forked from macchian/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifier.h
More file actions
108 lines (90 loc) · 3.33 KB
/
notifier.h
File metadata and controls
108 lines (90 loc) · 3.33 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
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2016 Intel Corporation. All rights reserved.
*
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
#ifndef __SOF_LIB_NOTIFIER_H__
#define __SOF_LIB_NOTIFIER_H__
#include <sof/bit.h>
#include <sof/list.h>
#include <sof/spinlock.h>
#include <sof/sof.h>
#include <stdint.h>
/* notifier target core masks */
#define NOTIFIER_TARGET_CORE_MASK(x) (1 << (x))
#define NOTIFIER_TARGET_CORE_LOCAL NOTIFIER_TARGET_CORE_MASK(cpu_get_id())
#define NOTIFIER_TARGET_CORE_ALL_MASK 0xFFFFFFFF
/** \brief Notifier flags. */
#define NOTIFIER_FLAG_AGGREGATE BIT(0)
enum notify_id {
NOTIFIER_ID_CPU_FREQ = 0, /* struct clock_notify_data * */
NOTIFIER_ID_SSP_FREQ, /* struct clock_notify_data * */
NOTIFIER_ID_KPB_CLIENT_EVT, /* struct kpb_event_data * */
NOTIFIER_ID_DMA_DOMAIN_CHANGE, /* struct dma_chan_data * */
NOTIFIER_ID_BUFFER_PRODUCE, /* struct buffer_cb_transact* */
NOTIFIER_ID_BUFFER_CONSUME, /* struct buffer_cb_transact* */
NOTIFIER_ID_BUFFER_FREE, /* struct buffer_cb_free* */
NOTIFIER_ID_DMA_COPY, /* struct dma_cb_data* */
NOTIFIER_ID_LL_POST_RUN, /* NULL */
NOTIFIER_ID_DMA_IRQ, /* struct dma_chan_data * */
NOTIFIER_ID_DAI_TRIGGER, /* struct dai_group * */
NOTIFIER_ID_COUNT
};
struct notify {
struct list_item list[NOTIFIER_ID_COUNT]; /* list of callback handles */
spinlock_t lock; /* list lock */
};
struct notify_data {
const void *caller;
enum notify_id type;
uint32_t data_size;
void *data;
};
#ifdef CLK_SSP
#define NOTIFIER_CLK_CHANGE_ID(clk) \
((clk) == CLK_SSP ? NOTIFIER_ID_SSP_FREQ : NOTIFIER_ID_CPU_FREQ)
#else
#define NOTIFIER_CLK_CHANGE_ID(clk) NOTIFIER_ID_CPU_FREQ
#endif
struct notify **arch_notify_get(void);
/** Register a callback to be run when event 'type' happens.
*
* The identifier for un-registration is the tuple (receiver_data,
* caller_id_filter, event_type), the callback argument is not part of
* it.
*
* caller_data argument from notifier_event()
*
* @param receiver_data private data passed to the callback.
* @param caller_id_filter optional, can be used to be notified only by
* some specific notifier_event() calls when not NULL.
* @param event_type list of callbacks to be added to
* @param callback callback function
* @param flags see NOTIFIER_FLAG_* above
*/
int notifier_register(void *receiver_data, void *caller_id_filter, enum notify_id event_type,
void (*callback)(void *receiver_data, enum notify_id event_type,
void *caller_data),
uint32_t flags);
/** Unregister all callbacks matching that arguments tuple. NULL acts
* as a wildcard.
*/
void notifier_unregister(void *receiver_data_filter, void *caller_id_filter, enum notify_id type);
/** Unregister callbacks matching the arguments for every notify_id.
* A NULL parameter acts as a wildcard.
*/
void notifier_unregister_all(void *receiver_data_filter, void *caller_id_filter);
void notifier_notify_remote(void);
/* data_size is required to manage cache coherency for notifications
* across cores.
*/
void notifier_event(const void *caller_id, enum notify_id event_type, uint32_t core_mask,
void *caller_data, uint32_t data_size);
void init_system_notify(struct sof *sof);
void free_system_notify(void);
static inline struct notify_data *notify_data_get(void)
{
return sof_get()->notify_data;
}
#endif /* __SOF_LIB_NOTIFIER_H__ */