Lines Matching refs:substream
37 #define trace_hw_mask_param(substream, type, index, prev, curr) argument
38 #define trace_hw_interval_param(substream, type, index, prev, curr) argument
65 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream,
67 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream,
114 void snd_pcm_stream_lock(struct snd_pcm_substream *substream) in snd_pcm_stream_lock() argument
116 snd_pcm_group_lock(&substream->self_group, substream->pcm->nonatomic); in snd_pcm_stream_lock()
126 void snd_pcm_stream_unlock(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock() argument
128 snd_pcm_group_unlock(&substream->self_group, substream->pcm->nonatomic); in snd_pcm_stream_unlock()
140 void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_lock_irq() argument
142 snd_pcm_group_lock_irq(&substream->self_group, in snd_pcm_stream_lock_irq()
143 substream->pcm->nonatomic); in snd_pcm_stream_lock_irq()
147 static void snd_pcm_stream_lock_nested(struct snd_pcm_substream *substream) in snd_pcm_stream_lock_nested() argument
149 struct snd_pcm_group *group = &substream->self_group; in snd_pcm_stream_lock_nested()
151 if (substream->pcm->nonatomic) in snd_pcm_stream_lock_nested()
163 void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock_irq() argument
165 snd_pcm_group_unlock_irq(&substream->self_group, in snd_pcm_stream_unlock_irq()
166 substream->pcm->nonatomic); in snd_pcm_stream_unlock_irq()
170 unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream) in _snd_pcm_stream_lock_irqsave() argument
173 if (substream->pcm->nonatomic) in _snd_pcm_stream_lock_irqsave()
174 mutex_lock(&substream->self_group.mutex); in _snd_pcm_stream_lock_irqsave()
176 spin_lock_irqsave(&substream->self_group.lock, flags); in _snd_pcm_stream_lock_irqsave()
181 unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream) in _snd_pcm_stream_lock_irqsave_nested() argument
184 if (substream->pcm->nonatomic) in _snd_pcm_stream_lock_irqsave_nested()
185 mutex_lock_nested(&substream->self_group.mutex, in _snd_pcm_stream_lock_irqsave_nested()
188 spin_lock_irqsave_nested(&substream->self_group.lock, flags, in _snd_pcm_stream_lock_irqsave_nested()
201 void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream, in snd_pcm_stream_unlock_irqrestore() argument
204 if (substream->pcm->nonatomic) in snd_pcm_stream_unlock_irqrestore()
205 mutex_unlock(&substream->self_group.mutex); in snd_pcm_stream_unlock_irqrestore()
207 spin_unlock_irqrestore(&substream->self_group.lock, flags); in snd_pcm_stream_unlock_irqrestore()
212 static int snd_pcm_ops_ioctl(struct snd_pcm_substream *substream, in snd_pcm_ops_ioctl() argument
215 if (substream->ops->ioctl) in snd_pcm_ops_ioctl()
216 return substream->ops->ioctl(substream, cmd, arg); in snd_pcm_ops_ioctl()
218 return snd_pcm_lib_ioctl(substream, cmd, arg); in snd_pcm_ops_ioctl()
221 int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info) in snd_pcm_info() argument
223 struct snd_pcm *pcm = substream->pcm; in snd_pcm_info()
224 struct snd_pcm_str *pstr = substream->pstr; in snd_pcm_info()
229 info->stream = substream->stream; in snd_pcm_info()
230 info->subdevice = substream->number; in snd_pcm_info()
237 strscpy(info->subname, substream->name, sizeof(info->subname)); in snd_pcm_info()
242 int snd_pcm_info_user(struct snd_pcm_substream *substream, in snd_pcm_info_user() argument
251 err = snd_pcm_info(substream, info); in snd_pcm_info_user()
262 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()
269 if (substream->ops->mmap || substream->ops->page) in hw_support_mmap()
272 dmabuf = snd_pcm_get_dma_buf(substream); in hw_support_mmap()
274 dmabuf = &substream->dma_buffer; in hw_support_mmap()
289 static int constrain_mask_params(struct snd_pcm_substream *substream, in constrain_mask_params() argument
293 &substream->runtime->hw_constraints; in constrain_mask_params()
318 trace_hw_mask_param(substream, k, 0, &old_mask, m); in constrain_mask_params()
325 static int constrain_interval_params(struct snd_pcm_substream *substream, in constrain_interval_params() argument
329 &substream->runtime->hw_constraints; in constrain_interval_params()
354 trace_hw_interval_param(substream, k, 0, &old_interval, i); in constrain_interval_params()
361 static int constrain_params_by_rules(struct snd_pcm_substream *substream, in constrain_params_by_rules() argument
365 &substream->runtime->hw_constraints; in constrain_params_by_rules()
453 trace_hw_mask_param(substream, r->var, in constrain_params_by_rules()
458 trace_hw_interval_param(substream, r->var, in constrain_params_by_rules()
478 static int fixup_unreferenced_params(struct snd_pcm_substream *substream, in fixup_unreferenced_params() argument
525 err = snd_pcm_ops_ioctl(substream, in fixup_unreferenced_params()
534 params->info = substream->runtime->hw.info; in fixup_unreferenced_params()
537 if (!hw_support_mmap(substream)) in fixup_unreferenced_params()
542 err = snd_pcm_ops_ioctl(substream, in fixup_unreferenced_params()
551 int snd_pcm_hw_refine(struct snd_pcm_substream *substream, in snd_pcm_hw_refine() argument
565 err = constrain_mask_params(substream, params); in snd_pcm_hw_refine()
569 err = constrain_interval_params(substream, params); in snd_pcm_hw_refine()
573 err = constrain_params_by_rules(substream, params); in snd_pcm_hw_refine()
583 static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_user() argument
593 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_user()
597 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_user()
621 static void snd_pcm_set_state(struct snd_pcm_substream *substream, in snd_pcm_set_state() argument
624 guard(pcm_stream_lock_irq)(substream); in snd_pcm_set_state()
625 if (substream->runtime->state != SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_set_state()
626 __snd_pcm_set_state(substream->runtime, state); in snd_pcm_set_state()
629 static inline void snd_pcm_timer_notify(struct snd_pcm_substream *substream, in snd_pcm_timer_notify() argument
633 if (substream->timer) in snd_pcm_timer_notify()
634 snd_timer_notify(substream->timer, event, in snd_pcm_timer_notify()
635 &substream->runtime->trigger_tstamp); in snd_pcm_timer_notify()
639 void snd_pcm_sync_stop(struct snd_pcm_substream *substream, bool sync_irq) in snd_pcm_sync_stop() argument
641 if (substream->runtime && substream->runtime->stop_operating) { in snd_pcm_sync_stop()
642 substream->runtime->stop_operating = false; in snd_pcm_sync_stop()
643 if (substream->ops && substream->ops->sync_stop) in snd_pcm_sync_stop()
644 substream->ops->sync_stop(substream); in snd_pcm_sync_stop()
645 else if (sync_irq && substream->pcm->card->sync_irq > 0) in snd_pcm_sync_stop()
646 synchronize_irq(substream->pcm->card->sync_irq); in snd_pcm_sync_stop()
749 #define is_oss_stream(substream) ((substream)->oss.oss) argument
751 #define is_oss_stream(substream) false argument
754 static int snd_pcm_hw_params(struct snd_pcm_substream *substream, in snd_pcm_hw_params() argument
762 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_params()
764 runtime = substream->runtime; in snd_pcm_hw_params()
768 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_hw_params()
773 if (!is_oss_stream(substream) && in snd_pcm_hw_params()
774 atomic_read(&substream->mmap_count)) in snd_pcm_hw_params()
785 snd_pcm_sync_stop(substream, true); in snd_pcm_hw_params()
788 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_params()
792 err = snd_pcm_hw_params_choose(substream, params); in snd_pcm_hw_params()
796 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_params()
800 if (substream->managed_buffer_alloc) { in snd_pcm_hw_params()
801 err = snd_pcm_lib_malloc_pages(substream, in snd_pcm_hw_params()
808 if (substream->ops->hw_params != NULL) { in snd_pcm_hw_params()
809 err = substream->ops->hw_params(substream, params); in snd_pcm_hw_params()
854 if (runtime->dma_area && !substream->ops->copy) { in snd_pcm_hw_params()
862 snd_pcm_timer_resolution_change(substream); in snd_pcm_hw_params()
863 snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_hw_params()
865 if (cpu_latency_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_hw_params()
866 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_params()
869 cpu_latency_qos_add_request(&substream->latency_pm_qos_req, in snd_pcm_hw_params()
878 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_params()
879 if (substream->ops->hw_free != NULL) in snd_pcm_hw_params()
880 substream->ops->hw_free(substream); in snd_pcm_hw_params()
881 if (substream->managed_buffer_alloc) in snd_pcm_hw_params()
882 snd_pcm_lib_free_pages(substream); in snd_pcm_hw_params()
889 static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_user() argument
899 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_user()
908 static int do_hw_free(struct snd_pcm_substream *substream) in do_hw_free() argument
912 snd_pcm_sync_stop(substream, true); in do_hw_free()
913 if (substream->ops->hw_free) in do_hw_free()
914 result = substream->ops->hw_free(substream); in do_hw_free()
915 if (substream->managed_buffer_alloc) in do_hw_free()
916 snd_pcm_lib_free_pages(substream); in do_hw_free()
920 static int snd_pcm_hw_free(struct snd_pcm_substream *substream) in snd_pcm_hw_free() argument
925 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_free()
927 runtime = substream->runtime; in snd_pcm_hw_free()
931 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_hw_free()
935 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_free()
945 result = do_hw_free(substream); in snd_pcm_hw_free()
946 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_free()
947 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_free()
953 static int snd_pcm_sw_params(struct snd_pcm_substream *substream, in snd_pcm_sw_params() argument
959 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_sw_params()
961 runtime = substream->runtime; in snd_pcm_sw_params()
962 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_sw_params()
985 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_sw_params()
996 if (snd_pcm_running(substream)) { in snd_pcm_sw_params()
997 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_sw_params()
999 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_sw_params()
1000 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
1006 static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, in snd_pcm_sw_params_user() argument
1013 err = snd_pcm_sw_params(substream, ¶ms); in snd_pcm_sw_params_user()
1020 snd_pcm_calc_delay(struct snd_pcm_substream *substream) in snd_pcm_calc_delay() argument
1024 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_calc_delay()
1025 delay = snd_pcm_playback_hw_avail(substream->runtime); in snd_pcm_calc_delay()
1027 delay = snd_pcm_capture_avail(substream->runtime); in snd_pcm_calc_delay()
1028 return delay + substream->runtime->delay; in snd_pcm_calc_delay()
1031 int snd_pcm_status64(struct snd_pcm_substream *substream, in snd_pcm_status64() argument
1034 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status64()
1036 guard(pcm_stream_lock_irq)(substream); in snd_pcm_status64()
1060 if (snd_pcm_running(substream)) { in snd_pcm_status64()
1061 snd_pcm_update_hw_ptr(substream); in snd_pcm_status64()
1095 status->avail = snd_pcm_avail(substream); in snd_pcm_status64()
1096 status->delay = snd_pcm_running(substream) ? in snd_pcm_status64()
1097 snd_pcm_calc_delay(substream) : 0; in snd_pcm_status64()
1105 static int snd_pcm_status_user64(struct snd_pcm_substream *substream, in snd_pcm_status_user64() argument
1121 res = snd_pcm_status64(substream, &status); in snd_pcm_status_user64()
1129 static int snd_pcm_status_user32(struct snd_pcm_substream *substream, in snd_pcm_status_user32() argument
1147 res = snd_pcm_status64(substream, &status64); in snd_pcm_status_user32()
1178 static int snd_pcm_channel_info(struct snd_pcm_substream *substream, in snd_pcm_channel_info() argument
1185 runtime = substream->runtime; in snd_pcm_channel_info()
1186 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_channel_info()
1194 return snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info); in snd_pcm_channel_info()
1197 static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, in snd_pcm_channel_info_user() argument
1205 res = snd_pcm_channel_info(substream, &info); in snd_pcm_channel_info_user()
1213 static void snd_pcm_trigger_tstamp(struct snd_pcm_substream *substream) in snd_pcm_trigger_tstamp() argument
1215 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp()
1218 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
1231 int (*pre_action)(struct snd_pcm_substream *substream,
1233 int (*do_action)(struct snd_pcm_substream *substream,
1235 void (*undo_action)(struct snd_pcm_substream *substream,
1237 void (*post_action)(struct snd_pcm_substream *substream,
1247 struct snd_pcm_substream *substream, in snd_pcm_action_group() argument
1255 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1256 if (s != substream) { in snd_pcm_action_group()
1269 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1273 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
1283 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1288 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
1289 if (s1 != substream) { in snd_pcm_action_group()
1307 struct snd_pcm_substream *substream, in snd_pcm_action_single() argument
1312 res = ops->pre_action(substream, state); in snd_pcm_action_single()
1315 res = ops->do_action(substream, state); in snd_pcm_action_single()
1317 ops->post_action(substream, state); in snd_pcm_action_single()
1319 ops->undo_action(substream, state); in snd_pcm_action_single()
1323 static void snd_pcm_group_assign(struct snd_pcm_substream *substream, in snd_pcm_group_assign() argument
1326 substream->group = new_group; in snd_pcm_group_assign()
1327 list_move(&substream->link_list, &new_group->substreams); in snd_pcm_group_assign()
1335 struct snd_pcm_substream *substream) in snd_pcm_group_unref() argument
1342 snd_pcm_group_unlock(group, substream->pcm->nonatomic); in snd_pcm_group_unref()
1352 snd_pcm_stream_group_ref(struct snd_pcm_substream *substream) in snd_pcm_stream_group_ref() argument
1354 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_stream_group_ref()
1359 if (!snd_pcm_stream_linked(substream)) in snd_pcm_stream_group_ref()
1361 group = substream->group; in snd_pcm_stream_group_ref()
1371 snd_pcm_stream_unlock(substream); in snd_pcm_stream_group_ref()
1373 snd_pcm_stream_lock(substream); in snd_pcm_stream_group_ref()
1376 if (substream->group == group) in snd_pcm_stream_group_ref()
1379 snd_pcm_group_unref(group, substream); in snd_pcm_stream_group_ref()
1388 struct snd_pcm_substream *substream, in snd_pcm_action() argument
1394 group = snd_pcm_stream_group_ref(substream); in snd_pcm_action()
1396 res = snd_pcm_action_group(ops, substream, state, true); in snd_pcm_action()
1398 res = snd_pcm_action_single(ops, substream, state); in snd_pcm_action()
1399 snd_pcm_group_unref(group, substream); in snd_pcm_action()
1407 struct snd_pcm_substream *substream, in snd_pcm_action_lock_irq() argument
1410 guard(pcm_stream_lock_irq)(substream); in snd_pcm_action_lock_irq()
1411 return snd_pcm_action(ops, substream, state); in snd_pcm_action_lock_irq()
1417 struct snd_pcm_substream *substream, in snd_pcm_action_nonatomic() argument
1424 res = snd_pcm_buffer_access_lock(substream->runtime); in snd_pcm_action_nonatomic()
1427 if (snd_pcm_stream_linked(substream)) in snd_pcm_action_nonatomic()
1428 res = snd_pcm_action_group(ops, substream, state, false); in snd_pcm_action_nonatomic()
1430 res = snd_pcm_action_single(ops, substream, state); in snd_pcm_action_nonatomic()
1431 snd_pcm_buffer_access_unlock(substream->runtime); in snd_pcm_action_nonatomic()
1438 static int snd_pcm_pre_start(struct snd_pcm_substream *substream, in snd_pcm_pre_start() argument
1441 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start()
1444 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_pre_start()
1445 !snd_pcm_playback_data(substream)) in snd_pcm_pre_start()
1448 runtime->trigger_master = substream; in snd_pcm_pre_start()
1452 static int snd_pcm_do_start(struct snd_pcm_substream *substream, in snd_pcm_do_start() argument
1457 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1459 err = substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); in snd_pcm_do_start()
1462 __snd_pcm_set_state(substream->runtime, SNDRV_PCM_STATE_XRUN); in snd_pcm_do_start()
1466 static void snd_pcm_undo_start(struct snd_pcm_substream *substream, in snd_pcm_undo_start() argument
1469 if (substream->runtime->trigger_master == substream) { in snd_pcm_undo_start()
1470 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_undo_start()
1471 substream->runtime->stop_operating = true; in snd_pcm_undo_start()
1475 static void snd_pcm_post_start(struct snd_pcm_substream *substream, in snd_pcm_post_start() argument
1478 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start()
1479 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_start()
1484 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_start()
1486 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_start()
1487 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTART); in snd_pcm_post_start()
1504 int snd_pcm_start(struct snd_pcm_substream *substream) in snd_pcm_start() argument
1506 return snd_pcm_action(&snd_pcm_action_start, substream, in snd_pcm_start()
1511 static int snd_pcm_start_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_start_lock_irq() argument
1513 return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, in snd_pcm_start_lock_irq()
1520 static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, in snd_pcm_pre_stop() argument
1523 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop()
1526 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1530 static int snd_pcm_do_stop(struct snd_pcm_substream *substream, in snd_pcm_do_stop() argument
1533 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1534 snd_pcm_running(substream)) { in snd_pcm_do_stop()
1535 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_do_stop()
1536 substream->runtime->stop_operating = true; in snd_pcm_do_stop()
1541 static void snd_pcm_post_stop(struct snd_pcm_substream *substream, in snd_pcm_post_stop() argument
1544 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop()
1546 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_stop()
1548 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTOP); in snd_pcm_post_stop()
1569 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) in snd_pcm_stop() argument
1571 return snd_pcm_action(&snd_pcm_action_stop, substream, state); in snd_pcm_stop()
1584 int snd_pcm_drain_done(struct snd_pcm_substream *substream) in snd_pcm_drain_done() argument
1586 return snd_pcm_action_single(&snd_pcm_action_stop, substream, in snd_pcm_drain_done()
1599 int snd_pcm_stop_xrun(struct snd_pcm_substream *substream) in snd_pcm_stop_xrun() argument
1601 guard(pcm_stream_lock_irqsave)(substream); in snd_pcm_stop_xrun()
1602 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1603 __snd_pcm_xrun(substream); in snd_pcm_stop_xrun()
1613 static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, in snd_pcm_pre_pause() argument
1616 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause()
1624 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1628 static int snd_pcm_do_pause(struct snd_pcm_substream *substream, in snd_pcm_do_pause() argument
1631 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1637 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1638 return substream->ops->trigger(substream, in snd_pcm_do_pause()
1644 static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, in snd_pcm_undo_pause() argument
1647 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1648 substream->ops->trigger(substream, in snd_pcm_undo_pause()
1654 static void snd_pcm_post_pause(struct snd_pcm_substream *substream, in snd_pcm_post_pause() argument
1657 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause()
1658 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_pause()
1661 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MPAUSE); in snd_pcm_post_pause()
1666 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MCONTINUE); in snd_pcm_post_pause()
1680 static int snd_pcm_pause(struct snd_pcm_substream *substream, bool push) in snd_pcm_pause() argument
1682 return snd_pcm_action(&snd_pcm_action_pause, substream, in snd_pcm_pause()
1686 static int snd_pcm_pause_lock_irq(struct snd_pcm_substream *substream, in snd_pcm_pause_lock_irq() argument
1689 return snd_pcm_action_lock_irq(&snd_pcm_action_pause, substream, in snd_pcm_pause_lock_irq()
1696 static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, in snd_pcm_pre_suspend() argument
1699 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend()
1709 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1713 static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, in snd_pcm_do_suspend() argument
1716 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend()
1717 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1719 if (! snd_pcm_running(substream)) in snd_pcm_do_suspend()
1721 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_do_suspend()
1726 static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, in snd_pcm_post_suspend() argument
1729 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend()
1730 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_suspend()
1734 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSUSPEND); in snd_pcm_post_suspend()
1753 static int snd_pcm_suspend(struct snd_pcm_substream *substream) in snd_pcm_suspend() argument
1755 guard(pcm_stream_lock_irqsave)(substream); in snd_pcm_suspend()
1756 return snd_pcm_action(&snd_pcm_action_suspend, substream, in snd_pcm_suspend()
1770 struct snd_pcm_substream *substream; in snd_pcm_suspend_all() local
1776 for_each_pcm_substream(pcm, stream, substream) { in snd_pcm_suspend_all()
1778 if (!substream->runtime) in snd_pcm_suspend_all()
1785 if (!substream->ops) in snd_pcm_suspend_all()
1788 err = snd_pcm_suspend(substream); in snd_pcm_suspend_all()
1793 for_each_pcm_substream(pcm, stream, substream) in snd_pcm_suspend_all()
1794 snd_pcm_sync_stop(substream, false); in snd_pcm_suspend_all()
1802 static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, in snd_pcm_pre_resume() argument
1805 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume()
1810 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1814 static int snd_pcm_do_resume(struct snd_pcm_substream *substream, in snd_pcm_do_resume() argument
1817 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume()
1818 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1823 substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) in snd_pcm_do_resume()
1825 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); in snd_pcm_do_resume()
1828 static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, in snd_pcm_undo_resume() argument
1831 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1832 snd_pcm_running(substream)) in snd_pcm_undo_resume()
1833 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_undo_resume()
1836 static void snd_pcm_post_resume(struct snd_pcm_substream *substream, in snd_pcm_post_resume() argument
1839 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume()
1840 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_resume()
1842 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MRESUME); in snd_pcm_post_resume()
1852 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1854 return snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, in snd_pcm_resume()
1860 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1872 static int snd_pcm_xrun(struct snd_pcm_substream *substream) in snd_pcm_xrun() argument
1874 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun()
1876 guard(pcm_stream_lock_irq)(substream); in snd_pcm_xrun()
1881 __snd_pcm_xrun(substream); in snd_pcm_xrun()
1892 static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, in snd_pcm_pre_reset() argument
1895 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset()
1907 static int snd_pcm_do_reset(struct snd_pcm_substream *substream, in snd_pcm_do_reset() argument
1910 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset()
1911 int err = snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); in snd_pcm_do_reset()
1914 guard(pcm_stream_lock_irq)(substream); in snd_pcm_do_reset()
1923 static void snd_pcm_post_reset(struct snd_pcm_substream *substream, in snd_pcm_post_reset() argument
1926 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset()
1927 guard(pcm_stream_lock_irq)(substream); in snd_pcm_post_reset()
1929 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_reset()
1931 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_reset()
1940 static int snd_pcm_reset(struct snd_pcm_substream *substream) in snd_pcm_reset() argument
1942 return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, in snd_pcm_reset()
1950 static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, in snd_pcm_pre_prepare() argument
1953 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare()
1959 if (snd_pcm_running(substream)) in snd_pcm_pre_prepare()
1961 substream->f_flags = f_flags; in snd_pcm_pre_prepare()
1965 static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, in snd_pcm_do_prepare() argument
1969 snd_pcm_sync_stop(substream, true); in snd_pcm_do_prepare()
1970 err = substream->ops->prepare(substream); in snd_pcm_do_prepare()
1973 return snd_pcm_do_reset(substream, state); in snd_pcm_do_prepare()
1976 static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, in snd_pcm_post_prepare() argument
1979 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare()
1981 snd_pcm_set_state(substream, SNDRV_PCM_STATE_PREPARED); in snd_pcm_post_prepare()
1997 static int snd_pcm_prepare(struct snd_pcm_substream *substream, in snd_pcm_prepare() argument
2005 f_flags = substream->f_flags; in snd_pcm_prepare()
2007 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_prepare()
2008 switch (substream->runtime->state) { in snd_pcm_prepare()
2010 snd_pcm_pause(substream, false); in snd_pcm_prepare()
2013 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_prepare()
2019 substream, in snd_pcm_prepare()
2028 static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, in snd_pcm_pre_drain_init() argument
2031 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init()
2038 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
2042 static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, in snd_pcm_do_drain_init() argument
2045 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init()
2046 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_do_drain_init()
2050 if (! snd_pcm_playback_empty(substream)) { in snd_pcm_do_drain_init()
2051 snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2052 snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2073 snd_pcm_do_stop(substream, new_state); in snd_pcm_do_drain_init()
2074 snd_pcm_post_stop(substream, new_state); in snd_pcm_do_drain_init()
2079 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
2081 return substream->ops->trigger(substream, in snd_pcm_do_drain_init()
2087 static void snd_pcm_post_drain_init(struct snd_pcm_substream *substream, in snd_pcm_post_drain_init() argument
2105 static int snd_pcm_drain(struct snd_pcm_substream *substream, in snd_pcm_drain() argument
2116 card = substream->pcm->card; in snd_pcm_drain()
2117 runtime = substream->runtime; in snd_pcm_drain()
2125 } else if (substream->f_flags & O_NONBLOCK) in snd_pcm_drain()
2128 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
2131 snd_pcm_pause(substream, false); in snd_pcm_drain()
2134 result = snd_pcm_action(&snd_pcm_action_drain_init, substream, in snd_pcm_drain()
2157 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
2158 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
2167 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
2182 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
2195 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
2196 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
2197 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
2203 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
2210 if (substream->runtime->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
2213 dev_dbg(substream->pcm->card->dev, in snd_pcm_drain()
2215 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drain()
2223 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
2233 static int snd_pcm_drop(struct snd_pcm_substream *substream) in snd_pcm_drop() argument
2238 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_drop()
2240 runtime = substream->runtime; in snd_pcm_drop()
2246 guard(pcm_stream_lock_irq)(substream); in snd_pcm_drop()
2249 snd_pcm_pause(substream, false); in snd_pcm_drop()
2251 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drop()
2279 static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) in snd_pcm_link() argument
2284 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_link()
2293 substream1 = pcm_file->substream; in snd_pcm_link()
2295 if (substream == substream1) in snd_pcm_link()
2305 if (substream->runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
2306 substream->runtime->state != substream1->runtime->state || in snd_pcm_link()
2307 substream->pcm->nonatomic != substream1->pcm->nonatomic) in snd_pcm_link()
2312 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_link()
2313 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_link()
2314 snd_pcm_group_assign(substream, group); in snd_pcm_link()
2317 target_group = substream->group; in snd_pcm_link()
2329 static void relink_to_local(struct snd_pcm_substream *substream) in relink_to_local() argument
2331 snd_pcm_stream_lock_nested(substream); in relink_to_local()
2332 snd_pcm_group_assign(substream, &substream->self_group); in relink_to_local()
2333 snd_pcm_stream_unlock(substream); in relink_to_local()
2336 static int snd_pcm_unlink(struct snd_pcm_substream *substream) in snd_pcm_unlink() argument
2339 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_unlink()
2344 if (!snd_pcm_stream_linked(substream)) in snd_pcm_unlink()
2347 group = substream->group; in snd_pcm_unlink()
2350 relink_to_local(substream); in snd_pcm_unlink()
2487 struct snd_pcm_substream *substream = rule->private; in snd_pcm_hw_rule_buffer_bytes_max() local
2489 t.max = substream->buffer_bytes_max; in snd_pcm_hw_rule_buffer_bytes_max()
2531 static int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_init() argument
2533 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init()
2655 static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_complete() argument
2657 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete()
2666 if (hw_support_mmap(substream)) { in snd_pcm_hw_constraints_complete()
2712 snd_pcm_hw_rule_buffer_bytes_max, substream, in snd_pcm_hw_constraints_complete()
2738 static void pcm_release_private(struct snd_pcm_substream *substream) in pcm_release_private() argument
2740 if (snd_pcm_stream_linked(substream)) in pcm_release_private()
2741 snd_pcm_unlink(substream); in pcm_release_private()
2744 void snd_pcm_release_substream(struct snd_pcm_substream *substream) in snd_pcm_release_substream() argument
2746 substream->ref_count--; in snd_pcm_release_substream()
2747 if (substream->ref_count > 0) in snd_pcm_release_substream()
2750 snd_pcm_drop(substream); in snd_pcm_release_substream()
2751 if (substream->hw_opened) { in snd_pcm_release_substream()
2752 if (substream->runtime->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2753 do_hw_free(substream); in snd_pcm_release_substream()
2754 substream->ops->close(substream); in snd_pcm_release_substream()
2755 substream->hw_opened = 0; in snd_pcm_release_substream()
2757 if (cpu_latency_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_release_substream()
2758 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_release_substream()
2759 if (substream->pcm_release) { in snd_pcm_release_substream()
2760 substream->pcm_release(substream); in snd_pcm_release_substream()
2761 substream->pcm_release = NULL; in snd_pcm_release_substream()
2763 snd_pcm_detach_substream(substream); in snd_pcm_release_substream()
2771 struct snd_pcm_substream *substream; in snd_pcm_open_substream() local
2774 err = snd_pcm_attach_substream(pcm, stream, file, &substream); in snd_pcm_open_substream()
2777 if (substream->ref_count > 1) { in snd_pcm_open_substream()
2778 *rsubstream = substream; in snd_pcm_open_substream()
2782 err = snd_pcm_hw_constraints_init(substream); in snd_pcm_open_substream()
2788 err = substream->ops->open(substream); in snd_pcm_open_substream()
2792 substream->hw_opened = 1; in snd_pcm_open_substream()
2794 err = snd_pcm_hw_constraints_complete(substream); in snd_pcm_open_substream()
2803 if (substream->managed_buffer_alloc && in snd_pcm_open_substream()
2804 substream->dma_buffer.dev.need_sync) in snd_pcm_open_substream()
2805 substream->runtime->hw.info |= SNDRV_PCM_INFO_EXPLICIT_SYNC; in snd_pcm_open_substream()
2807 *rsubstream = substream; in snd_pcm_open_substream()
2811 snd_pcm_release_substream(substream); in snd_pcm_open_substream()
2821 struct snd_pcm_substream *substream; in snd_pcm_open_file() local
2824 err = snd_pcm_open_substream(pcm, stream, file, &substream); in snd_pcm_open_file()
2830 snd_pcm_release_substream(substream); in snd_pcm_open_file()
2833 pcm_file->substream = substream; in snd_pcm_open_file()
2834 if (substream->ref_count == 1) in snd_pcm_open_file()
2835 substream->pcm_release = pcm_release_private; in snd_pcm_open_file()
2929 struct snd_pcm_substream *substream; in snd_pcm_release() local
2933 substream = pcm_file->substream; in snd_pcm_release()
2934 if (snd_BUG_ON(!substream)) in snd_pcm_release()
2936 pcm = substream->pcm; in snd_pcm_release()
2942 snd_pcm_release_substream(substream); in snd_pcm_release()
2954 static int do_pcm_hwsync(struct snd_pcm_substream *substream) in do_pcm_hwsync() argument
2956 switch (substream->runtime->state) { in do_pcm_hwsync()
2958 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in do_pcm_hwsync()
2962 return snd_pcm_update_hw_ptr(substream); in do_pcm_hwsync()
2976 static snd_pcm_sframes_t forward_appl_ptr(struct snd_pcm_substream *substream, in forward_appl_ptr() argument
2980 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr()
2991 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in forward_appl_ptr()
2996 static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream, in rewind_appl_ptr() argument
3000 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr()
3011 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in rewind_appl_ptr()
3020 static snd_pcm_sframes_t snd_pcm_rewind(struct snd_pcm_substream *substream, in snd_pcm_rewind() argument
3028 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_rewind()
3029 ret = do_pcm_hwsync(substream); in snd_pcm_rewind()
3031 ret = rewind_appl_ptr(substream, frames, in snd_pcm_rewind()
3032 snd_pcm_hw_avail(substream)); in snd_pcm_rewind()
3035 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_rewind()
3039 static snd_pcm_sframes_t snd_pcm_forward(struct snd_pcm_substream *substream, in snd_pcm_forward() argument
3047 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_forward()
3048 ret = do_pcm_hwsync(substream); in snd_pcm_forward()
3050 ret = forward_appl_ptr(substream, frames, in snd_pcm_forward()
3051 snd_pcm_avail(substream)); in snd_pcm_forward()
3054 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_forward()
3058 static int snd_pcm_delay(struct snd_pcm_substream *substream, in snd_pcm_delay() argument
3063 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_delay()
3064 err = do_pcm_hwsync(substream); in snd_pcm_delay()
3066 *delay = snd_pcm_calc_delay(substream); in snd_pcm_delay()
3068 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_CPU); in snd_pcm_delay()
3073 static inline int snd_pcm_hwsync(struct snd_pcm_substream *substream) in snd_pcm_hwsync() argument
3075 return snd_pcm_delay(substream, NULL); in snd_pcm_hwsync()
3118 static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, in snd_pcm_sync_ptr() argument
3121 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr()
3134 err = snd_pcm_hwsync(substream); in snd_pcm_sync_ptr()
3138 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_sync_ptr()
3140 err = pcm_lib_apply_appl_ptr(substream, scontrol.appl_ptr); in snd_pcm_sync_ptr()
3157 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_sync_ptr()
3212 static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, in snd_pcm_ioctl_sync_ptr_compat() argument
3215 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_ioctl_sync_ptr_compat()
3230 err = snd_pcm_hwsync(substream); in snd_pcm_ioctl_sync_ptr_compat()
3239 scoped_guard(pcm_stream_lock_irq, substream) { in snd_pcm_ioctl_sync_ptr_compat()
3242 err = pcm_lib_apply_appl_ptr(substream, in snd_pcm_ioctl_sync_ptr_compat()
3259 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_ioctl_sync_ptr_compat()
3267 static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) in snd_pcm_tstamp() argument
3269 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp()
3280 static int snd_pcm_xferi_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xferi_frames_ioctl() argument
3284 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl()
3293 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xferi_frames_ioctl()
3294 result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
3296 result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
3302 static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xfern_frames_ioctl() argument
3306 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl()
3322 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xfern_frames_ioctl()
3323 result = snd_pcm_lib_writev(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
3325 result = snd_pcm_lib_readv(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
3331 static int snd_pcm_rewind_ioctl(struct snd_pcm_substream *substream, in snd_pcm_rewind_ioctl() argument
3341 result = snd_pcm_rewind(substream, frames); in snd_pcm_rewind_ioctl()
3347 static int snd_pcm_forward_ioctl(struct snd_pcm_substream *substream, in snd_pcm_forward_ioctl() argument
3357 result = snd_pcm_forward(substream, frames); in snd_pcm_forward_ioctl()
3364 struct snd_pcm_substream *substream, in snd_pcm_common_ioctl() argument
3370 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_common_ioctl()
3373 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_common_ioctl()
3376 res = snd_power_wait(substream->pcm->card); in snd_pcm_common_ioctl()
3384 return snd_pcm_info_user(substream, arg); in snd_pcm_common_ioctl()
3388 return snd_pcm_tstamp(substream, arg); in snd_pcm_common_ioctl()
3395 return snd_pcm_hw_refine_user(substream, arg); in snd_pcm_common_ioctl()
3397 return snd_pcm_hw_params_user(substream, arg); in snd_pcm_common_ioctl()
3399 return snd_pcm_hw_free(substream); in snd_pcm_common_ioctl()
3401 return snd_pcm_sw_params_user(substream, arg); in snd_pcm_common_ioctl()
3403 return snd_pcm_status_user32(substream, arg, false); in snd_pcm_common_ioctl()
3405 return snd_pcm_status_user32(substream, arg, true); in snd_pcm_common_ioctl()
3407 return snd_pcm_status_user64(substream, arg, false); in snd_pcm_common_ioctl()
3409 return snd_pcm_status_user64(substream, arg, true); in snd_pcm_common_ioctl()
3411 return snd_pcm_channel_info_user(substream, arg); in snd_pcm_common_ioctl()
3413 return snd_pcm_prepare(substream, file); in snd_pcm_common_ioctl()
3415 return snd_pcm_reset(substream); in snd_pcm_common_ioctl()
3417 return snd_pcm_start_lock_irq(substream); in snd_pcm_common_ioctl()
3419 return snd_pcm_link(substream, (int)(unsigned long) arg); in snd_pcm_common_ioctl()
3421 return snd_pcm_unlink(substream); in snd_pcm_common_ioctl()
3423 return snd_pcm_resume(substream); in snd_pcm_common_ioctl()
3425 return snd_pcm_xrun(substream); in snd_pcm_common_ioctl()
3427 return snd_pcm_hwsync(substream); in snd_pcm_common_ioctl()
3434 err = snd_pcm_delay(substream, &delay); in snd_pcm_common_ioctl()
3442 return snd_pcm_ioctl_sync_ptr_compat(substream, arg); in snd_pcm_common_ioctl()
3444 return snd_pcm_sync_ptr(substream, arg); in snd_pcm_common_ioctl()
3447 return snd_pcm_hw_refine_old_user(substream, arg); in snd_pcm_common_ioctl()
3449 return snd_pcm_hw_params_old_user(substream, arg); in snd_pcm_common_ioctl()
3452 return snd_pcm_drain(substream, file); in snd_pcm_common_ioctl()
3454 return snd_pcm_drop(substream); in snd_pcm_common_ioctl()
3456 return snd_pcm_pause_lock_irq(substream, (unsigned long)arg); in snd_pcm_common_ioctl()
3459 return snd_pcm_xferi_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
3462 return snd_pcm_xfern_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
3464 return snd_pcm_rewind_ioctl(substream, arg); in snd_pcm_common_ioctl()
3466 return snd_pcm_forward_ioctl(substream, arg); in snd_pcm_common_ioctl()
3468 pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd); in snd_pcm_common_ioctl()
3482 return snd_pcm_common_ioctl(file, pcm_file->substream, cmd, in snd_pcm_ioctl()
3498 int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, in snd_pcm_kernel_ioctl() argument
3504 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_kernel_ioctl()
3511 if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) in snd_pcm_kernel_ioctl()
3513 result = snd_pcm_forward(substream, *frames); in snd_pcm_kernel_ioctl()
3517 return snd_pcm_hw_params(substream, arg); in snd_pcm_kernel_ioctl()
3519 return snd_pcm_sw_params(substream, arg); in snd_pcm_kernel_ioctl()
3521 return snd_pcm_prepare(substream, NULL); in snd_pcm_kernel_ioctl()
3523 return snd_pcm_start_lock_irq(substream); in snd_pcm_kernel_ioctl()
3525 return snd_pcm_drain(substream, NULL); in snd_pcm_kernel_ioctl()
3527 return snd_pcm_drop(substream); in snd_pcm_kernel_ioctl()
3529 return snd_pcm_delay(substream, frames); in snd_pcm_kernel_ioctl()
3540 struct snd_pcm_substream *substream; in snd_pcm_read() local
3545 substream = pcm_file->substream; in snd_pcm_read()
3546 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_read()
3548 runtime = substream->runtime; in snd_pcm_read()
3555 result = snd_pcm_lib_read(substream, buf, count); in snd_pcm_read()
3565 struct snd_pcm_substream *substream; in snd_pcm_write() local
3570 substream = pcm_file->substream; in snd_pcm_write()
3571 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_write()
3573 runtime = substream->runtime; in snd_pcm_write()
3580 result = snd_pcm_lib_write(substream, buf, count); in snd_pcm_write()
3589 struct snd_pcm_substream *substream; in snd_pcm_readv() local
3597 substream = pcm_file->substream; in snd_pcm_readv()
3598 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_readv()
3600 runtime = substream->runtime; in snd_pcm_readv()
3620 result = snd_pcm_lib_readv(substream, bufs, frames); in snd_pcm_readv()
3629 struct snd_pcm_substream *substream; in snd_pcm_writev() local
3637 substream = pcm_file->substream; in snd_pcm_writev()
3638 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_writev()
3640 runtime = substream->runtime; in snd_pcm_writev()
3659 result = snd_pcm_lib_writev(substream, bufs, frames); in snd_pcm_writev()
3668 struct snd_pcm_substream *substream; in snd_pcm_poll() local
3675 substream = pcm_file->substream; in snd_pcm_poll()
3676 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_poll()
3680 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_poll()
3683 runtime = substream->runtime; in snd_pcm_poll()
3690 guard(pcm_stream_lock_irq)(substream); in snd_pcm_poll()
3691 avail = snd_pcm_avail(substream); in snd_pcm_poll()
3700 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in snd_pcm_poll()
3727 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_status_fault() local
3730 if (substream == NULL) in snd_pcm_mmap_status_fault()
3732 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3743 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3753 area->vm_private_data = substream; in snd_pcm_mmap_status()
3765 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_control_fault() local
3768 if (substream == NULL) in snd_pcm_mmap_control_fault()
3770 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3781 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3791 area->vm_private_data = substream; in snd_pcm_mmap_control()
3802 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_status_mmap_allowed()
3809 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3819 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_control_mmap_allowed()
3825 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3837 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3842 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3854 struct snd_pcm_substream *substream = area->vm_private_data; in snd_pcm_mmap_data_open() local
3856 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data_open()
3864 struct snd_pcm_substream *substream = area->vm_private_data; in snd_pcm_mmap_data_close() local
3866 atomic_dec(&substream->mmap_count); in snd_pcm_mmap_data_close()
3874 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_data_fault() local
3880 if (substream == NULL) in snd_pcm_mmap_data_fault()
3882 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3887 if (substream->ops->page) in snd_pcm_mmap_data_fault()
3888 page = substream->ops->page(substream, offset); in snd_pcm_mmap_data_fault()
3889 else if (!snd_pcm_get_dma_buf(substream)) { in snd_pcm_mmap_data_fault()
3894 page = snd_sgbuf_get_page(snd_pcm_get_dma_buf(substream), offset); in snd_pcm_mmap_data_fault()
3927 int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, in snd_pcm_lib_default_mmap() argument
3931 if (!substream->ops->page && in snd_pcm_lib_default_mmap()
3932 !snd_dma_buffer_mmap(snd_pcm_get_dma_buf(substream), area)) in snd_pcm_lib_default_mmap()
3955 int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, in snd_pcm_lib_mmap_iomem() argument
3958 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_mmap_iomem()
3969 int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_data() argument
3978 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_mmap_data()
3985 runtime = substream->runtime; in snd_pcm_mmap_data()
4002 area->vm_private_data = substream; in snd_pcm_mmap_data()
4003 if (substream->ops->mmap) in snd_pcm_mmap_data()
4004 err = substream->ops->mmap(substream, area); in snd_pcm_mmap_data()
4006 err = snd_pcm_lib_default_mmap(substream, area); in snd_pcm_mmap_data()
4008 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data()
4016 struct snd_pcm_substream *substream; in snd_pcm_mmap() local
4020 substream = pcm_file->substream; in snd_pcm_mmap()
4021 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_mmap()
4023 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_mmap()
4035 return snd_pcm_mmap_status(substream, file, area); in snd_pcm_mmap()
4043 return snd_pcm_mmap_control(substream, file, area); in snd_pcm_mmap()
4045 return snd_pcm_mmap_data(substream, file, area); in snd_pcm_mmap()
4053 struct snd_pcm_substream *substream; in snd_pcm_fasync() local
4057 substream = pcm_file->substream; in snd_pcm_fasync()
4058 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_fasync()
4060 runtime = substream->runtime; in snd_pcm_fasync()
4121 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_old_user() argument
4136 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_old_user()
4140 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_old_user()
4150 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_old_user() argument
4166 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_old_user()
4185 struct snd_pcm_substream *substream = pcm_file->substream; in snd_pcm_get_unmapped_area() local
4186 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area()