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) { 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
1429 if (substream->runtime->trigger_master != substream) in snd_pcm_do_start()
1431 err = substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); in snd_pcm_do_start()
1434 __snd_pcm_set_state(substream->runtime, SNDRV_PCM_STATE_XRUN); in snd_pcm_do_start()
1438 static void snd_pcm_undo_start(struct snd_pcm_substream *substream, in snd_pcm_undo_start() argument
1441 if (substream->runtime->trigger_master == substream) { in snd_pcm_undo_start()
1442 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_undo_start()
1443 substream->runtime->stop_operating = true; in snd_pcm_undo_start()
1447 static void snd_pcm_post_start(struct snd_pcm_substream *substream, in snd_pcm_post_start() argument
1450 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start()
1451 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_start()
1456 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_start()
1458 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_start()
1459 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTART); in snd_pcm_post_start()
1476 int snd_pcm_start(struct snd_pcm_substream *substream) in snd_pcm_start() argument
1478 return snd_pcm_action(&snd_pcm_action_start, substream, in snd_pcm_start()
1483 static int snd_pcm_start_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_start_lock_irq() argument
1485 return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, in snd_pcm_start_lock_irq()
1492 static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, in snd_pcm_pre_stop() argument
1495 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop()
1498 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1502 static int snd_pcm_do_stop(struct snd_pcm_substream *substream, in snd_pcm_do_stop() argument
1505 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1506 snd_pcm_running(substream)) { in snd_pcm_do_stop()
1507 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_do_stop()
1508 substream->runtime->stop_operating = true; in snd_pcm_do_stop()
1513 static void snd_pcm_post_stop(struct snd_pcm_substream *substream, in snd_pcm_post_stop() argument
1516 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop()
1518 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_stop()
1520 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTOP); in snd_pcm_post_stop()
1541 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) in snd_pcm_stop() argument
1543 return snd_pcm_action(&snd_pcm_action_stop, substream, state); in snd_pcm_stop()
1556 int snd_pcm_drain_done(struct snd_pcm_substream *substream) in snd_pcm_drain_done() argument
1558 return snd_pcm_action_single(&snd_pcm_action_stop, substream, in snd_pcm_drain_done()
1571 int snd_pcm_stop_xrun(struct snd_pcm_substream *substream) in snd_pcm_stop_xrun() argument
1575 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_stop_xrun()
1576 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1577 __snd_pcm_xrun(substream); in snd_pcm_stop_xrun()
1578 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_stop_xrun()
1588 static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, in snd_pcm_pre_pause() argument
1591 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause()
1599 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1603 static int snd_pcm_do_pause(struct snd_pcm_substream *substream, in snd_pcm_do_pause() argument
1606 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1612 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1613 return substream->ops->trigger(substream, in snd_pcm_do_pause()
1619 static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, in snd_pcm_undo_pause() argument
1622 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1623 substream->ops->trigger(substream, in snd_pcm_undo_pause()
1629 static void snd_pcm_post_pause(struct snd_pcm_substream *substream, in snd_pcm_post_pause() argument
1632 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause()
1633 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_pause()
1636 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MPAUSE); in snd_pcm_post_pause()
1641 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MCONTINUE); in snd_pcm_post_pause()
1655 static int snd_pcm_pause(struct snd_pcm_substream *substream, bool push) in snd_pcm_pause() argument
1657 return snd_pcm_action(&snd_pcm_action_pause, substream, in snd_pcm_pause()
1661 static int snd_pcm_pause_lock_irq(struct snd_pcm_substream *substream, in snd_pcm_pause_lock_irq() argument
1664 return snd_pcm_action_lock_irq(&snd_pcm_action_pause, substream, in snd_pcm_pause_lock_irq()
1671 static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, in snd_pcm_pre_suspend() argument
1674 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend()
1684 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1688 static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, in snd_pcm_do_suspend() argument
1691 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend()
1692 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1694 if (! snd_pcm_running(substream)) in snd_pcm_do_suspend()
1696 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_do_suspend()
1701 static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, in snd_pcm_post_suspend() argument
1704 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend()
1705 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_suspend()
1709 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSUSPEND); in snd_pcm_post_suspend()
1728 static int snd_pcm_suspend(struct snd_pcm_substream *substream) in snd_pcm_suspend() argument
1733 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_suspend()
1734 err = snd_pcm_action(&snd_pcm_action_suspend, substream, in snd_pcm_suspend()
1736 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_suspend()
1750 struct snd_pcm_substream *substream; in snd_pcm_suspend_all() local
1756 for_each_pcm_substream(pcm, stream, substream) { in snd_pcm_suspend_all()
1758 if (!substream->runtime) in snd_pcm_suspend_all()
1765 if (!substream->ops) in snd_pcm_suspend_all()
1768 err = snd_pcm_suspend(substream); in snd_pcm_suspend_all()
1773 for_each_pcm_substream(pcm, stream, substream) in snd_pcm_suspend_all()
1774 snd_pcm_sync_stop(substream, false); in snd_pcm_suspend_all()
1782 static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, in snd_pcm_pre_resume() argument
1785 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume()
1788 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1792 static int snd_pcm_do_resume(struct snd_pcm_substream *substream, in snd_pcm_do_resume() argument
1795 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume()
1796 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1801 substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) in snd_pcm_do_resume()
1803 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); in snd_pcm_do_resume()
1806 static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, in snd_pcm_undo_resume() argument
1809 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1810 snd_pcm_running(substream)) in snd_pcm_undo_resume()
1811 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_undo_resume()
1814 static void snd_pcm_post_resume(struct snd_pcm_substream *substream, in snd_pcm_post_resume() argument
1817 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume()
1818 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_resume()
1820 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MRESUME); in snd_pcm_post_resume()
1830 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1832 return snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, in snd_pcm_resume()
1838 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1850 static int snd_pcm_xrun(struct snd_pcm_substream *substream) in snd_pcm_xrun() argument
1852 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun()
1855 snd_pcm_stream_lock_irq(substream); in snd_pcm_xrun()
1861 __snd_pcm_xrun(substream); in snd_pcm_xrun()
1867 snd_pcm_stream_unlock_irq(substream); in snd_pcm_xrun()
1875 static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, in snd_pcm_pre_reset() argument
1878 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset()
1890 static int snd_pcm_do_reset(struct snd_pcm_substream *substream, in snd_pcm_do_reset() argument
1893 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset()
1894 int err = snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); in snd_pcm_do_reset()
1897 snd_pcm_stream_lock_irq(substream); in snd_pcm_do_reset()
1903 snd_pcm_stream_unlock_irq(substream); in snd_pcm_do_reset()
1907 static void snd_pcm_post_reset(struct snd_pcm_substream *substream, in snd_pcm_post_reset() argument
1910 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset()
1911 snd_pcm_stream_lock_irq(substream); in snd_pcm_post_reset()
1913 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_reset()
1915 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_reset()
1916 snd_pcm_stream_unlock_irq(substream); in snd_pcm_post_reset()
1925 static int snd_pcm_reset(struct snd_pcm_substream *substream) in snd_pcm_reset() argument
1927 return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, in snd_pcm_reset()
1935 static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, in snd_pcm_pre_prepare() argument
1938 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare()
1944 if (snd_pcm_running(substream)) in snd_pcm_pre_prepare()
1946 substream->f_flags = f_flags; in snd_pcm_pre_prepare()
1950 static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, in snd_pcm_do_prepare() argument
1954 snd_pcm_sync_stop(substream, true); in snd_pcm_do_prepare()
1955 err = substream->ops->prepare(substream); in snd_pcm_do_prepare()
1958 return snd_pcm_do_reset(substream, state); in snd_pcm_do_prepare()
1961 static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, in snd_pcm_post_prepare() argument
1964 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare()
1966 snd_pcm_set_state(substream, SNDRV_PCM_STATE_PREPARED); in snd_pcm_post_prepare()
1982 static int snd_pcm_prepare(struct snd_pcm_substream *substream, in snd_pcm_prepare() argument
1990 f_flags = substream->f_flags; in snd_pcm_prepare()
1992 snd_pcm_stream_lock_irq(substream); in snd_pcm_prepare()
1993 switch (substream->runtime->state) { in snd_pcm_prepare()
1995 snd_pcm_pause(substream, false); in snd_pcm_prepare()
1998 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_prepare()
2001 snd_pcm_stream_unlock_irq(substream); in snd_pcm_prepare()
2004 substream, in snd_pcm_prepare()
2013 static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, in snd_pcm_pre_drain_init() argument
2016 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init()
2023 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
2027 static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, in snd_pcm_do_drain_init() argument
2030 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init()
2031 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_do_drain_init()
2035 if (! snd_pcm_playback_empty(substream)) { in snd_pcm_do_drain_init()
2036 snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2037 snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2058 snd_pcm_do_stop(substream, new_state); in snd_pcm_do_drain_init()
2059 snd_pcm_post_stop(substream, new_state); in snd_pcm_do_drain_init()
2064 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
2066 return substream->ops->trigger(substream, in snd_pcm_do_drain_init()
2072 static void snd_pcm_post_drain_init(struct snd_pcm_substream *substream, in snd_pcm_post_drain_init() argument
2090 static int snd_pcm_drain(struct snd_pcm_substream *substream, in snd_pcm_drain() argument
2101 card = substream->pcm->card; in snd_pcm_drain()
2102 runtime = substream->runtime; in snd_pcm_drain()
2110 } else if (substream->f_flags & O_NONBLOCK) in snd_pcm_drain()
2113 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
2116 snd_pcm_pause(substream, false); in snd_pcm_drain()
2119 result = snd_pcm_action(&snd_pcm_action_drain_init, substream, in snd_pcm_drain()
2138 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
2139 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
2148 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
2154 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
2167 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
2168 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
2169 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
2175 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
2182 if (substream->runtime->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
2185 dev_dbg(substream->pcm->card->dev, in snd_pcm_drain()
2187 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drain()
2195 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
2205 static int snd_pcm_drop(struct snd_pcm_substream *substream) in snd_pcm_drop() argument
2210 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_drop()
2212 runtime = substream->runtime; in snd_pcm_drop()
2218 snd_pcm_stream_lock_irq(substream); in snd_pcm_drop()
2221 snd_pcm_pause(substream, false); in snd_pcm_drop()
2223 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drop()
2225 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drop()
2252 static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) in snd_pcm_link() argument
2258 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_link()
2268 substream1 = pcm_file->substream; in snd_pcm_link()
2270 if (substream == substream1) { in snd_pcm_link()
2283 if (substream->runtime->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
2284 substream->runtime->state != substream1->runtime->state || in snd_pcm_link()
2285 substream->pcm->nonatomic != substream1->pcm->nonatomic) { in snd_pcm_link()
2294 snd_pcm_stream_lock_irq(substream); in snd_pcm_link()
2295 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_link()
2296 snd_pcm_group_assign(substream, group); in snd_pcm_link()
2299 target_group = substream->group; in snd_pcm_link()
2300 snd_pcm_stream_unlock_irq(substream); in snd_pcm_link()
2317 static void relink_to_local(struct snd_pcm_substream *substream) in relink_to_local() argument
2319 snd_pcm_stream_lock_nested(substream); in relink_to_local()
2320 snd_pcm_group_assign(substream, &substream->self_group); in relink_to_local()
2321 snd_pcm_stream_unlock(substream); in relink_to_local()
2324 static int snd_pcm_unlink(struct snd_pcm_substream *substream) in snd_pcm_unlink() argument
2327 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_unlink()
2333 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_unlink()
2338 group = substream->group; in snd_pcm_unlink()
2341 relink_to_local(substream); in snd_pcm_unlink()
2477 struct snd_pcm_substream *substream = rule->private; in snd_pcm_hw_rule_buffer_bytes_max() local
2479 t.max = substream->buffer_bytes_max; in snd_pcm_hw_rule_buffer_bytes_max()
2486 static int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_init() argument
2488 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init()
2610 static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_complete() argument
2612 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete()
2621 if (hw_support_mmap(substream)) { in snd_pcm_hw_constraints_complete()
2668 snd_pcm_hw_rule_buffer_bytes_max, substream, in snd_pcm_hw_constraints_complete()
2694 static void pcm_release_private(struct snd_pcm_substream *substream) in pcm_release_private() argument
2696 if (snd_pcm_stream_linked(substream)) in pcm_release_private()
2697 snd_pcm_unlink(substream); in pcm_release_private()
2700 void snd_pcm_release_substream(struct snd_pcm_substream *substream) in snd_pcm_release_substream() argument
2702 substream->ref_count--; in snd_pcm_release_substream()
2703 if (substream->ref_count > 0) in snd_pcm_release_substream()
2706 snd_pcm_drop(substream); in snd_pcm_release_substream()
2707 if (substream->hw_opened) { in snd_pcm_release_substream()
2708 if (substream->runtime->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2709 do_hw_free(substream); in snd_pcm_release_substream()
2710 substream->ops->close(substream); in snd_pcm_release_substream()
2711 substream->hw_opened = 0; in snd_pcm_release_substream()
2713 if (cpu_latency_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_release_substream()
2714 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_release_substream()
2715 if (substream->pcm_release) { in snd_pcm_release_substream()
2716 substream->pcm_release(substream); in snd_pcm_release_substream()
2717 substream->pcm_release = NULL; in snd_pcm_release_substream()
2719 snd_pcm_detach_substream(substream); in snd_pcm_release_substream()
2727 struct snd_pcm_substream *substream; in snd_pcm_open_substream() local
2730 err = snd_pcm_attach_substream(pcm, stream, file, &substream); in snd_pcm_open_substream()
2733 if (substream->ref_count > 1) { in snd_pcm_open_substream()
2734 *rsubstream = substream; in snd_pcm_open_substream()
2738 err = snd_pcm_hw_constraints_init(substream); in snd_pcm_open_substream()
2744 err = substream->ops->open(substream); in snd_pcm_open_substream()
2748 substream->hw_opened = 1; in snd_pcm_open_substream()
2750 err = snd_pcm_hw_constraints_complete(substream); in snd_pcm_open_substream()
2759 if (substream->managed_buffer_alloc && in snd_pcm_open_substream()
2760 substream->dma_buffer.dev.need_sync) in snd_pcm_open_substream()
2761 substream->runtime->hw.info |= SNDRV_PCM_INFO_EXPLICIT_SYNC; in snd_pcm_open_substream()
2763 *rsubstream = substream; in snd_pcm_open_substream()
2767 snd_pcm_release_substream(substream); in snd_pcm_open_substream()
2777 struct snd_pcm_substream *substream; in snd_pcm_open_file() local
2780 err = snd_pcm_open_substream(pcm, stream, file, &substream); in snd_pcm_open_file()
2786 snd_pcm_release_substream(substream); in snd_pcm_open_file()
2789 pcm_file->substream = substream; in snd_pcm_open_file()
2790 if (substream->ref_count == 1) in snd_pcm_open_file()
2791 substream->pcm_release = pcm_release_private; in snd_pcm_open_file()
2885 struct snd_pcm_substream *substream; in snd_pcm_release() local
2889 substream = pcm_file->substream; in snd_pcm_release()
2890 if (snd_BUG_ON(!substream)) in snd_pcm_release()
2892 pcm = substream->pcm; in snd_pcm_release()
2898 snd_pcm_release_substream(substream); in snd_pcm_release()
2910 static int do_pcm_hwsync(struct snd_pcm_substream *substream) in do_pcm_hwsync() argument
2912 switch (substream->runtime->state) { in do_pcm_hwsync()
2914 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in do_pcm_hwsync()
2918 return snd_pcm_update_hw_ptr(substream); in do_pcm_hwsync()
2932 static snd_pcm_sframes_t forward_appl_ptr(struct snd_pcm_substream *substream, in forward_appl_ptr() argument
2936 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr()
2947 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in forward_appl_ptr()
2952 static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream, in rewind_appl_ptr() argument
2956 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr()
2967 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in rewind_appl_ptr()
2976 static snd_pcm_sframes_t snd_pcm_rewind(struct snd_pcm_substream *substream, in snd_pcm_rewind() argument
2984 snd_pcm_stream_lock_irq(substream); in snd_pcm_rewind()
2985 ret = do_pcm_hwsync(substream); in snd_pcm_rewind()
2987 ret = rewind_appl_ptr(substream, frames, in snd_pcm_rewind()
2988 snd_pcm_hw_avail(substream)); in snd_pcm_rewind()
2989 snd_pcm_stream_unlock_irq(substream); in snd_pcm_rewind()
2991 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_rewind()
2995 static snd_pcm_sframes_t snd_pcm_forward(struct snd_pcm_substream *substream, in snd_pcm_forward() argument
3003 snd_pcm_stream_lock_irq(substream); in snd_pcm_forward()
3004 ret = do_pcm_hwsync(substream); in snd_pcm_forward()
3006 ret = forward_appl_ptr(substream, frames, in snd_pcm_forward()
3007 snd_pcm_avail(substream)); in snd_pcm_forward()
3008 snd_pcm_stream_unlock_irq(substream); in snd_pcm_forward()
3010 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_forward()
3014 static int snd_pcm_delay(struct snd_pcm_substream *substream, in snd_pcm_delay() argument
3019 snd_pcm_stream_lock_irq(substream); in snd_pcm_delay()
3020 err = do_pcm_hwsync(substream); in snd_pcm_delay()
3022 *delay = snd_pcm_calc_delay(substream); in snd_pcm_delay()
3023 snd_pcm_stream_unlock_irq(substream); in snd_pcm_delay()
3024 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_CPU); in snd_pcm_delay()
3029 static inline int snd_pcm_hwsync(struct snd_pcm_substream *substream) in snd_pcm_hwsync() argument
3031 return snd_pcm_delay(substream, NULL); in snd_pcm_hwsync()
3034 static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, in snd_pcm_sync_ptr() argument
3037 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr()
3051 err = snd_pcm_hwsync(substream); in snd_pcm_sync_ptr()
3055 snd_pcm_stream_lock_irq(substream); in snd_pcm_sync_ptr()
3057 err = pcm_lib_apply_appl_ptr(substream, in snd_pcm_sync_ptr()
3060 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
3075 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
3077 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_sync_ptr()
3124 static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, in snd_pcm_ioctl_sync_ptr_compat() argument
3127 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_ioctl_sync_ptr_compat()
3144 err = snd_pcm_hwsync(substream); in snd_pcm_ioctl_sync_ptr_compat()
3153 snd_pcm_stream_lock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3156 err = pcm_lib_apply_appl_ptr(substream, in snd_pcm_ioctl_sync_ptr_compat()
3159 snd_pcm_stream_unlock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3173 snd_pcm_stream_unlock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3175 snd_pcm_dma_buffer_sync(substream, SNDRV_DMA_SYNC_DEVICE); in snd_pcm_ioctl_sync_ptr_compat()
3191 static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) in snd_pcm_tstamp() argument
3193 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp()
3204 static int snd_pcm_xferi_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xferi_frames_ioctl() argument
3208 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl()
3217 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xferi_frames_ioctl()
3218 result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
3220 result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
3226 static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xfern_frames_ioctl() argument
3230 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl()
3246 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xfern_frames_ioctl()
3247 result = snd_pcm_lib_writev(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
3249 result = snd_pcm_lib_readv(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
3256 static int snd_pcm_rewind_ioctl(struct snd_pcm_substream *substream, in snd_pcm_rewind_ioctl() argument
3266 result = snd_pcm_rewind(substream, frames); in snd_pcm_rewind_ioctl()
3272 static int snd_pcm_forward_ioctl(struct snd_pcm_substream *substream, in snd_pcm_forward_ioctl() argument
3282 result = snd_pcm_forward(substream, frames); in snd_pcm_forward_ioctl()
3289 struct snd_pcm_substream *substream, in snd_pcm_common_ioctl() argument
3295 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_common_ioctl()
3298 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_common_ioctl()
3301 res = snd_power_wait(substream->pcm->card); in snd_pcm_common_ioctl()
3309 return snd_pcm_info_user(substream, arg); in snd_pcm_common_ioctl()
3313 return snd_pcm_tstamp(substream, arg); in snd_pcm_common_ioctl()
3320 return snd_pcm_hw_refine_user(substream, arg); in snd_pcm_common_ioctl()
3322 return snd_pcm_hw_params_user(substream, arg); in snd_pcm_common_ioctl()
3324 return snd_pcm_hw_free(substream); in snd_pcm_common_ioctl()
3326 return snd_pcm_sw_params_user(substream, arg); in snd_pcm_common_ioctl()
3328 return snd_pcm_status_user32(substream, arg, false); in snd_pcm_common_ioctl()
3330 return snd_pcm_status_user32(substream, arg, true); in snd_pcm_common_ioctl()
3332 return snd_pcm_status_user64(substream, arg, false); in snd_pcm_common_ioctl()
3334 return snd_pcm_status_user64(substream, arg, true); in snd_pcm_common_ioctl()
3336 return snd_pcm_channel_info_user(substream, arg); in snd_pcm_common_ioctl()
3338 return snd_pcm_prepare(substream, file); in snd_pcm_common_ioctl()
3340 return snd_pcm_reset(substream); in snd_pcm_common_ioctl()
3342 return snd_pcm_start_lock_irq(substream); in snd_pcm_common_ioctl()
3344 return snd_pcm_link(substream, (int)(unsigned long) arg); in snd_pcm_common_ioctl()
3346 return snd_pcm_unlink(substream); in snd_pcm_common_ioctl()
3348 return snd_pcm_resume(substream); in snd_pcm_common_ioctl()
3350 return snd_pcm_xrun(substream); in snd_pcm_common_ioctl()
3352 return snd_pcm_hwsync(substream); in snd_pcm_common_ioctl()
3359 err = snd_pcm_delay(substream, &delay); in snd_pcm_common_ioctl()
3367 return snd_pcm_ioctl_sync_ptr_compat(substream, arg); in snd_pcm_common_ioctl()
3369 return snd_pcm_sync_ptr(substream, arg); in snd_pcm_common_ioctl()
3372 return snd_pcm_hw_refine_old_user(substream, arg); in snd_pcm_common_ioctl()
3374 return snd_pcm_hw_params_old_user(substream, arg); in snd_pcm_common_ioctl()
3377 return snd_pcm_drain(substream, file); in snd_pcm_common_ioctl()
3379 return snd_pcm_drop(substream); in snd_pcm_common_ioctl()
3381 return snd_pcm_pause_lock_irq(substream, (unsigned long)arg); in snd_pcm_common_ioctl()
3384 return snd_pcm_xferi_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
3387 return snd_pcm_xfern_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
3389 return snd_pcm_rewind_ioctl(substream, arg); in snd_pcm_common_ioctl()
3391 return snd_pcm_forward_ioctl(substream, arg); in snd_pcm_common_ioctl()
3393 pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd); in snd_pcm_common_ioctl()
3407 return snd_pcm_common_ioctl(file, pcm_file->substream, cmd, in snd_pcm_ioctl()
3423 int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, in snd_pcm_kernel_ioctl() argument
3429 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_kernel_ioctl()
3436 if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) in snd_pcm_kernel_ioctl()
3438 result = snd_pcm_forward(substream, *frames); in snd_pcm_kernel_ioctl()
3442 return snd_pcm_hw_params(substream, arg); in snd_pcm_kernel_ioctl()
3444 return snd_pcm_sw_params(substream, arg); in snd_pcm_kernel_ioctl()
3446 return snd_pcm_prepare(substream, NULL); in snd_pcm_kernel_ioctl()
3448 return snd_pcm_start_lock_irq(substream); in snd_pcm_kernel_ioctl()
3450 return snd_pcm_drain(substream, NULL); in snd_pcm_kernel_ioctl()
3452 return snd_pcm_drop(substream); in snd_pcm_kernel_ioctl()
3454 return snd_pcm_delay(substream, frames); in snd_pcm_kernel_ioctl()
3465 struct snd_pcm_substream *substream; in snd_pcm_read() local
3470 substream = pcm_file->substream; in snd_pcm_read()
3471 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_read()
3473 runtime = substream->runtime; in snd_pcm_read()
3480 result = snd_pcm_lib_read(substream, buf, count); in snd_pcm_read()
3490 struct snd_pcm_substream *substream; in snd_pcm_write() local
3495 substream = pcm_file->substream; in snd_pcm_write()
3496 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_write()
3498 runtime = substream->runtime; in snd_pcm_write()
3505 result = snd_pcm_lib_write(substream, buf, count); in snd_pcm_write()
3514 struct snd_pcm_substream *substream; in snd_pcm_readv() local
3523 substream = pcm_file->substream; in snd_pcm_readv()
3524 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_readv()
3526 runtime = substream->runtime; in snd_pcm_readv()
3544 result = snd_pcm_lib_readv(substream, bufs, frames); in snd_pcm_readv()
3554 struct snd_pcm_substream *substream; in snd_pcm_writev() local
3563 substream = pcm_file->substream; in snd_pcm_writev()
3564 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_writev()
3566 runtime = substream->runtime; in snd_pcm_writev()
3583 result = snd_pcm_lib_writev(substream, bufs, frames); in snd_pcm_writev()
3593 struct snd_pcm_substream *substream; in snd_pcm_poll() local
3600 substream = pcm_file->substream; in snd_pcm_poll()
3601 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_poll()
3605 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_poll()
3608 runtime = substream->runtime; in snd_pcm_poll()
3615 snd_pcm_stream_lock_irq(substream); in snd_pcm_poll()
3616 avail = snd_pcm_avail(substream); in snd_pcm_poll()
3625 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in snd_pcm_poll()
3635 snd_pcm_stream_unlock_irq(substream); in snd_pcm_poll()
3653 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_status_fault() local
3656 if (substream == NULL) in snd_pcm_mmap_status_fault()
3658 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3669 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3679 area->vm_private_data = substream; in snd_pcm_mmap_status()
3691 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_control_fault() local
3694 if (substream == NULL) in snd_pcm_mmap_control_fault()
3696 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3707 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3717 area->vm_private_data = substream; in snd_pcm_mmap_control()
3728 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_status_mmap_allowed()
3735 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3745 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_control_mmap_allowed()
3751 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3763 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3768 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3780 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_data_fault() local
3786 if (substream == NULL) in snd_pcm_mmap_data_fault()
3788 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3793 if (substream->ops->page) in snd_pcm_mmap_data_fault()
3794 page = substream->ops->page(substream, offset); in snd_pcm_mmap_data_fault()
3795 else if (!snd_pcm_get_dma_buf(substream)) in snd_pcm_mmap_data_fault()
3798 page = snd_sgbuf_get_page(snd_pcm_get_dma_buf(substream), offset); in snd_pcm_mmap_data_fault()
3831 int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, in snd_pcm_lib_default_mmap() argument
3835 if (!substream->ops->page && in snd_pcm_lib_default_mmap()
3836 !snd_dma_buffer_mmap(snd_pcm_get_dma_buf(substream), area)) in snd_pcm_lib_default_mmap()
3859 int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, in snd_pcm_lib_mmap_iomem() argument
3862 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_mmap_iomem()
3873 int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_data() argument
3882 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_mmap_data()
3889 runtime = substream->runtime; in snd_pcm_mmap_data()
3906 area->vm_private_data = substream; in snd_pcm_mmap_data()
3907 if (substream->ops->mmap) in snd_pcm_mmap_data()
3908 err = substream->ops->mmap(substream, area); in snd_pcm_mmap_data()
3910 err = snd_pcm_lib_default_mmap(substream, area); in snd_pcm_mmap_data()
3912 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data()
3920 struct snd_pcm_substream *substream; in snd_pcm_mmap() local
3924 substream = pcm_file->substream; in snd_pcm_mmap()
3925 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_mmap()
3927 if (substream->runtime->state == SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_mmap()
3939 return snd_pcm_mmap_status(substream, file, area); in snd_pcm_mmap()
3947 return snd_pcm_mmap_control(substream, file, area); in snd_pcm_mmap()
3949 return snd_pcm_mmap_data(substream, file, area); in snd_pcm_mmap()
3957 struct snd_pcm_substream *substream; in snd_pcm_fasync() local
3961 substream = pcm_file->substream; in snd_pcm_fasync()
3962 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_fasync()
3964 runtime = substream->runtime; in snd_pcm_fasync()
4025 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_old_user() argument
4042 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_old_user()
4046 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_old_user()
4060 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_old_user() argument
4078 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_old_user()
4101 struct snd_pcm_substream *substream = pcm_file->substream; in snd_pcm_get_unmapped_area() local
4102 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area()