Sound Open Firmware
Loading...
Searching...
No Matches
notifier.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2016 Intel Corporation. All rights reserved.
4 *
5 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6 */
7
8#ifndef __SOF_LIB_NOTIFIER_H__
9#define __SOF_LIB_NOTIFIER_H__
10
11#include <rtos/bit.h>
12#include <sof/list.h>
13#include <rtos/spinlock.h>
14#include <rtos/sof.h>
15#include <stdint.h>
16
17/* notifier target core masks */
18#define NOTIFIER_TARGET_CORE_MASK(x) (1 << (x))
19#define NOTIFIER_TARGET_CORE_LOCAL NOTIFIER_TARGET_CORE_MASK(cpu_get_id())
20#define NOTIFIER_TARGET_CORE_ALL_MASK 0xFFFFFFFF
21
23#define NOTIFIER_FLAG_AGGREGATE BIT(0)
24
26 NOTIFIER_ID_CPU_FREQ = 0, /* struct clock_notify_data * */
27 NOTIFIER_ID_SSP_FREQ, /* struct clock_notify_data * */
28 NOTIFIER_ID_KPB_CLIENT_EVT, /* struct kpb_event_data * */
29 NOTIFIER_ID_DMA_DOMAIN_CHANGE, /* struct dma_chan_data * */
30 NOTIFIER_ID_DMA_COPY, /* struct dma_cb_data* */
31 NOTIFIER_ID_DMA_IRQ, /* struct dma_chan_data * */
32 NOTIFIER_ID_DAI_TRIGGER, /* struct dai_group * */
33 NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE, /* struct mic_privacy_settings * */
35};
36
37struct notify {
38 struct list_item list[NOTIFIER_ID_COUNT]; /* list of callback handles */
39 struct k_spinlock lock; /* list lock */
40};
41
43 const void *caller;
45 uint32_t data_size;
46 void *data;
47};
48
49#ifdef CLK_SSP
50#define NOTIFIER_CLK_CHANGE_ID(clk) \
51 ((clk) == CLK_SSP ? NOTIFIER_ID_SSP_FREQ : NOTIFIER_ID_CPU_FREQ)
52#else
53#define NOTIFIER_CLK_CHANGE_ID(clk) NOTIFIER_ID_CPU_FREQ
54#endif
55
56struct notify **arch_notify_get(void);
57
58typedef void (*notifier_callback_t)(void *receiver_data, enum notify_id event_type,
59 void *caller_data);
60
76int notifier_register(void *receiver_data, void *caller_id_filter, enum notify_id event_type,
77 notifier_callback_t callback, uint32_t flags);
78
82void notifier_unregister(void *receiver_data_filter, void *caller_id_filter, enum notify_id type);
83
87void notifier_unregister_all(void *receiver_data_filter, void *caller_id_filter);
88
90
91/* data_size is required to manage cache coherency for notifications
92 * across cores.
93 */
94void notifier_event(const void *caller_id, enum notify_id event_type, uint32_t core_mask,
95 void *caller_data, uint32_t data_size);
96
98
100
101static inline struct notify_data *notify_data_get(void)
102{
103 return sof_get()->notify_data;
104}
105
106#endif /* __SOF_LIB_NOTIFIER_H__ */
#define list_item(item, type, member)
Definition list.h:80
void notifier_unregister(void *receiver_data_filter, void *caller_id_filter, enum notify_id type)
Unregister all callbacks matching that arguments tuple.
int notifier_register(void *receiver_data, void *caller_id_filter, enum notify_id event_type, notifier_callback_t callback, uint32_t flags)
Register a callback to be run when event 'type' happens.
void notifier_event(const void *caller_id, enum notify_id event_type, uint32_t core_mask, void *caller_data, uint32_t data_size)
void notifier_notify_remote(void)
void(* notifier_callback_t)(void *receiver_data, enum notify_id event_type, void *caller_data)
Definition notifier.h:58
static struct notify_data * notify_data_get(void)
Definition notifier.h:101
notify_id
Definition notifier.h:25
@ NOTIFIER_ID_DMA_DOMAIN_CHANGE
Definition notifier.h:29
@ NOTIFIER_ID_KPB_CLIENT_EVT
Definition notifier.h:28
@ NOTIFIER_ID_SSP_FREQ
Definition notifier.h:27
@ NOTIFIER_ID_COUNT
Definition notifier.h:34
@ NOTIFIER_ID_DAI_TRIGGER
Definition notifier.h:32
@ NOTIFIER_ID_DMA_COPY
Definition notifier.h:30
@ NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE
Definition notifier.h:33
@ NOTIFIER_ID_DMA_IRQ
Definition notifier.h:31
@ NOTIFIER_ID_CPU_FREQ
Definition notifier.h:26
void notifier_unregister_all(void *receiver_data_filter, void *caller_id_filter)
Unregister callbacks matching the arguments for every notify_id.
struct notify ** arch_notify_get(void)
void free_system_notify(void)
void init_system_notify(struct sof *sof)
struct sof * sof_get(void)
Definition notifier.h:42
uint32_t data_size
Definition notifier.h:45
const void * caller
Definition notifier.h:43
enum notify_id type
Definition notifier.h:44
void * data
Definition notifier.h:46
Definition notifier.h:37
struct k_spinlock lock
Definition notifier.h:39
struct list_item list[NOTIFIER_ID_COUNT]
Definition notifier.h:38
General firmware context.
Definition sof.h:44
struct notify_data * notify_data
Definition sof.h:84
uint32_t type
Definition tlv.h:0