Lines Matching full:ti

65 	struct ct_timer_instance *ti = from_timer(ti, t, timer);  in ct_systimer_callback()  local
66 struct snd_pcm_substream *substream = ti->substream; in ct_systimer_callback()
68 struct ct_atc_pcm *apcm = ti->apcm; in ct_systimer_callback()
75 dist = (position + buffer_size - ti->position) % buffer_size; in ct_systimer_callback()
77 position / period_size != ti->position / period_size) { in ct_systimer_callback()
79 ti->position = position; in ct_systimer_callback()
85 spin_lock_irqsave(&ti->lock, flags); in ct_systimer_callback()
86 if (ti->running) in ct_systimer_callback()
87 mod_timer(&ti->timer, jiffies + interval); in ct_systimer_callback()
88 spin_unlock_irqrestore(&ti->lock, flags); in ct_systimer_callback()
91 static void ct_systimer_init(struct ct_timer_instance *ti) in ct_systimer_init() argument
93 timer_setup(&ti->timer, ct_systimer_callback, 0); in ct_systimer_init()
96 static void ct_systimer_start(struct ct_timer_instance *ti) in ct_systimer_start() argument
98 struct snd_pcm_runtime *runtime = ti->substream->runtime; in ct_systimer_start()
101 spin_lock_irqsave(&ti->lock, flags); in ct_systimer_start()
102 ti->running = 1; in ct_systimer_start()
103 mod_timer(&ti->timer, in ct_systimer_start()
106 spin_unlock_irqrestore(&ti->lock, flags); in ct_systimer_start()
109 static void ct_systimer_stop(struct ct_timer_instance *ti) in ct_systimer_stop() argument
113 spin_lock_irqsave(&ti->lock, flags); in ct_systimer_stop()
114 ti->running = 0; in ct_systimer_stop()
115 del_timer(&ti->timer); in ct_systimer_stop()
116 spin_unlock_irqrestore(&ti->lock, flags); in ct_systimer_stop()
119 static void ct_systimer_prepare(struct ct_timer_instance *ti) in ct_systimer_prepare() argument
121 ct_systimer_stop(ti); in ct_systimer_prepare()
122 try_to_del_timer_sync(&ti->timer); in ct_systimer_prepare()
181 struct ct_timer_instance *ti; in ct_xfitimer_reprogram() local
195 list_for_each_entry(ti, &atimer->running_head, running_list) { in ct_xfitimer_reprogram()
196 if (ti->frag_count > diff) in ct_xfitimer_reprogram()
197 ti->frag_count -= diff; in ct_xfitimer_reprogram()
202 period_size = ti->substream->runtime->period_size; in ct_xfitimer_reprogram()
203 rate = ti->substream->runtime->rate; in ct_xfitimer_reprogram()
204 pos = ti->substream->ops->pointer(ti->substream); in ct_xfitimer_reprogram()
205 if (pos / period_size != ti->position / period_size) { in ct_xfitimer_reprogram()
206 ti->need_update = 1; in ct_xfitimer_reprogram()
207 ti->position = pos; in ct_xfitimer_reprogram()
212 ti->frag_count = div_u64((u64)pos * CT_TIMER_FREQ + in ct_xfitimer_reprogram()
215 if (ti->need_update && !can_update) in ct_xfitimer_reprogram()
217 if (ti->frag_count < min_intr) in ct_xfitimer_reprogram()
218 min_intr = ti->frag_count; in ct_xfitimer_reprogram()
231 struct ct_timer_instance *ti; in ct_xfitimer_check_period() local
235 list_for_each_entry(ti, &atimer->instance_head, instance_list) { in ct_xfitimer_check_period()
236 if (ti->running && ti->need_update) { in ct_xfitimer_check_period()
237 ti->need_update = 0; in ct_xfitimer_check_period()
238 ti->apcm->interrupt(ti->apcm); in ct_xfitimer_check_period()
263 static void ct_xfitimer_prepare(struct ct_timer_instance *ti) in ct_xfitimer_prepare() argument
265 ti->frag_count = ti->substream->runtime->period_size; in ct_xfitimer_prepare()
266 ti->running = 0; in ct_xfitimer_prepare()
267 ti->need_update = 0; in ct_xfitimer_prepare()
289 static void ct_xfitimer_start(struct ct_timer_instance *ti) in ct_xfitimer_start() argument
291 struct ct_timer *atimer = ti->timer_base; in ct_xfitimer_start()
295 if (list_empty(&ti->running_list)) in ct_xfitimer_start()
297 ti->running = 1; in ct_xfitimer_start()
298 ti->need_update = 0; in ct_xfitimer_start()
299 list_add(&ti->running_list, &atimer->running_head); in ct_xfitimer_start()
304 static void ct_xfitimer_stop(struct ct_timer_instance *ti) in ct_xfitimer_stop() argument
306 struct ct_timer *atimer = ti->timer_base; in ct_xfitimer_stop()
310 list_del_init(&ti->running_list); in ct_xfitimer_stop()
311 ti->running = 0; in ct_xfitimer_stop()
336 struct ct_timer_instance *ti; in ct_timer_instance_new() local
338 ti = kzalloc(sizeof(*ti), GFP_KERNEL); in ct_timer_instance_new()
339 if (!ti) in ct_timer_instance_new()
341 spin_lock_init(&ti->lock); in ct_timer_instance_new()
342 INIT_LIST_HEAD(&ti->instance_list); in ct_timer_instance_new()
343 INIT_LIST_HEAD(&ti->running_list); in ct_timer_instance_new()
344 ti->timer_base = atimer; in ct_timer_instance_new()
345 ti->apcm = apcm; in ct_timer_instance_new()
346 ti->substream = apcm->substream; in ct_timer_instance_new()
348 atimer->ops->init(ti); in ct_timer_instance_new()
351 list_add(&ti->instance_list, &atimer->instance_head); in ct_timer_instance_new()
354 return ti; in ct_timer_instance_new()
357 void ct_timer_prepare(struct ct_timer_instance *ti) in ct_timer_prepare() argument
359 if (ti->timer_base->ops->prepare) in ct_timer_prepare()
360 ti->timer_base->ops->prepare(ti); in ct_timer_prepare()
361 ti->position = 0; in ct_timer_prepare()
362 ti->running = 0; in ct_timer_prepare()
365 void ct_timer_start(struct ct_timer_instance *ti) in ct_timer_start() argument
367 struct ct_timer *atimer = ti->timer_base; in ct_timer_start()
368 atimer->ops->start(ti); in ct_timer_start()
371 void ct_timer_stop(struct ct_timer_instance *ti) in ct_timer_stop() argument
373 struct ct_timer *atimer = ti->timer_base; in ct_timer_stop()
374 atimer->ops->stop(ti); in ct_timer_stop()
377 void ct_timer_instance_free(struct ct_timer_instance *ti) in ct_timer_instance_free() argument
379 struct ct_timer *atimer = ti->timer_base; in ct_timer_instance_free()
381 atimer->ops->stop(ti); /* to be sure */ in ct_timer_instance_free()
383 atimer->ops->free_instance(ti); in ct_timer_instance_free()
386 list_del(&ti->instance_list); in ct_timer_instance_free()
389 kfree(ti); in ct_timer_instance_free()