• Home
  • Raw
  • Download

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->status->state != SNDRV_PCM_STATE_DISCONNECTED) in snd_pcm_set_state()
599 substream->runtime->status->state = 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, &params); 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()
1437 substream->runtime->stop_operating = true; in snd_pcm_undo_start()
1441 static void snd_pcm_post_start(struct snd_pcm_substream *substream, in snd_pcm_post_start() argument
1444 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_start()
1445 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_start()
1450 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_start()
1452 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_start()
1453 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTART); in snd_pcm_post_start()
1470 int snd_pcm_start(struct snd_pcm_substream *substream) in snd_pcm_start() argument
1472 return snd_pcm_action(&snd_pcm_action_start, substream, in snd_pcm_start()
1477 static int snd_pcm_start_lock_irq(struct snd_pcm_substream *substream) in snd_pcm_start_lock_irq() argument
1479 return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, in snd_pcm_start_lock_irq()
1486 static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, in snd_pcm_pre_stop() argument
1489 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_stop()
1492 runtime->trigger_master = substream; in snd_pcm_pre_stop()
1496 static int snd_pcm_do_stop(struct snd_pcm_substream *substream, in snd_pcm_do_stop() argument
1499 if (substream->runtime->trigger_master == substream && in snd_pcm_do_stop()
1500 snd_pcm_running(substream)) { in snd_pcm_do_stop()
1501 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); in snd_pcm_do_stop()
1502 substream->runtime->stop_operating = true; in snd_pcm_do_stop()
1507 static void snd_pcm_post_stop(struct snd_pcm_substream *substream, in snd_pcm_post_stop() argument
1510 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_stop()
1512 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_stop()
1514 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSTOP); in snd_pcm_post_stop()
1535 int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t state) in snd_pcm_stop() argument
1537 return snd_pcm_action(&snd_pcm_action_stop, substream, state); in snd_pcm_stop()
1550 int snd_pcm_drain_done(struct snd_pcm_substream *substream) in snd_pcm_drain_done() argument
1552 return snd_pcm_action_single(&snd_pcm_action_stop, substream, in snd_pcm_drain_done()
1565 int snd_pcm_stop_xrun(struct snd_pcm_substream *substream) in snd_pcm_stop_xrun() argument
1569 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_stop_xrun()
1570 if (substream->runtime && snd_pcm_running(substream)) in snd_pcm_stop_xrun()
1571 __snd_pcm_xrun(substream); in snd_pcm_stop_xrun()
1572 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_stop_xrun()
1582 static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, in snd_pcm_pre_pause() argument
1585 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_pause()
1593 runtime->trigger_master = substream; in snd_pcm_pre_pause()
1597 static int snd_pcm_do_pause(struct snd_pcm_substream *substream, in snd_pcm_do_pause() argument
1600 if (substream->runtime->trigger_master != substream) in snd_pcm_do_pause()
1605 snd_pcm_update_hw_ptr(substream); in snd_pcm_do_pause()
1610 substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; in snd_pcm_do_pause()
1611 return substream->ops->trigger(substream, in snd_pcm_do_pause()
1617 static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, in snd_pcm_undo_pause() argument
1620 if (substream->runtime->trigger_master == substream) in snd_pcm_undo_pause()
1621 substream->ops->trigger(substream, in snd_pcm_undo_pause()
1627 static void snd_pcm_post_pause(struct snd_pcm_substream *substream, in snd_pcm_post_pause() argument
1630 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_pause()
1631 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_pause()
1634 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MPAUSE); in snd_pcm_post_pause()
1639 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MCONTINUE); in snd_pcm_post_pause()
1653 static int snd_pcm_pause(struct snd_pcm_substream *substream, bool push) in snd_pcm_pause() argument
1655 return snd_pcm_action(&snd_pcm_action_pause, substream, in snd_pcm_pause()
1659 static int snd_pcm_pause_lock_irq(struct snd_pcm_substream *substream, in snd_pcm_pause_lock_irq() argument
1662 return snd_pcm_action_lock_irq(&snd_pcm_action_pause, substream, in snd_pcm_pause_lock_irq()
1669 static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, in snd_pcm_pre_suspend() argument
1672 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_suspend()
1682 runtime->trigger_master = substream; in snd_pcm_pre_suspend()
1686 static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, in snd_pcm_do_suspend() argument
1689 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_suspend()
1690 if (runtime->trigger_master != substream) in snd_pcm_do_suspend()
1692 if (! snd_pcm_running(substream)) in snd_pcm_do_suspend()
1694 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_do_suspend()
1699 static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, in snd_pcm_post_suspend() argument
1702 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_suspend()
1703 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_suspend()
1706 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MSUSPEND); in snd_pcm_post_suspend()
1725 static int snd_pcm_suspend(struct snd_pcm_substream *substream) in snd_pcm_suspend() argument
1730 snd_pcm_stream_lock_irqsave(substream, flags); in snd_pcm_suspend()
1731 err = snd_pcm_action(&snd_pcm_action_suspend, substream, in snd_pcm_suspend()
1733 snd_pcm_stream_unlock_irqrestore(substream, flags); in snd_pcm_suspend()
1747 struct snd_pcm_substream *substream; in snd_pcm_suspend_all() local
1753 for_each_pcm_substream(pcm, stream, substream) { in snd_pcm_suspend_all()
1755 if (!substream->runtime) in snd_pcm_suspend_all()
1762 if (!substream->ops) in snd_pcm_suspend_all()
1765 err = snd_pcm_suspend(substream); in snd_pcm_suspend_all()
1770 for_each_pcm_substream(pcm, stream, substream) in snd_pcm_suspend_all()
1771 snd_pcm_sync_stop(substream, false); in snd_pcm_suspend_all()
1779 static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, in snd_pcm_pre_resume() argument
1782 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_resume()
1785 runtime->trigger_master = substream; in snd_pcm_pre_resume()
1789 static int snd_pcm_do_resume(struct snd_pcm_substream *substream, in snd_pcm_do_resume() argument
1792 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_resume()
1793 if (runtime->trigger_master != substream) in snd_pcm_do_resume()
1798 substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) in snd_pcm_do_resume()
1800 return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); in snd_pcm_do_resume()
1803 static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, in snd_pcm_undo_resume() argument
1806 if (substream->runtime->trigger_master == substream && in snd_pcm_undo_resume()
1807 snd_pcm_running(substream)) in snd_pcm_undo_resume()
1808 substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); in snd_pcm_undo_resume()
1811 static void snd_pcm_post_resume(struct snd_pcm_substream *substream, in snd_pcm_post_resume() argument
1814 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_resume()
1815 snd_pcm_trigger_tstamp(substream); in snd_pcm_post_resume()
1817 snd_pcm_timer_notify(substream, SNDRV_TIMER_EVENT_MRESUME); in snd_pcm_post_resume()
1827 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1829 return snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, in snd_pcm_resume()
1835 static int snd_pcm_resume(struct snd_pcm_substream *substream) in snd_pcm_resume() argument
1847 static int snd_pcm_xrun(struct snd_pcm_substream *substream) in snd_pcm_xrun() argument
1849 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xrun()
1852 snd_pcm_stream_lock_irq(substream); in snd_pcm_xrun()
1858 __snd_pcm_xrun(substream); in snd_pcm_xrun()
1864 snd_pcm_stream_unlock_irq(substream); in snd_pcm_xrun()
1872 static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, in snd_pcm_pre_reset() argument
1875 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_reset()
1887 static int snd_pcm_do_reset(struct snd_pcm_substream *substream, in snd_pcm_do_reset() argument
1890 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_reset()
1891 int err = snd_pcm_ops_ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); in snd_pcm_do_reset()
1894 snd_pcm_stream_lock_irq(substream); in snd_pcm_do_reset()
1900 snd_pcm_stream_unlock_irq(substream); in snd_pcm_do_reset()
1904 static void snd_pcm_post_reset(struct snd_pcm_substream *substream, in snd_pcm_post_reset() argument
1907 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_reset()
1908 snd_pcm_stream_lock_irq(substream); in snd_pcm_post_reset()
1910 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_post_reset()
1912 snd_pcm_playback_silence(substream, ULONG_MAX); in snd_pcm_post_reset()
1913 snd_pcm_stream_unlock_irq(substream); in snd_pcm_post_reset()
1922 static int snd_pcm_reset(struct snd_pcm_substream *substream) in snd_pcm_reset() argument
1924 return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, in snd_pcm_reset()
1932 static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, in snd_pcm_pre_prepare() argument
1935 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_prepare()
1941 if (snd_pcm_running(substream)) in snd_pcm_pre_prepare()
1943 substream->f_flags = f_flags; in snd_pcm_pre_prepare()
1947 static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, in snd_pcm_do_prepare() argument
1951 snd_pcm_sync_stop(substream, true); in snd_pcm_do_prepare()
1952 err = substream->ops->prepare(substream); in snd_pcm_do_prepare()
1955 return snd_pcm_do_reset(substream, state); in snd_pcm_do_prepare()
1958 static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, in snd_pcm_post_prepare() argument
1961 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_post_prepare()
1963 snd_pcm_set_state(substream, SNDRV_PCM_STATE_PREPARED); in snd_pcm_post_prepare()
1979 static int snd_pcm_prepare(struct snd_pcm_substream *substream, in snd_pcm_prepare() argument
1987 f_flags = substream->f_flags; in snd_pcm_prepare()
1989 snd_pcm_stream_lock_irq(substream); in snd_pcm_prepare()
1990 switch (substream->runtime->status->state) { in snd_pcm_prepare()
1992 snd_pcm_pause(substream, false); in snd_pcm_prepare()
1995 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_prepare()
1998 snd_pcm_stream_unlock_irq(substream); in snd_pcm_prepare()
2001 substream, in snd_pcm_prepare()
2010 static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, in snd_pcm_pre_drain_init() argument
2013 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_pre_drain_init()
2020 runtime->trigger_master = substream; in snd_pcm_pre_drain_init()
2024 static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, in snd_pcm_do_drain_init() argument
2027 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_do_drain_init()
2028 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_do_drain_init()
2032 if (! snd_pcm_playback_empty(substream)) { in snd_pcm_do_drain_init()
2033 snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2034 snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING); in snd_pcm_do_drain_init()
2055 snd_pcm_do_stop(substream, new_state); in snd_pcm_do_drain_init()
2056 snd_pcm_post_stop(substream, new_state); in snd_pcm_do_drain_init()
2061 runtime->trigger_master == substream && in snd_pcm_do_drain_init()
2063 return substream->ops->trigger(substream, in snd_pcm_do_drain_init()
2069 static void snd_pcm_post_drain_init(struct snd_pcm_substream *substream, in snd_pcm_post_drain_init() argument
2087 static int snd_pcm_drain(struct snd_pcm_substream *substream, in snd_pcm_drain() argument
2098 card = substream->pcm->card; in snd_pcm_drain()
2099 runtime = substream->runtime; in snd_pcm_drain()
2107 } else if (substream->f_flags & O_NONBLOCK) in snd_pcm_drain()
2110 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
2113 snd_pcm_pause(substream, false); in snd_pcm_drain()
2116 result = snd_pcm_action(&snd_pcm_action_drain_init, substream, in snd_pcm_drain()
2135 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
2136 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
2145 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
2151 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
2164 snd_pcm_stream_lock_irq(substream); in snd_pcm_drain()
2165 group = snd_pcm_stream_group_ref(substream); in snd_pcm_drain()
2166 snd_pcm_group_for_each_entry(s, substream) { in snd_pcm_drain()
2172 snd_pcm_group_unref(group, substream); in snd_pcm_drain()
2179 if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) in snd_pcm_drain()
2182 dev_dbg(substream->pcm->card->dev, in snd_pcm_drain()
2184 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drain()
2192 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drain()
2202 static int snd_pcm_drop(struct snd_pcm_substream *substream) in snd_pcm_drop() argument
2207 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_drop()
2209 runtime = substream->runtime; in snd_pcm_drop()
2215 snd_pcm_stream_lock_irq(substream); in snd_pcm_drop()
2218 snd_pcm_pause(substream, false); in snd_pcm_drop()
2220 snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); in snd_pcm_drop()
2222 snd_pcm_stream_unlock_irq(substream); in snd_pcm_drop()
2249 static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) in snd_pcm_link() argument
2255 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_link()
2265 substream1 = pcm_file->substream; in snd_pcm_link()
2267 if (substream == substream1) { in snd_pcm_link()
2280 if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN || in snd_pcm_link()
2281 substream->runtime->status->state != substream1->runtime->status->state || in snd_pcm_link()
2282 substream->pcm->nonatomic != substream1->pcm->nonatomic) { in snd_pcm_link()
2291 snd_pcm_stream_lock_irq(substream); in snd_pcm_link()
2292 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_link()
2293 snd_pcm_group_assign(substream, group); in snd_pcm_link()
2296 target_group = substream->group; in snd_pcm_link()
2297 snd_pcm_stream_unlock_irq(substream); in snd_pcm_link()
2314 static void relink_to_local(struct snd_pcm_substream *substream) in relink_to_local() argument
2316 snd_pcm_stream_lock_nested(substream); in relink_to_local()
2317 snd_pcm_group_assign(substream, &substream->self_group); in relink_to_local()
2318 snd_pcm_stream_unlock(substream); in relink_to_local()
2321 static int snd_pcm_unlink(struct snd_pcm_substream *substream) in snd_pcm_unlink() argument
2324 bool nonatomic = substream->pcm->nonatomic; in snd_pcm_unlink()
2330 if (!snd_pcm_stream_linked(substream)) { in snd_pcm_unlink()
2335 group = substream->group; in snd_pcm_unlink()
2338 relink_to_local(substream); in snd_pcm_unlink()
2474 struct snd_pcm_substream *substream = rule->private; in snd_pcm_hw_rule_buffer_bytes_max() local
2476 t.max = substream->buffer_bytes_max; in snd_pcm_hw_rule_buffer_bytes_max()
2483 static int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_init() argument
2485 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_init()
2607 static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) in snd_pcm_hw_constraints_complete() argument
2609 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_hw_constraints_complete()
2618 if (hw_support_mmap(substream)) { in snd_pcm_hw_constraints_complete()
2665 snd_pcm_hw_rule_buffer_bytes_max, substream, in snd_pcm_hw_constraints_complete()
2691 static void pcm_release_private(struct snd_pcm_substream *substream) in pcm_release_private() argument
2693 if (snd_pcm_stream_linked(substream)) in pcm_release_private()
2694 snd_pcm_unlink(substream); in pcm_release_private()
2697 void snd_pcm_release_substream(struct snd_pcm_substream *substream) in snd_pcm_release_substream() argument
2699 substream->ref_count--; in snd_pcm_release_substream()
2700 if (substream->ref_count > 0) in snd_pcm_release_substream()
2703 snd_pcm_drop(substream); in snd_pcm_release_substream()
2704 if (substream->hw_opened) { in snd_pcm_release_substream()
2705 if (substream->runtime->status->state != SNDRV_PCM_STATE_OPEN) in snd_pcm_release_substream()
2706 do_hw_free(substream); in snd_pcm_release_substream()
2707 substream->ops->close(substream); in snd_pcm_release_substream()
2708 substream->hw_opened = 0; in snd_pcm_release_substream()
2710 if (cpu_latency_qos_request_active(&substream->latency_pm_qos_req)) in snd_pcm_release_substream()
2711 cpu_latency_qos_remove_request(&substream->latency_pm_qos_req); in snd_pcm_release_substream()
2712 if (substream->pcm_release) { in snd_pcm_release_substream()
2713 substream->pcm_release(substream); in snd_pcm_release_substream()
2714 substream->pcm_release = NULL; in snd_pcm_release_substream()
2716 snd_pcm_detach_substream(substream); in snd_pcm_release_substream()
2724 struct snd_pcm_substream *substream; in snd_pcm_open_substream() local
2727 err = snd_pcm_attach_substream(pcm, stream, file, &substream); in snd_pcm_open_substream()
2730 if (substream->ref_count > 1) { in snd_pcm_open_substream()
2731 *rsubstream = substream; in snd_pcm_open_substream()
2735 err = snd_pcm_hw_constraints_init(substream); in snd_pcm_open_substream()
2741 err = substream->ops->open(substream); in snd_pcm_open_substream()
2745 substream->hw_opened = 1; in snd_pcm_open_substream()
2747 err = snd_pcm_hw_constraints_complete(substream); in snd_pcm_open_substream()
2753 *rsubstream = substream; in snd_pcm_open_substream()
2757 snd_pcm_release_substream(substream); in snd_pcm_open_substream()
2767 struct snd_pcm_substream *substream; in snd_pcm_open_file() local
2770 err = snd_pcm_open_substream(pcm, stream, file, &substream); in snd_pcm_open_file()
2776 snd_pcm_release_substream(substream); in snd_pcm_open_file()
2779 pcm_file->substream = substream; in snd_pcm_open_file()
2780 if (substream->ref_count == 1) in snd_pcm_open_file()
2781 substream->pcm_release = pcm_release_private; in snd_pcm_open_file()
2875 struct snd_pcm_substream *substream; in snd_pcm_release() local
2879 substream = pcm_file->substream; in snd_pcm_release()
2880 if (snd_BUG_ON(!substream)) in snd_pcm_release()
2882 pcm = substream->pcm; in snd_pcm_release()
2888 snd_pcm_release_substream(substream); in snd_pcm_release()
2900 static int do_pcm_hwsync(struct snd_pcm_substream *substream) in do_pcm_hwsync() argument
2902 switch (substream->runtime->status->state) { in do_pcm_hwsync()
2904 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in do_pcm_hwsync()
2908 return snd_pcm_update_hw_ptr(substream); in do_pcm_hwsync()
2922 static snd_pcm_sframes_t forward_appl_ptr(struct snd_pcm_substream *substream, in forward_appl_ptr() argument
2926 struct snd_pcm_runtime *runtime = substream->runtime; in forward_appl_ptr()
2937 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in forward_appl_ptr()
2942 static snd_pcm_sframes_t rewind_appl_ptr(struct snd_pcm_substream *substream, in rewind_appl_ptr() argument
2946 struct snd_pcm_runtime *runtime = substream->runtime; in rewind_appl_ptr()
2957 ret = pcm_lib_apply_appl_ptr(substream, appl_ptr); in rewind_appl_ptr()
2966 static snd_pcm_sframes_t snd_pcm_rewind(struct snd_pcm_substream *substream, in snd_pcm_rewind() argument
2974 snd_pcm_stream_lock_irq(substream); in snd_pcm_rewind()
2975 ret = do_pcm_hwsync(substream); in snd_pcm_rewind()
2977 ret = rewind_appl_ptr(substream, frames, in snd_pcm_rewind()
2978 snd_pcm_hw_avail(substream)); in snd_pcm_rewind()
2979 snd_pcm_stream_unlock_irq(substream); in snd_pcm_rewind()
2983 static snd_pcm_sframes_t snd_pcm_forward(struct snd_pcm_substream *substream, in snd_pcm_forward() argument
2991 snd_pcm_stream_lock_irq(substream); in snd_pcm_forward()
2992 ret = do_pcm_hwsync(substream); in snd_pcm_forward()
2994 ret = forward_appl_ptr(substream, frames, in snd_pcm_forward()
2995 snd_pcm_avail(substream)); in snd_pcm_forward()
2996 snd_pcm_stream_unlock_irq(substream); in snd_pcm_forward()
3000 static int snd_pcm_hwsync(struct snd_pcm_substream *substream) in snd_pcm_hwsync() argument
3004 snd_pcm_stream_lock_irq(substream); in snd_pcm_hwsync()
3005 err = do_pcm_hwsync(substream); in snd_pcm_hwsync()
3006 snd_pcm_stream_unlock_irq(substream); in snd_pcm_hwsync()
3010 static int snd_pcm_delay(struct snd_pcm_substream *substream, in snd_pcm_delay() argument
3016 snd_pcm_stream_lock_irq(substream); in snd_pcm_delay()
3017 err = do_pcm_hwsync(substream); in snd_pcm_delay()
3019 n = snd_pcm_calc_delay(substream); in snd_pcm_delay()
3020 snd_pcm_stream_unlock_irq(substream); in snd_pcm_delay()
3026 static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, in snd_pcm_sync_ptr() argument
3029 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_sync_ptr()
3043 err = snd_pcm_hwsync(substream); in snd_pcm_sync_ptr()
3047 snd_pcm_stream_lock_irq(substream); in snd_pcm_sync_ptr()
3049 err = pcm_lib_apply_appl_ptr(substream, in snd_pcm_sync_ptr()
3052 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
3067 snd_pcm_stream_unlock_irq(substream); in snd_pcm_sync_ptr()
3114 static int snd_pcm_ioctl_sync_ptr_compat(struct snd_pcm_substream *substream, in snd_pcm_ioctl_sync_ptr_compat() argument
3117 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_ioctl_sync_ptr_compat()
3134 err = snd_pcm_hwsync(substream); in snd_pcm_ioctl_sync_ptr_compat()
3143 snd_pcm_stream_lock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3146 err = pcm_lib_apply_appl_ptr(substream, in snd_pcm_ioctl_sync_ptr_compat()
3149 snd_pcm_stream_unlock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3163 snd_pcm_stream_unlock_irq(substream); in snd_pcm_ioctl_sync_ptr_compat()
3179 static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) in snd_pcm_tstamp() argument
3181 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_tstamp()
3192 static int snd_pcm_xferi_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xferi_frames_ioctl() argument
3196 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xferi_frames_ioctl()
3205 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xferi_frames_ioctl()
3206 result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
3208 result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); in snd_pcm_xferi_frames_ioctl()
3214 static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream, in snd_pcm_xfern_frames_ioctl() argument
3218 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_xfern_frames_ioctl()
3234 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_xfern_frames_ioctl()
3235 result = snd_pcm_lib_writev(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
3237 result = snd_pcm_lib_readv(substream, bufs, xfern.frames); in snd_pcm_xfern_frames_ioctl()
3244 static int snd_pcm_rewind_ioctl(struct snd_pcm_substream *substream, in snd_pcm_rewind_ioctl() argument
3254 result = snd_pcm_rewind(substream, frames); in snd_pcm_rewind_ioctl()
3260 static int snd_pcm_forward_ioctl(struct snd_pcm_substream *substream, in snd_pcm_forward_ioctl() argument
3270 result = snd_pcm_forward(substream, frames); in snd_pcm_forward_ioctl()
3277 struct snd_pcm_substream *substream, in snd_pcm_common_ioctl() argument
3283 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_common_ioctl()
3286 res = snd_power_wait(substream->pcm->card); in snd_pcm_common_ioctl()
3294 return snd_pcm_info_user(substream, arg); in snd_pcm_common_ioctl()
3298 return snd_pcm_tstamp(substream, arg); in snd_pcm_common_ioctl()
3305 return snd_pcm_hw_refine_user(substream, arg); in snd_pcm_common_ioctl()
3307 return snd_pcm_hw_params_user(substream, arg); in snd_pcm_common_ioctl()
3309 return snd_pcm_hw_free(substream); in snd_pcm_common_ioctl()
3311 return snd_pcm_sw_params_user(substream, arg); in snd_pcm_common_ioctl()
3313 return snd_pcm_status_user32(substream, arg, false); in snd_pcm_common_ioctl()
3315 return snd_pcm_status_user32(substream, arg, true); in snd_pcm_common_ioctl()
3317 return snd_pcm_status_user64(substream, arg, false); in snd_pcm_common_ioctl()
3319 return snd_pcm_status_user64(substream, arg, true); in snd_pcm_common_ioctl()
3321 return snd_pcm_channel_info_user(substream, arg); in snd_pcm_common_ioctl()
3323 return snd_pcm_prepare(substream, file); in snd_pcm_common_ioctl()
3325 return snd_pcm_reset(substream); in snd_pcm_common_ioctl()
3327 return snd_pcm_start_lock_irq(substream); in snd_pcm_common_ioctl()
3329 return snd_pcm_link(substream, (int)(unsigned long) arg); in snd_pcm_common_ioctl()
3331 return snd_pcm_unlink(substream); in snd_pcm_common_ioctl()
3333 return snd_pcm_resume(substream); in snd_pcm_common_ioctl()
3335 return snd_pcm_xrun(substream); in snd_pcm_common_ioctl()
3337 return snd_pcm_hwsync(substream); in snd_pcm_common_ioctl()
3344 err = snd_pcm_delay(substream, &delay); in snd_pcm_common_ioctl()
3352 return snd_pcm_ioctl_sync_ptr_compat(substream, arg); in snd_pcm_common_ioctl()
3354 return snd_pcm_sync_ptr(substream, arg); in snd_pcm_common_ioctl()
3357 return snd_pcm_hw_refine_old_user(substream, arg); in snd_pcm_common_ioctl()
3359 return snd_pcm_hw_params_old_user(substream, arg); in snd_pcm_common_ioctl()
3362 return snd_pcm_drain(substream, file); in snd_pcm_common_ioctl()
3364 return snd_pcm_drop(substream); in snd_pcm_common_ioctl()
3366 return snd_pcm_pause_lock_irq(substream, (unsigned long)arg); in snd_pcm_common_ioctl()
3369 return snd_pcm_xferi_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
3372 return snd_pcm_xfern_frames_ioctl(substream, arg); in snd_pcm_common_ioctl()
3374 return snd_pcm_rewind_ioctl(substream, arg); in snd_pcm_common_ioctl()
3376 return snd_pcm_forward_ioctl(substream, arg); in snd_pcm_common_ioctl()
3378 pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd); in snd_pcm_common_ioctl()
3392 return snd_pcm_common_ioctl(file, pcm_file->substream, cmd, in snd_pcm_ioctl()
3406 int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, in snd_pcm_kernel_ioctl() argument
3416 if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) in snd_pcm_kernel_ioctl()
3418 result = snd_pcm_forward(substream, *frames); in snd_pcm_kernel_ioctl()
3422 return snd_pcm_hw_params(substream, arg); in snd_pcm_kernel_ioctl()
3424 return snd_pcm_sw_params(substream, arg); in snd_pcm_kernel_ioctl()
3426 return snd_pcm_prepare(substream, NULL); in snd_pcm_kernel_ioctl()
3428 return snd_pcm_start_lock_irq(substream); in snd_pcm_kernel_ioctl()
3430 return snd_pcm_drain(substream, NULL); in snd_pcm_kernel_ioctl()
3432 return snd_pcm_drop(substream); in snd_pcm_kernel_ioctl()
3434 return snd_pcm_delay(substream, frames); in snd_pcm_kernel_ioctl()
3445 struct snd_pcm_substream *substream; in snd_pcm_read() local
3450 substream = pcm_file->substream; in snd_pcm_read()
3451 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_read()
3453 runtime = substream->runtime; in snd_pcm_read()
3459 result = snd_pcm_lib_read(substream, buf, count); in snd_pcm_read()
3469 struct snd_pcm_substream *substream; in snd_pcm_write() local
3474 substream = pcm_file->substream; in snd_pcm_write()
3475 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_write()
3477 runtime = substream->runtime; in snd_pcm_write()
3483 result = snd_pcm_lib_write(substream, buf, count); in snd_pcm_write()
3492 struct snd_pcm_substream *substream; in snd_pcm_readv() local
3500 substream = pcm_file->substream; in snd_pcm_readv()
3501 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_readv()
3503 runtime = substream->runtime; in snd_pcm_readv()
3518 result = snd_pcm_lib_readv(substream, bufs, frames); in snd_pcm_readv()
3528 struct snd_pcm_substream *substream; in snd_pcm_writev() local
3536 substream = pcm_file->substream; in snd_pcm_writev()
3537 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_writev()
3539 runtime = substream->runtime; in snd_pcm_writev()
3553 result = snd_pcm_lib_writev(substream, bufs, frames); in snd_pcm_writev()
3563 struct snd_pcm_substream *substream; in snd_pcm_poll() local
3570 substream = pcm_file->substream; in snd_pcm_poll()
3571 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_pcm_poll()
3575 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_poll()
3578 runtime = substream->runtime; in snd_pcm_poll()
3582 snd_pcm_stream_lock_irq(substream); in snd_pcm_poll()
3583 avail = snd_pcm_avail(substream); in snd_pcm_poll()
3592 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in snd_pcm_poll()
3602 snd_pcm_stream_unlock_irq(substream); in snd_pcm_poll()
3620 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_status_fault() local
3623 if (substream == NULL) in snd_pcm_mmap_status_fault()
3625 runtime = substream->runtime; in snd_pcm_mmap_status_fault()
3636 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3646 area->vm_private_data = substream; in snd_pcm_mmap_status()
3656 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_control_fault() local
3659 if (substream == NULL) in snd_pcm_mmap_control_fault()
3661 runtime = substream->runtime; in snd_pcm_mmap_control_fault()
3672 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3682 area->vm_private_data = substream; in snd_pcm_mmap_control()
3693 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_status_mmap_allowed()
3700 (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR)) in pcm_status_mmap_allowed()
3710 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_EXPLICIT_SYNC) in pcm_control_mmap_allowed()
3716 if (pcm_file->substream->runtime->hw.info & SNDRV_PCM_INFO_SYNC_APPLPTR) in pcm_control_mmap_allowed()
3728 static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_status() argument
3733 static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_control() argument
3745 struct snd_pcm_substream *substream = vmf->vma->vm_private_data; in snd_pcm_mmap_data_fault() local
3751 if (substream == NULL) in snd_pcm_mmap_data_fault()
3753 runtime = substream->runtime; in snd_pcm_mmap_data_fault()
3758 if (substream->ops->page) in snd_pcm_mmap_data_fault()
3759 page = substream->ops->page(substream, offset); in snd_pcm_mmap_data_fault()
3760 else if (!snd_pcm_get_dma_buf(substream)) in snd_pcm_mmap_data_fault()
3763 page = snd_sgbuf_get_page(snd_pcm_get_dma_buf(substream), offset); in snd_pcm_mmap_data_fault()
3794 int snd_pcm_lib_default_mmap(struct snd_pcm_substream *substream, in snd_pcm_lib_default_mmap() argument
3798 if (!substream->ops->page && in snd_pcm_lib_default_mmap()
3799 !snd_dma_buffer_mmap(snd_pcm_get_dma_buf(substream), area)) in snd_pcm_lib_default_mmap()
3820 int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, in snd_pcm_lib_mmap_iomem() argument
3823 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_mmap_iomem()
3834 int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, in snd_pcm_mmap_data() argument
3843 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_pcm_mmap_data()
3850 runtime = substream->runtime; in snd_pcm_mmap_data()
3867 area->vm_private_data = substream; in snd_pcm_mmap_data()
3868 if (substream->ops->mmap) in snd_pcm_mmap_data()
3869 err = substream->ops->mmap(substream, area); in snd_pcm_mmap_data()
3871 err = snd_pcm_lib_default_mmap(substream, area); in snd_pcm_mmap_data()
3873 atomic_inc(&substream->mmap_count); in snd_pcm_mmap_data()
3881 struct snd_pcm_substream *substream; in snd_pcm_mmap() local
3885 substream = pcm_file->substream; in snd_pcm_mmap()
3886 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_mmap()
3898 return snd_pcm_mmap_status(substream, file, area); in snd_pcm_mmap()
3906 return snd_pcm_mmap_control(substream, file, area); in snd_pcm_mmap()
3908 return snd_pcm_mmap_data(substream, file, area); in snd_pcm_mmap()
3916 struct snd_pcm_substream *substream; in snd_pcm_fasync() local
3920 substream = pcm_file->substream; in snd_pcm_fasync()
3921 if (PCM_RUNTIME_CHECK(substream)) in snd_pcm_fasync()
3923 runtime = substream->runtime; in snd_pcm_fasync()
3982 static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_refine_old_user() argument
3999 err = snd_pcm_hw_refine(substream, params); in snd_pcm_hw_refine_old_user()
4003 err = fixup_unreferenced_params(substream, params); in snd_pcm_hw_refine_old_user()
4017 static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, in snd_pcm_hw_params_old_user() argument
4035 err = snd_pcm_hw_params(substream, params); in snd_pcm_hw_params_old_user()
4058 struct snd_pcm_substream *substream = pcm_file->substream; in snd_pcm_get_unmapped_area() local
4059 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_get_unmapped_area()