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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright(c) 2021-2022 Intel Corporation. All rights reserved.
*
* Authors: Cezary Rojewski <cezary.rojewski@intel.com>
* Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
*/
#ifndef __SOUND_SOC_INTEL_AVS_MSGS_H
#define __SOUND_SOC_INTEL_AVS_MSGS_H
struct avs_dev;
#define AVS_MAILBOX_SIZE 4096
enum avs_msg_target {
AVS_FW_GEN_MSG = 0,
AVS_MOD_MSG = 1
};
enum avs_msg_direction {
AVS_MSG_REQUEST = 0,
AVS_MSG_REPLY = 1
};
enum avs_global_msg_type {
AVS_GLB_LOAD_MULTIPLE_MODULES = 15,
AVS_GLB_UNLOAD_MULTIPLE_MODULES = 16,
AVS_GLB_LOAD_LIBRARY = 24,
AVS_GLB_NOTIFICATION = 27,
};
union avs_global_msg {
u64 val;
struct {
union {
u32 primary;
struct {
u32 rsvd:24;
u32 global_msg_type:5;
u32 msg_direction:1;
u32 msg_target:1;
};
/* module loading */
struct {
u32 mod_cnt:8;
} load_multi_mods;
/* library loading */
struct {
u32 dma_id:5;
u32 rsvd:11;
u32 lib_id:4;
} load_lib;
};
union {
u32 val;
} ext;
};
} __packed;
struct avs_tlv {
u32 type;
u32 length;
u32 value[];
} __packed;
union avs_module_msg {
u64 val;
struct {
union {
u32 primary;
struct {
u32 module_id:16;
u32 instance_id:8;
u32 module_msg_type:5;
u32 msg_direction:1;
u32 msg_target:1;
};
};
union {
u32 val;
} ext;
};
} __packed;
union avs_reply_msg {
u64 val;
struct {
union {
u32 primary;
struct {
u32 status:24;
u32 global_msg_type:5;
u32 msg_direction:1;
u32 msg_target:1;
};
};
union {
u32 val;
/* module loading */
struct {
u32 err_mod_id:16;
} load_multi_mods;
} ext;
};
} __packed;
enum avs_notify_msg_type {
AVS_NOTIFY_PHRASE_DETECTED = 4,
AVS_NOTIFY_RESOURCE_EVENT = 5,
AVS_NOTIFY_FW_READY = 8,
AVS_NOTIFY_MODULE_EVENT = 12,
};
union avs_notify_msg {
u64 val;
struct {
union {
u32 primary;
struct {
u32 rsvd:16;
u32 notify_msg_type:8;
u32 global_msg_type:5;
u32 msg_direction:1;
u32 msg_target:1;
};
};
union {
u32 val;
} ext;
};
} __packed;
#define AVS_MSG(hdr) { .val = hdr }
#define AVS_GLOBAL_REQUEST(msg_type) \
{ \
.global_msg_type = AVS_GLB_##msg_type, \
.msg_direction = AVS_MSG_REQUEST, \
.msg_target = AVS_FW_GEN_MSG, \
}
#define AVS_MODULE_REQUEST(msg_type) \
{ \
.module_msg_type = AVS_MOD_##msg_type, \
.msg_direction = AVS_MSG_REQUEST, \
.msg_target = AVS_MOD_MSG, \
}
#define AVS_NOTIFICATION(msg_type) \
{ \
.notify_msg_type = AVS_NOTIFY_##msg_type,\
.global_msg_type = AVS_GLB_NOTIFICATION,\
.msg_direction = AVS_MSG_REPLY, \
.msg_target = AVS_FW_GEN_MSG, \
}
#define avs_msg_is_reply(hdr) \
({ \
union avs_reply_msg __msg = AVS_MSG(hdr); \
__msg.msg_direction == AVS_MSG_REPLY && \
__msg.global_msg_type != AVS_GLB_NOTIFICATION; \
})
/* Notification types */
struct avs_notify_voice_data {
u16 kpd_score;
u16 reserved;
} __packed;
struct avs_notify_res_data {
u32 resource_type;
u32 resource_id;
u32 event_type;
u32 reserved;
u32 data[6];
} __packed;
struct avs_notify_mod_data {
u32 module_instance_id;
u32 event_id;
u32 data_size;
u32 data[];
} __packed;
/* Code loading messages */
int avs_ipc_load_modules(struct avs_dev *adev, u16 *mod_ids, u32 num_mod_ids);
int avs_ipc_unload_modules(struct avs_dev *adev, u16 *mod_ids, u32 num_mod_ids);
int avs_ipc_load_library(struct avs_dev *adev, u32 dma_id, u32 lib_id);
#endif /* __SOUND_SOC_INTEL_AVS_MSGS_H */
|