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 NOTIFIER_ID_CPU_FREQ = 0, /* struct clock_notify_data * */
24 NOTIFIER_ID_SSP_FREQ, /* struct clock_notify_data * */
25 NOTIFIER_ID_KPB_CLIENT_EVT, /* struct kpb_event_data * */
26 NOTIFIER_ID_DMA_DOMAIN_CHANGE, /* struct dma_chan_data * */
27 NOTIFIER_ID_DMA_COPY, /* struct dma_cb_data* */
28 NOTIFIER_ID_DMA_IRQ, /* struct dma_chan_data * */
29 NOTIFIER_ID_DAI_TRIGGER, /* struct dai_group * */
30 NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE, /* struct mic_privacy_settings * */
31 NOTIFIER_ID_VAD, /* int * (WEBRTC_VAD_SPEECH / WEBRTC_VAD_SILENCE) */
33};
34
35struct notify {
36 struct list_item list[NOTIFIER_ID_COUNT]; /* list of callback handles */
37 struct k_spinlock lock; /* list lock */
38};
39
41 const void *caller;
43 uint32_t data_size;
44 void *data;
45};
46
47#ifdef CLK_SSP
48#define NOTIFIER_CLK_CHANGE_ID(clk) \
49 ((clk) == CLK_SSP ? NOTIFIER_ID_SSP_FREQ : NOTIFIER_ID_CPU_FREQ)
50#else
51#define NOTIFIER_CLK_CHANGE_ID(clk) NOTIFIER_ID_CPU_FREQ
52#endif
53
54struct notify **arch_notify_get(void);
55
56typedef void (*notifier_callback_t)(void *receiver_data, enum notify_id event_type,
57 void *caller_data);
58
73int notifier_register(void *receiver_data, void *caller_id_filter, enum notify_id event_type,
74 notifier_callback_t callback);
75
79void notifier_unregister(void *receiver_data_filter, void *caller_id_filter, enum notify_id type);
80
84void notifier_unregister_all(void *receiver_data_filter, void *caller_id_filter);
85
87
88/* data_size is required to manage cache coherency for notifications
89 * across cores.
90 */
91void notifier_event(const void *caller_id, enum notify_id event_type, uint32_t core_mask,
92 void *caller_data, uint32_t data_size);
93
95
97
98static inline struct notify_data *notify_data_get(void)
99{
100 return sof_get()->notify_data;
101}
102
103#endif /* __SOF_LIB_NOTIFIER_H__ */
uint32_t type
Message type, symmetric to the incoming request.
Definition header.h:8
void notifier_unregister(void *receiver_data_filter, void *caller_id_filter, enum notify_id type)
Unregister all callbacks matching that arguments tuple.
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:56
static struct notify_data * notify_data_get(void)
Definition notifier.h:98
notify_id
Definition notifier.h:22
@ NOTIFIER_ID_DMA_DOMAIN_CHANGE
Definition notifier.h:26
@ NOTIFIER_ID_VAD
Definition notifier.h:31
@ NOTIFIER_ID_KPB_CLIENT_EVT
Definition notifier.h:25
@ NOTIFIER_ID_SSP_FREQ
Definition notifier.h:24
@ NOTIFIER_ID_COUNT
Definition notifier.h:32
@ NOTIFIER_ID_DAI_TRIGGER
Definition notifier.h:29
@ NOTIFIER_ID_DMA_COPY
Definition notifier.h:27
@ NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE
Definition notifier.h:30
@ NOTIFIER_ID_DMA_IRQ
Definition notifier.h:28
@ NOTIFIER_ID_CPU_FREQ
Definition notifier.h:23
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)
int notifier_register(void *receiver_data, void *caller_id_filter, enum notify_id event_type, notifier_callback_t callback)
Register a callback to be run when event 'type' happens.
void free_system_notify(void)
void init_system_notify(struct sof *sof)
Sound Open Firmware global runtime context.
struct sof * sof_get(void)
Get the global Sound Open Firmware runtime instance pointer.
RTOS spinlock primitives and initialization.
Definition list.h:16
Definition notifier.h:40
uint32_t data_size
Definition notifier.h:43
const void * caller
Definition notifier.h:41
enum notify_id type
Definition notifier.h:42
void * data
Definition notifier.h:44
Definition notifier.h:35
struct k_spinlock lock
Definition notifier.h:37
struct list_item list[NOTIFIER_ID_COUNT]
Definition notifier.h:36
General firmware context.
Definition sof.h:50
struct notify_data * notify_data
Definition sof.h:90