Repository navigation
Expand file tree
/
Copy pathtimer.c
More file actions
126 lines (100 loc) · 2.58 KB
/
Copy pathtimer.c
File metadata and controls
126 lines (100 loc) · 2.58 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2016 Intel Corporation. All rights reserved.
//
// Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
#include <sof/audio/component_ext.h>
#include <sof/drivers/interrupt.h>
#include <sof/drivers/timer.h>
#include <sof/lib/clk.h>
#include <sof/lib/memory.h>
#include <sof/platform.h>
#include <ipc/stream.h>
#include <errno.h>
#include <stdint.h>
#ifndef __ZEPHYR__
void platform_timer_start(struct timer *timer)
{
//nothing to do on BDW & HSW 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);
}
#endif /* __ZEPHYR__ */
/* 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 = k_cycle_get_64() - posn->wallclock;
posn->wallclock_hz = clock_get_freq(PLATFORM_DEFAULT_CLOCK);
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 HSW */
*wallclock = k_cycle_get_64();
}
#ifndef __ZEPHYR__
int timer_register(struct timer *timer, void (*handler)(void *arg), void *arg)
{
int ret;
switch (timer->id) {
case TIMER0:
case TIMER1:
case TIMER2:
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);
}
#endif /* __ZEPHYR__ */