Lines Matching refs:substream
36 #define trace_hw_mask_param(substream, type, index, prev, curr) argument
37 #define trace_hw_interval_param(substream, type, index, prev, curr) argument
64 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream,
66 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream,
108 void snd_pcm_stream_lock(struct snd_pcm_substream *substream) in snd_pcm_stream_lock() argument
110 snd_pcm_group_lock(&substream->self_group, substream->pcm->nonatomic); in snd_pcm_stream_lock()
120 void snd_pcm_stream_unlock(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock() argument
122 snd_pcm_group_unlock(&substream->self_group, substream->pcm->nonatomic); in snd_pcm_stream_unlock()
134 void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_lock_irq() argument
136 snd_pcm_group_lock_irq(&substream->self_group, in snd_pcm_stream_lock_irq()
137 substream->pcm->nonatomic); in snd_pcm_stream_lock_irq()
141 static void snd_pcm_stream_lock_nested(struct snd_pcm_substream *substream) in snd_pcm_stream_lock_nested() argument
143 struct snd_pcm_group *group = &substream->self_group; in snd_pcm_stream_lock_nested()
145 if (substream->pcm->nonatomic) in snd_pcm_stream_lock_nested()
157 void snd_pcm_stream_unlock_irq(struct snd_pcm_substream *substream) in snd_pcm_stream_unlock_irq() argument
159 snd_pcm_group_unlock_irq(&substream->self_group, in snd_pcm_stream_unlock_irq()
160 substream->pcm->nonatomic); in snd_pcm_stream_unlock_irq()
164 unsigned long _snd_pcm_stream_lock_irqsave(struct snd_pcm_substream *substream) in _snd_pcm_stream_lock_irqsave() argument
167 if (substream->pcm->nonatomic) in _snd_pcm_stream_lock_irqsave()
168 mutex_lock(&substream->self_group.mutex); in _snd_pcm_stream_lock_irqsave()
170 spin_lock_irqsave(&substream->self_group.lock, flags); in _snd_pcm_stream_lock_irqsave()
175 unsigned long _snd_pcm_stream_lock_irqsave_nested(struct snd_pcm_substream *substream) in _snd_pcm_stream_lock_irqsave_nested() argument
178 if (substream->pcm->nonatomic) in _snd_pcm_stream_lock_irqsave_nested()
179 mutex_lock_nested(&substream->self_group.mutex, in _snd_pcm_stream_lock_irqsave_nested()
182 spin_lock_irqsave_nested(&substream->self_group.lock, flags, in _snd_pcm_stream_lock_irqsave_nested()
195 void snd_pcm_stream_unlock_irqrestore(struct snd_pcm_substream *substream, in snd_pcm_stream_unlock_irqrestore() argument
198 if (substream->pcm->nonatomic) in snd_pcm_stream_unlock_irqrestore()
199 mutex_unlock(&substream->self_group.mutex); in snd_pcm_stream_unlock_irqrestore()
201 spin_unlock_irqrestore(&substream->self_group.lock, flags); in snd_pcm_stream_unlock_irqrestore()
206 static int snd_pcm_ops_ioctl(struct snd_pcm_substream *substream, in snd_pcm_ops_ioctl() argument
209 if (substream->ops->ioctl) in snd_pcm_ops_ioctl()
210 return substream->ops->ioctl(substream, cmd, arg); in snd_pcm_ops_ioctl()
212 return snd_pcm_lib_ioctl(substream, cmd, arg); in snd_pcm_ops_ioctl()
215 int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info) in snd_pcm_info() argument
217 struct snd_pcm *pcm = substream->pcm; in snd_pcm_info()
218 struct snd_pcm_str *pstr = substream->pstr; in snd_pcm_info()
223 info->stream = substream->stream; in snd_pcm_info()
224 info->subdevice = substream->number; in snd_pcm_info()
231 strscpy(info->subname, substream->name, sizeof(info->subname)); in snd_pcm_info()
236 int snd_pcm_info_user(struct snd_pcm_substream *substream, in snd_pcm_info_user() argument
245 err = snd_pcm_info(substream, info); in snd_pcm_info_user()
257 static bool hw_support_mmap(struct snd_pcm_substream *substream) in hw_support_mmap() argument
261 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_MMAP)) in hw_support_mmap()
264 if (substream->ops->mmap || substream->ops->page) in hw_support_mmap()
267 dmabuf = snd_pcm_get_dma_buf(substream); in hw_support_mmap()
269 dmabuf = &substream->dma_buffer; in hw_support_mmap()
284 static int constrain_mask_params(struct snd_pcm_substream *substream, in constrain_mask_params() argument
288 &substream->runtime->hw_constraints; in constrain_mask_params()
313 trace_hw_mask_param(substream, k, 0, &old_mask, m); in constrain_mask_params()
320 static int constrain_interval_params(struct snd_pcm_substream *substream, in constrain_interval_params() argument
324 &substream->runtime->hw_constraints; in constrain_interval_params()
349 trace_hw_interval_param(substream, k, 0, &old_interval, i); in constrain_interval_params()
356 static int constrain_params_by_rules(struct snd_pcm_substream *substream, in constrain_params_by_rules() argument
360 &substream->runtime->hw_constraints; in constrain_params_by_rules()
450 trace_hw_mask_param(substream, r->var, in constrain_params_by_rules()
455 trace_hw_interval_param(substream, r->var, in constrain_params_by_rules()
477 static int fixup_unreferenced_params(struct snd_pcm_substream *substream, in fixup_unreferenced_params() argument
502 err = snd_pcm_ops_ioctl(substream, in fixup_unreferenced_params()
511 params->info = substream->runtime->hw.info; in fixup_unreferenced_params()
514 if (!hw_support_mmap(substream)) in fixup_unreferenced_params()
522 int snd_pcm_hw_refine(struct snd_pcm_substream *substream, in snd_pcm_hw_refine() argument
536 err = constrain_mask_params(substream, params); in snd_pcm_hw_refine()
540 err = constrain_interval_params(substream, params); in snd_pcm_hw_refine()
544 err = constrain_params_by_rules(substream, params); in snd_pcm_hw_refine()
554 static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_user() argument
564 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_user()
568 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_user()
594 static void snd_pcm_set_state(struct snd_pcm_substream *substream, in snd_pcm_set_state() argument
597 snd_pcm_stream_lock_irq(substream); in snd_pcm_set_state()
598 if (substream->runtime->state != SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_set_state()
599 __snd_pcm_set_state(substream->runtime, state); in snd_pcm_set_state()
600 snd_pcm_stream_unlock_irq(substream); in snd_pcm_set_state()
603 static inline void snd_pcm_timer_notify(struct snd_pcm_substream *substream, in snd_pcm_timer_notify() argument
607 if (substream->timer) in snd_pcm_timer_notify()
608 snd_timer_notify(substream->timer, event, in snd_pcm_timer_notify()
609 &substream->runtime->trigger_tstamp); in snd_pcm_timer_notify()
613 void snd_pcm_sync_stop(struct snd_pcm_substream *substream, bool sync_irq) in snd_pcm_sync_stop() argument
615 if (substream->runtime && substream->runtime->stop_operating) { in snd_pcm_sync_stop()
616 substream->runtime->stop_operating = false; in snd_pcm_sync_stop()
617 if (substream->ops && substream->ops->sync_stop) in snd_pcm_sync_stop()
618 substream->ops->sync_stop(substream); in snd_pcm_sync_stop()
619 else if (sync_irq && substream->pcm->card->sync_irq > 0) in snd_pcm_sync_stop()
620 synchronize_irq(substream->pcm->card->sync_irq); in snd_pcm_sync_stop()
707 #define is_oss_stream(substream) ((substream)->oss.oss) argument
709 #define is_oss_stream(substream) false argument
712 static int snd_pcm_hw_params(struct snd_pcm_substream *substream, in snd_pcm_hw_params() argument
720 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_params()
722 runtime = substream->runtime; in snd_pcm_hw_params()
726 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_params()
731 if (!is_oss_stream(substream) && in snd_pcm_hw_params()
732 atomic_read(&substream->mmap_count)) in snd_pcm_hw_params()
739 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_params()
743 snd_pcm_sync_stop(substream, true); in snd_pcm_hw_params()
746 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_params()
750 err = snd_pcm_hw_params_choose(substream, params); in snd_pcm_hw_params()
754 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_params()
758 if (substream->managed_buffer_alloc) { in snd_pcm_hw_params()
759 err = snd_pcm_lib_malloc_pages(substream, in snd_pcm_hw_params()
766 if (substream->ops->hw_params != NULL) { in snd_pcm_hw_params()
767 err = substream->ops->hw_params(substream, params); in snd_pcm_hw_params()
812 if (runtime->dma_area && !substream->ops->copy_user) { in snd_pcm_hw_params()
820 snd_pcm_timer_resolution_change(substream); in snd_pcm_hw_params()
821 snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_hw_params()
823 if (cpu_latency_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_hw_params()
824 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_params()
827 cpu_latency_qos_add_request(&substream->latency_pm_qos_req, in snd_pcm_hw_params()
836 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_params()
837 if (substream->ops->hw_free != NULL) in snd_pcm_hw_params()
838 substream->ops->hw_free(substream); in snd_pcm_hw_params()
839 if (substream->managed_buffer_alloc) in snd_pcm_hw_params()
840 snd_pcm_lib_free_pages(substream); in snd_pcm_hw_params()
847 static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_user() argument
857 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_user()
868 static int do_hw_free(struct snd_pcm_substream *substream) in do_hw_free() argument
872 snd_pcm_sync_stop(substream, true); in do_hw_free()
873 if (substream->ops->hw_free) in do_hw_free()
874 result = substream->ops->hw_free(substream); in do_hw_free()
875 if (substream->managed_buffer_alloc) in do_hw_free()
876 snd_pcm_lib_free_pages(substream); in do_hw_free()
880 static int snd_pcm_hw_free(struct snd_pcm_substream *substream) in snd_pcm_hw_free() argument
885 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_hw_free()
887 runtime = substream->runtime; in snd_pcm_hw_free()
891 snd_pcm_stream_lock_irq(substream); in snd_pcm_hw_free()
895 if (atomic_read(&substream->mmap_count)) in snd_pcm_hw_free()
902 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hw_free()
905 result = do_hw_free(substream); in snd_pcm_hw_free()
906 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN); in snd_pcm_hw_free()
907 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_hw_free()
913 static int snd_pcm_sw_params(struct snd_pcm_substream *substream, in snd_pcm_sw_params() argument
919 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_sw_params()
921 runtime = substream->runtime; in snd_pcm_sw_params()
922 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
924 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
927 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
947 snd_pcm_stream_lock_irq(substream); in snd_pcm_sw_params()
958 if (snd_pcm_running(substream)) { in snd_pcm_sw_params()
959 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_sw_params()
961 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_sw_params()
962 err = snd_pcm_update_state(substream, runtime); in snd_pcm_sw_params()
964 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sw_params()
968 static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, in snd_pcm_sw_params_user() argument
975 err = snd_pcm_sw_params(substream, ¶ms); in snd_pcm_sw_params_user()
982 snd_pcm_calc_delay(struct snd_pcm_substream *substream) in snd_pcm_calc_delay() argument
986 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_calc_delay()
987 delay = snd_pcm_playback_hw_avail(substream->runtime); in snd_pcm_calc_delay()
989 delay = snd_pcm_capture_avail(substream->runtime); in snd_pcm_calc_delay()
990 return delay + substream->runtime->delay; in snd_pcm_calc_delay()
993 int snd_pcm_status64(struct snd_pcm_substream *substream, in snd_pcm_status64() argument
996 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_status64()
998 snd_pcm_stream_lock_irq(substream); in snd_pcm_status64()
1022 if (snd_pcm_running(substream)) { in snd_pcm_status64()
1023 snd_pcm_update_hw_ptr(substream); in snd_pcm_status64()
1057 status->avail = snd_pcm_avail(substream); in snd_pcm_status64()
1058 status->delay = snd_pcm_running(substream) ? in snd_pcm_status64()
1059 snd_pcm_calc_delay(substream) : 0; in snd_pcm_status64()
1065 snd_pcm_stream_unlock_irq(substream); in snd_pcm_status64()
1069 static int snd_pcm_status_user64(struct snd_pcm_substream *substream, in snd_pcm_status_user64() argument
1085 res = snd_pcm_status64(substream, &status); in snd_pcm_status_user64()
1093 static int snd_pcm_status_user32(struct snd_pcm_substream *substream, in snd_pcm_status_user32() argument
1111 res = snd_pcm_status64(substream, &status64); in snd_pcm_status_user32()
1142 static int snd_pcm_channel_info(struct snd_pcm_substream *substream, in snd_pcm_channel_info() argument
1149 runtime = substream->runtime; in snd_pcm_channel_info()
1150 snd_pcm_stream_lock_irq(substream); in snd_pcm_channel_info()
1152 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
1155 snd_pcm_stream_unlock_irq(substream); in snd_pcm_channel_info()
1160 return snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info); in snd_pcm_channel_info()
1163 static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, in snd_pcm_channel_info_user() argument
1171 res = snd_pcm_channel_info(substream, &info); in snd_pcm_channel_info_user()
1179 static void snd_pcm_trigger_tstamp(struct snd_pcm_substream *substream) in snd_pcm_trigger_tstamp() argument
1181 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_trigger_tstamp()
1184 if (runtime->trigger_master == substream) { in snd_pcm_trigger_tstamp()
1197 int (*pre_action)(struct snd_pcm_substream *substream,
1199 int (*do_action)(struct snd_pcm_substream *substream,
1201 void (*undo_action)(struct snd_pcm_substream *substream,
1203 void (*post_action)(struct snd_pcm_substream *substream,
1213 struct snd_pcm_substream *substream, in snd_pcm_action_group() argument
1221 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1222 if (s != substream) { in snd_pcm_action_group()
1235 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1239 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
1249 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_action_group()
1254 snd_pcm_group_for_each_entry(s1, substream) { in snd_pcm_action_group()
1255 if (s1 != substream) { in snd_pcm_action_group()
1273 struct snd_pcm_substream *substream, in snd_pcm_action_single() argument
1278 res = ops->pre_action(substream, state); in snd_pcm_action_single()
1281 res = ops->do_action(substream, state); in snd_pcm_action_single()
1283 ops->post_action(substream, state); in snd_pcm_action_single()
1285 ops->undo_action(substream, state); in snd_pcm_action_single()
1289 static void snd_pcm_group_assign(struct snd_pcm_substream *substream, in snd_pcm_group_assign() argument
1292 substream->group = new_group; in snd_pcm_group_assign()
1293 list_move(&substream->link_list, &new_group->substreams); in snd_pcm_group_assign()
1301 struct snd_pcm_substream *substream) in snd_pcm_group_unref() argument
1308 snd_pcm_group_unlock(group, substream->pcm->nonatomic); in snd_pcm_group_unref()
1318 snd_pcm_stream_group_ref(struct snd_pcm_substream *substream) in snd_pcm_stream_group_ref() argument
1320 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_stream_group_ref()
1325 if (!snd_pcm_stream_linked(substream)) in snd_pcm_stream_group_ref()
1327 group = substream->group; in snd_pcm_stream_group_ref()
1337 snd_pcm_stream_unlock(substream); in snd_pcm_stream_group_ref()
1339 snd_pcm_stream_lock(substream); in snd_pcm_stream_group_ref()
1342 if (substream->group == group) in snd_pcm_stream_group_ref()
1345 snd_pcm_group_unref(group, substream); in snd_pcm_stream_group_ref()
1354 struct snd_pcm_substream *substream, in snd_pcm_action() argument
1360 group = snd_pcm_stream_group_ref(substream); in snd_pcm_action()
1362 res = snd_pcm_action_group(ops, substream, state, true); in snd_pcm_action()
1364 res = snd_pcm_action_single(ops, substream, state); in snd_pcm_action()
1365 snd_pcm_group_unref(group, substream); in snd_pcm_action()
1373 struct snd_pcm_substream *substream, in snd_pcm_action_lock_irq() argument
1378 snd_pcm_stream_lock_irq(substream); in snd_pcm_action_lock_irq()
1379 res = snd_pcm_action(ops, substream, state); in snd_pcm_action_lock_irq()
1380 snd_pcm_stream_unlock_irq(substream); in snd_pcm_action_lock_irq()
1387 struct snd_pcm_substream *substream, in snd_pcm_action_nonatomic() argument
1394 res = snd_pcm_buffer_access_lock(substream->runtime); in snd_pcm_action_nonatomic()
1397 if (snd_pcm_stream_linked(substream)) in snd_pcm_action_nonatomic()
1398 res = snd_pcm_action_group(ops, substream, state, false); in snd_pcm_action_nonatomic()
1400 res = snd_pcm_action_single(ops, substream, state); in snd_pcm_action_nonatomic()
1401 snd_pcm_buffer_access_unlock(substream->runtime); in snd_pcm_action_nonatomic()
1410 static int snd_pcm_pre_start(struct snd_pcm_substream *substream, in snd_pcm_pre_start() argument
1413 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_start()
1416 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_pre_start()
1417 !snd_pcm_playback_data(substream)) in snd_pcm_pre_start()
1420 runtime->trigger_master = substream; in snd_pcm_pre_start()
1424 static int snd_pcm_do_start(struct snd_pcm_substream *substream, in snd_pcm_do_start() argument
1427 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1429 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); in snd_pcm_do_start()
1432 static void snd_pcm_undo_start(struct snd_pcm_substream *substream, in snd_pcm_undo_start() argument
1435 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_start()
1436 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_undo_start()
1439 static void snd_pcm_post_start(struct snd_pcm_substream *substream, in snd_pcm_post_start() argument
1442 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start()
1443 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_start()
1448 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_start()
1450 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_start()
1451 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTART); in snd_pcm_post_start()
1468 int snd_pcm_start(struct snd_pcm_substream *substream) in snd_pcm_start() argument
1470 return snd_pcm_action(&snd_pcm_action_start, substream, in snd_pcm_start()
1475 static int snd_pcm_start_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_start_lock_irq() argument
1477 return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, in snd_pcm_start_lock_irq()
1484 static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, in snd_pcm_pre_stop() argument
1487 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop()
1490 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1494 static int snd_pcm_do_stop(struct snd_pcm_substream *substream, in snd_pcm_do_stop() argument
1497 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1498 snd_pcm_running(substream)) { in snd_pcm_do_stop()
1499 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_do_stop()
1500 substream->runtime->stop_operating = true; in snd_pcm_do_stop()
1505 static void snd_pcm_post_stop(struct snd_pcm_substream *substream, in snd_pcm_post_stop() argument
1508 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop()
1510 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_stop()
1512 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTOP); in snd_pcm_post_stop()
1533 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) in snd_pcm_stop() argument
1535 return snd_pcm_action(&snd_pcm_action_stop, substream, state); in snd_pcm_stop()
1548 int snd_pcm_drain_done(struct snd_pcm_substream *substream) in snd_pcm_drain_done() argument
1550 return snd_pcm_action_single(&snd_pcm_action_stop, substream, in snd_pcm_drain_done()
1563 int snd_pcm_stop_xrun(struct snd_pcm_substream *substream) in snd_pcm_stop_xrun() argument
1567 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_stop_xrun()
1568 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1569 __snd_pcm_xrun(substream); in snd_pcm_stop_xrun()
1570 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_stop_xrun()
1580 static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, in snd_pcm_pre_pause() argument
1583 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause()
1591 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1595 static int snd_pcm_do_pause(struct snd_pcm_substream *substream, in snd_pcm_do_pause() argument
1598 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1603 snd_pcm_update_hw_ptr(substream); in snd_pcm_do_pause()
1608 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1609 return substream->ops->trigger(substream, in snd_pcm_do_pause()
1615 static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, in snd_pcm_undo_pause() argument
1618 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1619 substream->ops->trigger(substream, in snd_pcm_undo_pause()
1625 static void snd_pcm_post_pause(struct snd_pcm_substream *substream, in snd_pcm_post_pause() argument
1628 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause()
1629 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_pause()
1632 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MPAUSE); in snd_pcm_post_pause()
1637 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MCONTINUE); in snd_pcm_post_pause()
1651 static int snd_pcm_pause(struct snd_pcm_substream *substream, bool push) in snd_pcm_pause() argument
1653 return snd_pcm_action(&snd_pcm_action_pause, substream, in snd_pcm_pause()
1657 static int snd_pcm_pause_lock_irq(struct snd_pcm_substream *substream, in snd_pcm_pause_lock_irq() argument
1660 return snd_pcm_action_lock_irq(&snd_pcm_action_pause, substream, in snd_pcm_pause_lock_irq()
1667 static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, in snd_pcm_pre_suspend() argument
1670 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend()
1680 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1684 static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, in snd_pcm_do_suspend() argument
1687 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend()
1688 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1690 if (! snd_pcm_running(substream)) in snd_pcm_do_suspend()
1692 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_do_suspend()
1697 static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, in snd_pcm_post_suspend() argument
1700 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend()
1701 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_suspend()
1705 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSUSPEND); in snd_pcm_post_suspend()
1724 static int snd_pcm_suspend(struct snd_pcm_substream *substream) in snd_pcm_suspend() argument
1729 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_suspend()
1730 err = snd_pcm_action(&snd_pcm_action_suspend, substream, in snd_pcm_suspend()
1732 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_suspend()
1746 struct snd_pcm_substream *substream; in snd_pcm_suspend_all() local
1752 for_each_pcm_substream(pcm, stream, substream) { in snd_pcm_suspend_all()
1754 if (!substream->runtime) in snd_pcm_suspend_all()
1761 if (!substream->ops) in snd_pcm_suspend_all()
1764 err = snd_pcm_suspend(substream); in snd_pcm_suspend_all()
1769 for_each_pcm_substream(pcm, stream, substream) in snd_pcm_suspend_all()
1770 snd_pcm_sync_stop(substream, false); in snd_pcm_suspend_all()
1778 static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, in snd_pcm_pre_resume() argument
1781 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume()
1784 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1788 static int snd_pcm_do_resume(struct snd_pcm_substream *substream, in snd_pcm_do_resume() argument
1791 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume()
1792 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1797 substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) in snd_pcm_do_resume()
1799 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); in snd_pcm_do_resume()
1802 static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, in snd_pcm_undo_resume() argument
1805 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1806 snd_pcm_running(substream)) in snd_pcm_undo_resume()
1807 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_undo_resume()
1810 static void snd_pcm_post_resume(struct snd_pcm_substream *substream, in snd_pcm_post_resume() argument
1813 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume()
1814 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_resume()
1816 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MRESUME); in snd_pcm_post_resume()
1826 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1828 return snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, in snd_pcm_resume()
1834 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1846 static int snd_pcm_xrun(struct snd_pcm_substream *substream) in snd_pcm_xrun() argument
1848 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun()
1851 snd_pcm_stream_lock_irq(substream); in snd_pcm_xrun()
1857 __snd_pcm_xrun(substream); in snd_pcm_xrun()
1863 snd_pcm_stream_unlock_irq(substream); in snd_pcm_xrun()
1871 static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, in snd_pcm_pre_reset() argument
1874 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset()
1886 static int snd_pcm_do_reset(struct snd_pcm_substream *substream, in snd_pcm_do_reset() argument
1889 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset()
1890 int err = snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); in snd_pcm_do_reset()
1893 snd_pcm_stream_lock_irq(substream); in snd_pcm_do_reset()
1899 snd_pcm_stream_unlock_irq(substream); in snd_pcm_do_reset()
1903 static void snd_pcm_post_reset(struct snd_pcm_substream *substream, in snd_pcm_post_reset() argument
1906 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset()
1907 snd_pcm_stream_lock_irq(substream); in snd_pcm_post_reset()
1909 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_reset()
1911 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_reset()
1912 snd_pcm_stream_unlock_irq(substream); in snd_pcm_post_reset()
1921 static int snd_pcm_reset(struct snd_pcm_substream *substream) in snd_pcm_reset() argument
1923 return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, in snd_pcm_reset()
1931 static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, in snd_pcm_pre_prepare() argument
1934 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare()
1940 if (snd_pcm_running(substream)) in snd_pcm_pre_prepare()
1942 substream->f_flags = f_flags; in snd_pcm_pre_prepare()
1946 static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, in snd_pcm_do_prepare() argument
1950 snd_pcm_sync_stop(substream, true); in snd_pcm_do_prepare()
1951 err = substream->ops->prepare(substream); in snd_pcm_do_prepare()
1954 return snd_pcm_do_reset(substream, state); in snd_pcm_do_prepare()
1957 static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, in snd_pcm_post_prepare() argument
1960 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare()
1962 snd_pcm_set_state(substream, SNDRV_PCM_STATE_PREPARED); in snd_pcm_post_prepare()
1978 static int snd_pcm_prepare(struct snd_pcm_substream *substream, in snd_pcm_prepare() argument
1986 f_flags = substream->f_flags; in snd_pcm_prepare()
1988 snd_pcm_stream_lock_irq(substream); in snd_pcm_prepare()
1989 switch (substream->runtime->state) { in snd_pcm_prepare()
1991 snd_pcm_pause(substream, false); in snd_pcm_prepare()
1994 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_prepare()
1997 snd_pcm_stream_unlock_irq(substream); in snd_pcm_prepare()
2000 substream, in snd_pcm_prepare()
2009 static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, in snd_pcm_pre_drain_init() argument
2012 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init()
2019 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
2023 static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, in snd_pcm_do_drain_init() argument
2026 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init()
2027 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_do_drain_init()
2031 if (! snd_pcm_playback_empty(substream)) { in snd_pcm_do_drain_init()
2032 snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2033 snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2054 snd_pcm_do_stop(substream, new_state); in snd_pcm_do_drain_init()
2055 snd_pcm_post_stop(substream, new_state); in snd_pcm_do_drain_init()
2060 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
2062 return substream->ops->trigger(substream, in snd_pcm_do_drain_init()
2068 static void snd_pcm_post_drain_init(struct snd_pcm_substream *substream, in snd_pcm_post_drain_init() argument
2086 static int snd_pcm_drain(struct snd_pcm_substream *substream, in snd_pcm_drain() argument
2097 card = substream->pcm->card; in snd_pcm_drain()
2098 runtime = substream->runtime; in snd_pcm_drain()
2106 } else if (substream->f_flags & O_NONBLOCK) in snd_pcm_drain()
2109 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
2112 snd_pcm_pause(substream, false); in snd_pcm_drain()
2115 result = snd_pcm_action(&snd_pcm_action_drain_init, substream, in snd_pcm_drain()
2134 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
2135 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
2144 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
2150 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
2163 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
2164 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
2165 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
2171 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
2178 if (substream->runtime->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
2181 dev_dbg(substream->pcm->card->dev, in snd_pcm_drain()
2183 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drain()
2191 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
2201 static int snd_pcm_drop(struct snd_pcm_substream *substream) in snd_pcm_drop() argument
2206 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_drop()
2208 runtime = substream->runtime; in snd_pcm_drop()
2214 snd_pcm_stream_lock_irq(substream); in snd_pcm_drop()
2217 snd_pcm_pause(substream, false); in snd_pcm_drop()
2219 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drop()
2221 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drop()
2248 static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) in snd_pcm_link() argument
2254 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_link()
2264 substream1 = pcm_file->substream; in snd_pcm_link()
2266 if (substream == substream1) { in snd_pcm_link()
2279 if (substream->runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
2280 substream->runtime->state != substream1->runtime->state || in snd_pcm_link()
2281 substream->pcm->nonatomic != substream1->pcm->nonatomic) { in snd_pcm_link()
2290 snd_pcm_stream_lock_irq(substream); in snd_pcm_link()
2291 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_link()
2292 snd_pcm_group_assign(substream, group); in snd_pcm_link()
2295 target_group = substream->group; in snd_pcm_link()
2296 snd_pcm_stream_unlock_irq(substream); in snd_pcm_link()
2313 static void relink_to_local(struct snd_pcm_substream *substream) in relink_to_local() argument
2315 snd_pcm_stream_lock_nested(substream); in relink_to_local()
2316 snd_pcm_group_assign(substream, &substream->self_group); in relink_to_local()
2317 snd_pcm_stream_unlock(substream); in relink_to_local()
2320 static int snd_pcm_unlink(struct snd_pcm_substream *substream) in snd_pcm_unlink() argument
2323 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_unlink()
2329 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_unlink()
2334 group = substream->group; in snd_pcm_unlink()
2337 relink_to_local(substream); in snd_pcm_unlink()
2473 struct snd_pcm_substream *substream = rule->private; in snd_pcm_hw_rule_buffer_bytes_max() local
2475 t.max = substream->buffer_bytes_max; in snd_pcm_hw_rule_buffer_bytes_max()
2482 static int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_init() argument
2484 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init()
2606 static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_complete() argument
2608 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete()
2617 if (hw_support_mmap(substream)) { in snd_pcm_hw_constraints_complete()
2664 snd_pcm_hw_rule_buffer_bytes_max, substream, in snd_pcm_hw_constraints_complete()
2690 static void pcm_release_private(struct snd_pcm_substream *substream) in pcm_release_private() argument
2692 if (snd_pcm_stream_linked(substream)) in pcm_release_private()
2693 snd_pcm_unlink(substream); in pcm_release_private()
2696 void snd_pcm_release_substream(struct snd_pcm_substream *substream) in snd_pcm_release_substream() argument
2698 substream->ref_count--; in snd_pcm_release_substream()
2699 if (substream->ref_count > 0) in snd_pcm_release_substream()
2702 snd_pcm_drop(substream); in snd_pcm_release_substream()
2703 if (substream->hw_opened) { in snd_pcm_release_substream()
2704 if (substream->runtime->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2705 do_hw_free(substream); in snd_pcm_release_substream()
2706 substream->ops->close(substream); in snd_pcm_release_substream()
2707 substream->hw_opened = 0; in snd_pcm_release_substream()
2709 if (cpu_latency_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_release_substream()
2710 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_release_substream()
2711 if (substream->pcm_release) { in snd_pcm_release_substream()
2712 substream->pcm_release(substream); in snd_pcm_release_substream()
2713 substream->pcm_release = NULL; in snd_pcm_release_substream()
2715 snd_pcm_detach_substream(substream); in snd_pcm_release_substream()
2723 struct snd_pcm_substream *substream; in snd_pcm_open_substream() local
2726 err = snd_pcm_attach_substream(pcm, stream, file, &substream); in snd_pcm_open_substream()
2729 if (substream->ref_count > 1) { in snd_pcm_open_substream()
2730 *rsubstream = substream; in snd_pcm_open_substream()
2734 err = snd_pcm_hw_constraints_init(substream); in snd_pcm_open_substream()
2740 err = substream->ops->open(substream); in snd_pcm_open_substream()
2744 substream->hw_opened = 1; in snd_pcm_open_substream()
2746 err = snd_pcm_hw_constraints_complete(substream); in snd_pcm_open_substream()
2755 if (substream->managed_buffer_alloc && in snd_pcm_open_substream()
2756 substream->dma_buffer.dev.need_sync) in snd_pcm_open_substream()
2757 substream->runtime->hw.info |= SNDRV_PCM_INFO_EXPLICIT_SYNC; in snd_pcm_open_substream()
2759 *rsubstream = substream; in snd_pcm_open_substream()
2763 snd_pcm_release_substream(substream); in snd_pcm_open_substream()
2773 struct snd_pcm_substream *substream; in snd_pcm_open_file() local
2776 err = snd_pcm_open_substream(pcm, stream, file, &substream); in snd_pcm_open_file()
2782 snd_pcm_release_substream(substream); in snd_pcm_open_file()
2785 pcm_file->substream = substream; in snd_pcm_open_file()
2786 if (substream->ref_count == 1) in snd_pcm_open_file()
2787 substream->pcm_release = pcm_release_private; in snd_pcm_open_file()
2881 struct snd_pcm_substream *substream; in snd_pcm_release() local
2885 substream = pcm_file->substream; in snd_pcm_release()
2886 if (snd_BUG_ON(!substream)) in snd_pcm_release()
2888 pcm = substream->pcm; in snd_pcm_release()
2894 snd_pcm_release_substream(substream); in snd_pcm_release()
2906 static int do_pcm_hwsync(struct snd_pcm_substream *substream) in do_pcm_hwsync() argument
2908 switch (substream->runtime->state) { in do_pcm_hwsync()
2910 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in do_pcm_hwsync()
2914 return snd_pcm_update_hw_ptr(substream); in do_pcm_hwsync()
2928 static snd_pcm_sframes_t forward_appl_ptr(struct snd_pcm_substream *substream, in forward_appl_ptr() argument
2932 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr()
2943 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in forward_appl_ptr()
2948 static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream, in rewind_appl_ptr() argument
2952 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr()
2963 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in rewind_appl_ptr()
2972 static snd_pcm_sframes_t snd_pcm_rewind(struct snd_pcm_substream *substream, in snd_pcm_rewind() argument
2980 snd_pcm_stream_lock_irq(substream); in snd_pcm_rewind()
2981 ret = do_pcm_hwsync(substream); in snd_pcm_rewind()
2983 ret = rewind_appl_ptr(substream, frames, in snd_pcm_rewind()
2984 snd_pcm_hw_avail(substream)); in snd_pcm_rewind()
2985 snd_pcm_stream_unlock_irq(substream); in snd_pcm_rewind()
2987 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_rewind()
2991 static snd_pcm_sframes_t snd_pcm_forward(struct snd_pcm_substream *substream, in snd_pcm_forward() argument
2999 snd_pcm_stream_lock_irq(substream); in snd_pcm_forward()
3000 ret = do_pcm_hwsync(substream); in snd_pcm_forward()
3002 ret = forward_appl_ptr(substream, frames, in snd_pcm_forward()
3003 snd_pcm_avail(substream)); in snd_pcm_forward()
3004 snd_pcm_stream_unlock_irq(substream); in snd_pcm_forward()
3006 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_forward()
3010 static int snd_pcm_delay(struct snd_pcm_substream *substream, in snd_pcm_delay() argument
3015 snd_pcm_stream_lock_irq(substream); in snd_pcm_delay()
3016 err = do_pcm_hwsync(substream); in snd_pcm_delay()
3018 *delay = snd_pcm_calc_delay(substream); in snd_pcm_delay()
3019 snd_pcm_stream_unlock_irq(substream); in snd_pcm_delay()
3020 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_CPU); in snd_pcm_delay()
3025 static inline int snd_pcm_hwsync(struct snd_pcm_substream *substream) in snd_pcm_hwsync() argument
3027 return snd_pcm_delay(substream, NULL); in snd_pcm_hwsync()
3030 static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, in snd_pcm_sync_ptr() argument
3033 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr()
3047 err = snd_pcm_hwsync(substream); in snd_pcm_sync_ptr()
3051 snd_pcm_stream_lock_irq(substream); in snd_pcm_sync_ptr()
3053 err = pcm_lib_apply_appl_ptr(substream, in snd_pcm_sync_ptr()
3056 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
3071 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
3073 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_sync_ptr()
3120 static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, in snd_pcm_ioctl_sync_ptr_compat() argument
3123 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_ioctl_sync_ptr_compat()
3140 err = snd_pcm_hwsync(substream); in snd_pcm_ioctl_sync_ptr_compat()
3149 snd_pcm_stream_lock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3152 err = pcm_lib_apply_appl_ptr(substream, in snd_pcm_ioctl_sync_ptr_compat()
3155 snd_pcm_stream_unlock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3169 snd_pcm_stream_unlock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3171 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_ioctl_sync_ptr_compat()
3187 static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) in snd_pcm_tstamp() argument
3189 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp()
3200 static int snd_pcm_xferi_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xferi_frames_ioctl() argument
3204 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl()
3213 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xferi_frames_ioctl()
3214 result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
3216 result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
3222 static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xfern_frames_ioctl() argument
3226 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl()
3242 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xfern_frames_ioctl()
3243 result = snd_pcm_lib_writev(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
3245 result = snd_pcm_lib_readv(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
3252 static int snd_pcm_rewind_ioctl(struct snd_pcm_substream *substream, in snd_pcm_rewind_ioctl() argument
3262 result = snd_pcm_rewind(substream, frames); in snd_pcm_rewind_ioctl()
3268 static int snd_pcm_forward_ioctl(struct snd_pcm_substream *substream, in snd_pcm_forward_ioctl() argument
3278 result = snd_pcm_forward(substream, frames); in snd_pcm_forward_ioctl()
3285 struct snd_pcm_substream *substream, in snd_pcm_common_ioctl() argument
3291 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_common_ioctl()
3294 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_common_ioctl()
3297 res = snd_power_wait(substream->pcm->card); in snd_pcm_common_ioctl()
3305 return snd_pcm_info_user(substream, arg); in snd_pcm_common_ioctl()
3309 return snd_pcm_tstamp(substream, arg); in snd_pcm_common_ioctl()
3316 return snd_pcm_hw_refine_user(substream, arg); in snd_pcm_common_ioctl()
3318 return snd_pcm_hw_params_user(substream, arg); in snd_pcm_common_ioctl()
3320 return snd_pcm_hw_free(substream); in snd_pcm_common_ioctl()
3322 return snd_pcm_sw_params_user(substream, arg); in snd_pcm_common_ioctl()
3324 return snd_pcm_status_user32(substream, arg, false); in snd_pcm_common_ioctl()
3326 return snd_pcm_status_user32(substream, arg, true); in snd_pcm_common_ioctl()
3328 return snd_pcm_status_user64(substream, arg, false); in snd_pcm_common_ioctl()
3330 return snd_pcm_status_user64(substream, arg, true); in snd_pcm_common_ioctl()
3332 return snd_pcm_channel_info_user(substream, arg); in snd_pcm_common_ioctl()
3334 return snd_pcm_prepare(substream, file); in snd_pcm_common_ioctl()
3336 return snd_pcm_reset(substream); in snd_pcm_common_ioctl()
3338 return snd_pcm_start_lock_irq(substream); in snd_pcm_common_ioctl()
3340 return snd_pcm_link(substream, (int)(unsigned long) arg); in snd_pcm_common_ioctl()
3342 return snd_pcm_unlink(substream); in snd_pcm_common_ioctl()
3344 return snd_pcm_resume(substream); in snd_pcm_common_ioctl()
3346 return snd_pcm_xrun(substream); in snd_pcm_common_ioctl()
3348 return snd_pcm_hwsync(substream); in snd_pcm_common_ioctl()
3355 err = snd_pcm_delay(substream, &delay); in snd_pcm_common_ioctl()
3363 return snd_pcm_ioctl_sync_ptr_compat(substream, arg); in snd_pcm_common_ioctl()
3365 return snd_pcm_sync_ptr(substream, arg); in snd_pcm_common_ioctl()
3368 return snd_pcm_hw_refine_old_user(substream, arg); in snd_pcm_common_ioctl()
3370 return snd_pcm_hw_params_old_user(substream, arg); in snd_pcm_common_ioctl()
3373 return snd_pcm_drain(substream, file); in snd_pcm_common_ioctl()
3375 return snd_pcm_drop(substream); in snd_pcm_common_ioctl()
3377 return snd_pcm_pause_lock_irq(substream, (unsigned long)arg); in snd_pcm_common_ioctl()
3380 return snd_pcm_xferi_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
3383 return snd_pcm_xfern_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
3385 return snd_pcm_rewind_ioctl(substream, arg); in snd_pcm_common_ioctl()
3387 return snd_pcm_forward_ioctl(substream, arg); in snd_pcm_common_ioctl()
3389 pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd); in snd_pcm_common_ioctl()
3403 return snd_pcm_common_ioctl(file, pcm_file->substream, cmd, in snd_pcm_ioctl()
3419 int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, in snd_pcm_kernel_ioctl() argument
3425 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_kernel_ioctl()
3432 if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) in snd_pcm_kernel_ioctl()
3434 result = snd_pcm_forward(substream, *frames); in snd_pcm_kernel_ioctl()
3438 return snd_pcm_hw_params(substream, arg); in snd_pcm_kernel_ioctl()
3440 return snd_pcm_sw_params(substream, arg); in snd_pcm_kernel_ioctl()
3442 return snd_pcm_prepare(substream, NULL); in snd_pcm_kernel_ioctl()
3444 return snd_pcm_start_lock_irq(substream); in snd_pcm_kernel_ioctl()
3446 return snd_pcm_drain(substream, NULL); in snd_pcm_kernel_ioctl()
3448 return snd_pcm_drop(substream); in snd_pcm_kernel_ioctl()
3450 return snd_pcm_delay(substream, frames); in snd_pcm_kernel_ioctl()
3461 struct snd_pcm_substream *substream; in snd_pcm_read() local
3466 substream = pcm_file->substream; in snd_pcm_read()
3467 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_read()
3469 runtime = substream->runtime; in snd_pcm_read()
3476 result = snd_pcm_lib_read(substream, buf, count); in snd_pcm_read()
3486 struct snd_pcm_substream *substream; in snd_pcm_write() local
3491 substream = pcm_file->substream; in snd_pcm_write()
3492 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_write()
3494 runtime = substream->runtime; in snd_pcm_write()
3501 result = snd_pcm_lib_write(substream, buf, count); in snd_pcm_write()
3510 struct snd_pcm_substream *substream; in snd_pcm_readv() local
3518 substream = pcm_file->substream; in snd_pcm_readv()
3519 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_readv()
3521 runtime = substream->runtime; in snd_pcm_readv()
3537 result = snd_pcm_lib_readv(substream, bufs, frames); in snd_pcm_readv()
3547 struct snd_pcm_substream *substream; in snd_pcm_writev() local
3555 substream = pcm_file->substream; in snd_pcm_writev()
3556 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_writev()
3558 runtime = substream->runtime; in snd_pcm_writev()
3573 result = snd_pcm_lib_writev(substream, bufs, frames); in snd_pcm_writev()
3583 struct snd_pcm_substream *substream; in snd_pcm_poll() local
3590 substream = pcm_file->substream; in snd_pcm_poll()
3591 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_poll()
3595 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_poll()
3598 runtime = substream->runtime; in snd_pcm_poll()
3605 snd_pcm_stream_lock_irq(substream); in snd_pcm_poll()
3606 avail = snd_pcm_avail(substream); in snd_pcm_poll()
3615 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in snd_pcm_poll()
3625 snd_pcm_stream_unlock_irq(substream); in snd_pcm_poll()
3643 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_status_fault() local
3646 if (substream == NULL) in snd_pcm_mmap_status_fault()
3648 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3659 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3669 area->vm_private_data = substream; in snd_pcm_mmap_status()
3680 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_control_fault() local
3683 if (substream == NULL) in snd_pcm_mmap_control_fault()
3685 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3696 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3706 area->vm_private_data = substream; in snd_pcm_mmap_control()
3717 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_status_mmap_allowed()
3724 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3734 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_control_mmap_allowed()
3740 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3752 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3757 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3769 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_data_fault() local
3775 if (substream == NULL) in snd_pcm_mmap_data_fault()
3777 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3782 if (substream->ops->page) in snd_pcm_mmap_data_fault()
3783 page = substream->ops->page(substream, offset); in snd_pcm_mmap_data_fault()
3784 else if (!snd_pcm_get_dma_buf(substream)) in snd_pcm_mmap_data_fault()
3787 page = snd_sgbuf_get_page(snd_pcm_get_dma_buf(substream), offset); in snd_pcm_mmap_data_fault()
3820 int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, in snd_pcm_lib_default_mmap() argument
3824 if (!substream->ops->page && in snd_pcm_lib_default_mmap()
3825 !snd_dma_buffer_mmap(snd_pcm_get_dma_buf(substream), area)) in snd_pcm_lib_default_mmap()
3848 int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, in snd_pcm_lib_mmap_iomem() argument
3851 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_mmap_iomem()
3862 int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_data() argument
3871 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_mmap_data()
3878 runtime = substream->runtime; in snd_pcm_mmap_data()
3895 area->vm_private_data = substream; in snd_pcm_mmap_data()
3896 if (substream->ops->mmap) in snd_pcm_mmap_data()
3897 err = substream->ops->mmap(substream, area); in snd_pcm_mmap_data()
3899 err = snd_pcm_lib_default_mmap(substream, area); in snd_pcm_mmap_data()
3901 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data()
3909 struct snd_pcm_substream *substream; in snd_pcm_mmap() local
3913 substream = pcm_file->substream; in snd_pcm_mmap()
3914 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_mmap()
3916 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_mmap()
3928 return snd_pcm_mmap_status(substream, file, area); in snd_pcm_mmap()
3936 return snd_pcm_mmap_control(substream, file, area); in snd_pcm_mmap()
3938 return snd_pcm_mmap_data(substream, file, area); in snd_pcm_mmap()
3946 struct snd_pcm_substream *substream; in snd_pcm_fasync() local
3950 substream = pcm_file->substream; in snd_pcm_fasync()
3951 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_fasync()
3953 runtime = substream->runtime; in snd_pcm_fasync()
4014 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_old_user() argument
4031 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_old_user()
4035 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_old_user()
4049 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_old_user() argument
4067 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_old_user()
4090 struct snd_pcm_substream *substream = pcm_file->substream; in snd_pcm_get_unmapped_area() local
4091 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area()