1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2019 Pengutronix, Michael Tretter <kernel@pengutronix.de>
5 * Allegro VCU firmware mailbox mail definitions
11 #include <linux/kernel.h>
14 MCU_MSG_TYPE_INIT = 0x0000,
15 MCU_MSG_TYPE_CREATE_CHANNEL = 0x0005,
16 MCU_MSG_TYPE_DESTROY_CHANNEL = 0x0006,
17 MCU_MSG_TYPE_ENCODE_FRAME = 0x0007,
18 MCU_MSG_TYPE_PUT_STREAM_BUFFER = 0x0012,
19 MCU_MSG_TYPE_PUSH_BUFFER_INTERMEDIATE = 0x000e,
20 MCU_MSG_TYPE_PUSH_BUFFER_REFERENCE = 0x000f,
23 enum mcu_msg_version {
24 MCU_MSG_VERSION_2018_2,
25 MCU_MSG_VERSION_2019_2,
28 const char *msg_type_name(enum mcu_msg_type type);
30 struct mcu_msg_header {
31 enum mcu_msg_type type;
32 enum mcu_msg_version version;
35 struct mcu_msg_init_request {
36 struct mcu_msg_header header;
37 u32 reserved0; /* maybe a unused channel id */
43 struct mcu_msg_init_response {
44 struct mcu_msg_header header;
48 struct create_channel_param {
49 enum mcu_msg_version version;
59 u16 constraint_set_flags;
64 u32 log2_max_frame_num;
65 u32 temporal_mvp_enable;
66 u32 enable_reordering;
82 u32 prefetch_mem_offset;
83 u32 prefetch_mem_size;
91 u8 max_transfo_depth_inter;
92 u8 max_transfo_depth_intra;
97 /* rate control param */
98 u32 rate_control_mode;
99 u32 initial_rem_delay;
112 u16 golden_ref_frequency;
113 u32 rate_control_option;
117 u32 maxpicturesize[3];
130 u32 subframe_latency;
131 u32 lda_control_mode;
136 u32 max_num_merge_cand;
139 struct mcu_msg_create_channel {
140 struct mcu_msg_header header;
148 struct mcu_msg_create_channel_response {
149 struct mcu_msg_header header;
156 u32 int_buffers_count;
157 u32 int_buffers_size;
158 u32 rec_buffers_count;
159 u32 rec_buffers_size;
164 struct mcu_msg_destroy_channel {
165 struct mcu_msg_header header;
169 struct mcu_msg_destroy_channel_response {
170 struct mcu_msg_header header;
174 struct mcu_msg_push_buffers_internal_buffer {
180 struct mcu_msg_push_buffers_internal {
181 struct mcu_msg_header header;
184 struct mcu_msg_push_buffers_internal_buffer buffer[];
187 struct mcu_msg_put_stream_buffer {
188 struct mcu_msg_header header;
197 struct mcu_msg_encode_frame {
198 struct mcu_msg_header header;
202 u32 encoding_options;
203 #define AL_OPT_USE_QP_TABLE BIT(0)
204 #define AL_OPT_FORCE_LOAD BIT(1)
205 #define AL_OPT_USE_L2 BIT(2)
206 #define AL_OPT_DISABLE_INTRA BIT(3)
207 #define AL_OPT_DEPENDENT_SLICES BIT(4)
215 #define AL_OPT_SCENE_CHANGE BIT(0)
216 #define AL_OPT_RESTART_GOP BIT(1)
217 #define AL_OPT_USE_LONG_TERM BIT(2)
218 #define AL_OPT_UPDATE_PARAMS BIT(3)
220 /* u32 scene_change_delay (optional) */
221 /* rate control param (optional) */
222 /* gop param (optional) */
223 /* dynamic resolution params (optional) */
233 struct mcu_msg_encode_frame_response {
234 struct mcu_msg_header header;
236 u64 stream_id; /* see mcu_msg_put_stream_buffer */
237 u64 user_param; /* see mcu_msg_encode_frame */
238 u64 src_handle; /* see mcu_msg_encode_frame */
241 u32 initial_removal_delay;
242 u32 dpb_output_delay;
252 u32 partition_table_offset;
253 s32 partition_table_size;
260 #define AL_ENC_SLICE_TYPE_B 0
261 #define AL_ENC_SLICE_TYPE_P 1
262 #define AL_ENC_SLICE_TYPE_I 2
278 union mcu_msg_response {
279 struct mcu_msg_header header;
280 struct mcu_msg_init_response init;
281 struct mcu_msg_create_channel_response create_channel;
282 struct mcu_msg_destroy_channel_response destroy_channel;
283 struct mcu_msg_encode_frame_response encode_frame;
286 ssize_t allegro_encode_config_blob(u32 *dst, struct create_channel_param *param);
287 ssize_t allegro_decode_config_blob(struct create_channel_param *param,
288 struct mcu_msg_create_channel_response *msg,
291 int allegro_decode_mail(void *msg, u32 *src);
292 ssize_t allegro_encode_mail(u32 *dst, void *msg);