forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer.c
More file actions
112 lines (93 loc) · 2.35 KB
/
timer.c
File metadata and controls
112 lines (93 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright 2019 NXP
//
// Author: Daniel Baluta <daniel.baluta@nxp.com>
#include <sof/audio/component_ext.h>
#include <rtos/interrupt.h>
#include <rtos/timer.h>
#include <sof/lib/memory.h>
#include <sof/platform.h>
#include <ipc/stream.h>
#include <errno.h>
#include <stdint.h>
void platform_timer_start(struct timer *timer)
{
//nothing to do on IMX for cpu timer
}
void platform_timer_stop(struct timer *timer)
{
arch_timer_disable(timer);
}
int64_t platform_timer_set(struct timer *timer, uint64_t ticks)
{
return arch_timer_set(timer, ticks);
}
void platform_timer_clear(struct timer *timer)
{
arch_timer_clear(timer);
}
uint64_t platform_timer_get(struct timer *timer)
{
return arch_timer_get_system(timer);
}
/* IRQs off in arch_timer_get_system() */
uint64_t platform_timer_get_atomic(struct timer *timer)
{
return arch_timer_get_system(timer);
}
/* get timestamp for host stream DMA position */
void platform_host_timestamp(struct comp_dev *host,
struct sof_ipc_stream_posn *posn)
{
int err;
/* get host position */
err = comp_position(host, posn);
if (err == 0)
posn->flags |= SOF_TIME_HOST_VALID | SOF_TIME_HOST_64;
}
/* get timestamp for DAI stream DMA position */
void platform_dai_timestamp(struct comp_dev *dai,
struct sof_ipc_stream_posn *posn)
{
int err;
/* get DAI position */
err = comp_position(dai, posn);
if (err == 0)
posn->flags |= SOF_TIME_DAI_VALID;
/* get SSP wallclock - DAI sets this to stream start value */
posn->wallclock = timer_get_system(timer_get()) - posn->wallclock;
posn->flags |= SOF_TIME_WALL_VALID | SOF_TIME_WALL_64;
}
/* get current wallclock for componnent */
void platform_dai_wallclock(struct comp_dev *dai, uint64_t *wallclock)
{
/* only 1 wallclock on imx8 */
*wallclock = timer_get_system(timer_get());
}
int timer_register(struct timer *timer, void(*handler)(void *arg), void *arg)
{
int ret;
switch (timer->id) {
case TIMER0:
case TIMER1:
ret = arch_timer_register(timer, handler, arg);
break;
default:
ret = -EINVAL;
break;
}
return ret;
}
void timer_unregister(struct timer *timer, void *arg)
{
interrupt_unregister(timer->irq, arg);
}
void timer_enable(struct timer *timer, void *arg, int core)
{
interrupt_enable(timer->irq, arg);
}
void timer_disable(struct timer *timer, void *arg, int core)
{
interrupt_disable(timer->irq, arg);
}