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 */
40 s32 encoder_buffer_size
;
41 s32 encoder_buffer_color_depth
;
46 struct mcu_msg_init_response
{
47 struct mcu_msg_header header
;
51 struct create_channel_param
{
52 enum mcu_msg_version version
;
62 u16 constraint_set_flags
;
67 u32 log2_max_frame_num
;
68 u32 temporal_mvp_enable
;
69 u32 enable_reordering
;
85 u32 encoder_buffer_offset
;
86 u32 encoder_buffer_enabled
;
94 u8 max_transfo_depth_inter
;
95 u8 max_transfo_depth_intra
;
100 /* rate control param */
101 u32 rate_control_mode
;
102 u32 initial_rem_delay
;
115 u16 golden_ref_frequency
;
116 u32 rate_control_option
;
120 u32 maxpicturesize
[3];
133 u32 subframe_latency
;
134 u32 lda_control_mode
;
139 u32 max_num_merge_cand
;
142 struct mcu_msg_create_channel
{
143 struct mcu_msg_header header
;
151 struct mcu_msg_create_channel_response
{
152 struct mcu_msg_header header
;
159 u32 int_buffers_count
;
160 u32 int_buffers_size
;
161 u32 rec_buffers_count
;
162 u32 rec_buffers_size
;
167 struct mcu_msg_destroy_channel
{
168 struct mcu_msg_header header
;
172 struct mcu_msg_destroy_channel_response
{
173 struct mcu_msg_header header
;
177 struct mcu_msg_push_buffers_internal_buffer
{
183 struct mcu_msg_push_buffers_internal
{
184 struct mcu_msg_header header
;
187 struct mcu_msg_push_buffers_internal_buffer buffer
[] __counted_by(num_buffers
);
190 struct mcu_msg_put_stream_buffer
{
191 struct mcu_msg_header header
;
200 struct mcu_msg_encode_frame
{
201 struct mcu_msg_header header
;
205 u32 encoding_options
;
206 #define AL_OPT_USE_QP_TABLE BIT(0)
207 #define AL_OPT_FORCE_LOAD BIT(1)
208 #define AL_OPT_USE_L2 BIT(2)
209 #define AL_OPT_DISABLE_INTRA BIT(3)
210 #define AL_OPT_DEPENDENT_SLICES BIT(4)
218 #define AL_OPT_SCENE_CHANGE BIT(0)
219 #define AL_OPT_RESTART_GOP BIT(1)
220 #define AL_OPT_USE_LONG_TERM BIT(2)
221 #define AL_OPT_UPDATE_PARAMS BIT(3)
223 /* u32 scene_change_delay (optional) */
224 /* rate control param (optional) */
225 /* gop param (optional) */
226 /* dynamic resolution params (optional) */
236 struct mcu_msg_encode_frame_response
{
237 struct mcu_msg_header header
;
239 u64 dst_handle
; /* see mcu_msg_put_stream_buffer */
240 u64 user_param
; /* see mcu_msg_encode_frame */
241 u64 src_handle
; /* see mcu_msg_encode_frame */
244 u32 initial_removal_delay
;
245 u32 dpb_output_delay
;
255 u32 partition_table_offset
;
256 s32 partition_table_size
;
263 #define AL_ENC_SLICE_TYPE_B 0
264 #define AL_ENC_SLICE_TYPE_P 1
265 #define AL_ENC_SLICE_TYPE_I 2
281 union mcu_msg_response
{
282 struct mcu_msg_header header
;
283 struct mcu_msg_init_response init
;
284 struct mcu_msg_create_channel_response create_channel
;
285 struct mcu_msg_destroy_channel_response destroy_channel
;
286 struct mcu_msg_encode_frame_response encode_frame
;
289 ssize_t
allegro_encode_config_blob(u32
*dst
, struct create_channel_param
*param
);
290 ssize_t
allegro_decode_config_blob(struct create_channel_param
*param
,
291 struct mcu_msg_create_channel_response
*msg
,
294 int allegro_decode_mail(void *msg
, u32
*src
);
295 ssize_t
allegro_encode_mail(u32
*dst
, void *msg
);