Lines Matching refs:dpcm
243 static void dummy_systimer_rearm(struct dummy_systimer_pcm *dpcm) in dummy_systimer_rearm() argument
245 mod_timer(&dpcm->timer, jiffies + in dummy_systimer_rearm()
246 DIV_ROUND_UP(dpcm->frac_period_rest, dpcm->rate)); in dummy_systimer_rearm()
249 static void dummy_systimer_update(struct dummy_systimer_pcm *dpcm) in dummy_systimer_update() argument
253 delta = jiffies - dpcm->base_time; in dummy_systimer_update()
256 dpcm->base_time += delta; in dummy_systimer_update()
257 delta *= dpcm->rate; in dummy_systimer_update()
258 dpcm->frac_pos += delta; in dummy_systimer_update()
259 while (dpcm->frac_pos >= dpcm->frac_buffer_size) in dummy_systimer_update()
260 dpcm->frac_pos -= dpcm->frac_buffer_size; in dummy_systimer_update()
261 while (dpcm->frac_period_rest <= delta) { in dummy_systimer_update()
262 dpcm->elapsed++; in dummy_systimer_update()
263 dpcm->frac_period_rest += dpcm->frac_period_size; in dummy_systimer_update()
265 dpcm->frac_period_rest -= delta; in dummy_systimer_update()
270 struct dummy_systimer_pcm *dpcm = substream->runtime->private_data; in dummy_systimer_start() local
271 spin_lock(&dpcm->lock); in dummy_systimer_start()
272 dpcm->base_time = jiffies; in dummy_systimer_start()
273 dummy_systimer_rearm(dpcm); in dummy_systimer_start()
274 spin_unlock(&dpcm->lock); in dummy_systimer_start()
280 struct dummy_systimer_pcm *dpcm = substream->runtime->private_data; in dummy_systimer_stop() local
281 spin_lock(&dpcm->lock); in dummy_systimer_stop()
282 del_timer(&dpcm->timer); in dummy_systimer_stop()
283 spin_unlock(&dpcm->lock); in dummy_systimer_stop()
290 struct dummy_systimer_pcm *dpcm = runtime->private_data; in dummy_systimer_prepare() local
292 dpcm->frac_pos = 0; in dummy_systimer_prepare()
293 dpcm->rate = runtime->rate; in dummy_systimer_prepare()
294 dpcm->frac_buffer_size = runtime->buffer_size * HZ; in dummy_systimer_prepare()
295 dpcm->frac_period_size = runtime->period_size * HZ; in dummy_systimer_prepare()
296 dpcm->frac_period_rest = dpcm->frac_period_size; in dummy_systimer_prepare()
297 dpcm->elapsed = 0; in dummy_systimer_prepare()
304 struct dummy_systimer_pcm *dpcm = from_timer(dpcm, t, timer); in dummy_systimer_callback() local
308 spin_lock_irqsave(&dpcm->lock, flags); in dummy_systimer_callback()
309 dummy_systimer_update(dpcm); in dummy_systimer_callback()
310 dummy_systimer_rearm(dpcm); in dummy_systimer_callback()
311 elapsed = dpcm->elapsed; in dummy_systimer_callback()
312 dpcm->elapsed = 0; in dummy_systimer_callback()
313 spin_unlock_irqrestore(&dpcm->lock, flags); in dummy_systimer_callback()
315 snd_pcm_period_elapsed(dpcm->substream); in dummy_systimer_callback()
321 struct dummy_systimer_pcm *dpcm = substream->runtime->private_data; in dummy_systimer_pointer() local
324 spin_lock(&dpcm->lock); in dummy_systimer_pointer()
325 dummy_systimer_update(dpcm); in dummy_systimer_pointer()
326 pos = dpcm->frac_pos / HZ; in dummy_systimer_pointer()
327 spin_unlock(&dpcm->lock); in dummy_systimer_pointer()
333 struct dummy_systimer_pcm *dpcm; in dummy_systimer_create() local
335 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); in dummy_systimer_create()
336 if (!dpcm) in dummy_systimer_create()
338 substream->runtime->private_data = dpcm; in dummy_systimer_create()
339 timer_setup(&dpcm->timer, dummy_systimer_callback, 0); in dummy_systimer_create()
340 spin_lock_init(&dpcm->lock); in dummy_systimer_create()
341 dpcm->substream = substream; in dummy_systimer_create()
376 struct dummy_hrtimer_pcm *dpcm; in dummy_hrtimer_callback() local
378 dpcm = container_of(timer, struct dummy_hrtimer_pcm, timer); in dummy_hrtimer_callback()
379 if (!atomic_read(&dpcm->running)) in dummy_hrtimer_callback()
385 snd_pcm_period_elapsed(dpcm->substream); in dummy_hrtimer_callback()
386 if (!atomic_read(&dpcm->running)) in dummy_hrtimer_callback()
389 hrtimer_forward_now(timer, dpcm->period_time); in dummy_hrtimer_callback()
395 struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; in dummy_hrtimer_start() local
397 dpcm->base_time = hrtimer_cb_get_time(&dpcm->timer); in dummy_hrtimer_start()
398 hrtimer_start(&dpcm->timer, dpcm->period_time, HRTIMER_MODE_REL_SOFT); in dummy_hrtimer_start()
399 atomic_set(&dpcm->running, 1); in dummy_hrtimer_start()
405 struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; in dummy_hrtimer_stop() local
407 atomic_set(&dpcm->running, 0); in dummy_hrtimer_stop()
408 if (!hrtimer_callback_running(&dpcm->timer)) in dummy_hrtimer_stop()
409 hrtimer_cancel(&dpcm->timer); in dummy_hrtimer_stop()
413 static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm) in dummy_hrtimer_sync() argument
415 hrtimer_cancel(&dpcm->timer); in dummy_hrtimer_sync()
422 struct dummy_hrtimer_pcm *dpcm = runtime->private_data; in dummy_hrtimer_pointer() local
426 delta = ktime_us_delta(hrtimer_cb_get_time(&dpcm->timer), in dummy_hrtimer_pointer()
427 dpcm->base_time); in dummy_hrtimer_pointer()
436 struct dummy_hrtimer_pcm *dpcm = runtime->private_data; in dummy_hrtimer_prepare() local
441 dummy_hrtimer_sync(dpcm); in dummy_hrtimer_prepare()
447 dpcm->period_time = ktime_set(sec, nsecs); in dummy_hrtimer_prepare()
454 struct dummy_hrtimer_pcm *dpcm; in dummy_hrtimer_create() local
456 dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); in dummy_hrtimer_create()
457 if (!dpcm) in dummy_hrtimer_create()
459 substream->runtime->private_data = dpcm; in dummy_hrtimer_create()
460 hrtimer_init(&dpcm->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT); in dummy_hrtimer_create()
461 dpcm->timer.function = dummy_hrtimer_callback; in dummy_hrtimer_create()
462 dpcm->substream = substream; in dummy_hrtimer_create()
463 atomic_set(&dpcm->running, 0); in dummy_hrtimer_create()
469 struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; in dummy_hrtimer_free() local
470 dummy_hrtimer_sync(dpcm); in dummy_hrtimer_free()
471 kfree(dpcm); in dummy_hrtimer_free()