linux/drivers/staging/media/allegro-dvt/allegro-mail.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2/*
   3 * Copyright (C) 2019 Pengutronix, Michael Tretter <kernel@pengutronix.de>
   4 *
   5 * Allegro VCU firmware mailbox mail definitions
   6 */
   7
   8#ifndef ALLEGRO_MAIL_H
   9#define ALLEGRO_MAIL_H
  10
  11#include <linux/kernel.h>
  12
  13enum mcu_msg_type {
  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,
  21};
  22
  23const char *msg_type_name(enum mcu_msg_type type);
  24
  25struct mcu_msg_header {
  26        u16 length;             /* length of the body in bytes */
  27        u16 type;
  28} __attribute__ ((__packed__));
  29
  30struct mcu_msg_init_request {
  31        struct mcu_msg_header header;
  32        u32 reserved0;          /* maybe a unused channel id */
  33        u32 suballoc_dma;
  34        u32 suballoc_size;
  35        s32 l2_cache[3];
  36} __attribute__ ((__packed__));
  37
  38struct mcu_msg_init_response {
  39        struct mcu_msg_header header;
  40        u32 reserved0;
  41} __attribute__ ((__packed__));
  42
  43struct create_channel_param {
  44        u16 width;
  45        u16 height;
  46        u32 format;
  47        u32 colorspace;
  48        u32 src_mode;
  49        u8 profile;
  50        u16 constraint_set_flags;
  51        s8 codec;
  52        u16 level;
  53        u16 tier;
  54        u32 sps_param;
  55        u32 pps_param;
  56
  57        u32 enc_option;
  58#define AL_OPT_WPP                      BIT(0)
  59#define AL_OPT_TILE                     BIT(1)
  60#define AL_OPT_LF                       BIT(2)
  61#define AL_OPT_LF_X_SLICE               BIT(3)
  62#define AL_OPT_LF_X_TILE                BIT(4)
  63#define AL_OPT_SCL_LST                  BIT(5)
  64#define AL_OPT_CONST_INTRA_PRED         BIT(6)
  65#define AL_OPT_QP_TAB_RELATIVE          BIT(7)
  66#define AL_OPT_FIX_PREDICTOR            BIT(8)
  67#define AL_OPT_CUSTOM_LDA               BIT(9)
  68#define AL_OPT_ENABLE_AUTO_QP           BIT(10)
  69#define AL_OPT_ADAPT_AUTO_QP            BIT(11)
  70#define AL_OPT_TRANSFO_SKIP             BIT(13)
  71#define AL_OPT_FORCE_REC                BIT(15)
  72#define AL_OPT_FORCE_MV_OUT             BIT(16)
  73#define AL_OPT_FORCE_MV_CLIP            BIT(17)
  74#define AL_OPT_LOWLAT_SYNC              BIT(18)
  75#define AL_OPT_LOWLAT_INT               BIT(19)
  76#define AL_OPT_RDO_COST_MODE            BIT(20)
  77
  78        s8 beta_offset;
  79        s8 tc_offset;
  80        u16 reserved10;
  81        u32 unknown11;
  82        u32 unknown12;
  83        u16 num_slices;
  84        u16 prefetch_auto;
  85        u32 prefetch_mem_offset;
  86        u32 prefetch_mem_size;
  87        u16 clip_hrz_range;
  88        u16 clip_vrt_range;
  89        u16 me_range[4];
  90        u8 max_cu_size;
  91        u8 min_cu_size;
  92        u8 max_tu_size;
  93        u8 min_tu_size;
  94        u8 max_transfo_depth_inter;
  95        u8 max_transfo_depth_intra;
  96        u16 reserved20;
  97        u32 entropy_mode;
  98        u32 wp_mode;
  99
 100        /* rate control param */
 101        u32 rate_control_mode;
 102        u32 initial_rem_delay;
 103        u32 cpb_size;
 104        u16 framerate;
 105        u16 clk_ratio;
 106        u32 target_bitrate;
 107        u32 max_bitrate;
 108        u16 initial_qp;
 109        u16 min_qp;
 110        u16 max_qp;
 111        s16 ip_delta;
 112        s16 pb_delta;
 113        u16 golden_ref;
 114        u16 golden_delta;
 115        u16 golden_ref_frequency;
 116        u32 rate_control_option;
 117
 118        /* gop param */
 119        u32 gop_ctrl_mode;
 120        u32 freq_idr;
 121        u32 freq_lt;
 122        u32 gdr_mode;
 123        u16 gop_length;
 124        u8 num_b;
 125        u8 freq_golden_ref;
 126
 127        u32 subframe_latency;
 128        u32 lda_control_mode;
 129        u32 unknown41;
 130} __attribute__ ((__packed__));
 131
 132struct mcu_msg_create_channel {
 133        struct mcu_msg_header header;
 134        u32 user_id;
 135        struct create_channel_param param;
 136} __attribute__ ((__packed__));
 137
 138struct mcu_msg_create_channel_response {
 139        struct mcu_msg_header header;
 140        u32 channel_id;
 141        u32 user_id;
 142        u32 options;
 143        u32 num_core;
 144        u32 pps_param;
 145        u32 int_buffers_count;
 146        u32 int_buffers_size;
 147        u32 rec_buffers_count;
 148        u32 rec_buffers_size;
 149        u32 reserved;
 150        u32 error_code;
 151} __attribute__ ((__packed__));
 152
 153struct mcu_msg_destroy_channel {
 154        struct mcu_msg_header header;
 155        u32 channel_id;
 156} __attribute__ ((__packed__));
 157
 158struct mcu_msg_destroy_channel_response {
 159        struct mcu_msg_header header;
 160        u32 channel_id;
 161} __attribute__ ((__packed__));
 162
 163struct mcu_msg_push_buffers_internal_buffer {
 164        u32 dma_addr;
 165        u32 mcu_addr;
 166        u32 size;
 167} __attribute__ ((__packed__));
 168
 169struct mcu_msg_push_buffers_internal {
 170        struct mcu_msg_header header;
 171        u32 channel_id;
 172        struct mcu_msg_push_buffers_internal_buffer buffer[];
 173} __attribute__ ((__packed__));
 174
 175struct mcu_msg_put_stream_buffer {
 176        struct mcu_msg_header header;
 177        u32 channel_id;
 178        u32 dma_addr;
 179        u32 mcu_addr;
 180        u32 size;
 181        u32 offset;
 182        u64 stream_id;
 183} __attribute__ ((__packed__));
 184
 185struct mcu_msg_encode_frame {
 186        struct mcu_msg_header header;
 187        u32 channel_id;
 188        u32 reserved;
 189
 190        u32 encoding_options;
 191#define AL_OPT_USE_QP_TABLE             BIT(0)
 192#define AL_OPT_FORCE_LOAD               BIT(1)
 193#define AL_OPT_USE_L2                   BIT(2)
 194#define AL_OPT_DISABLE_INTRA            BIT(3)
 195#define AL_OPT_DEPENDENT_SLICES         BIT(4)
 196
 197        s16 pps_qp;
 198        u16 padding;
 199        u64 user_param;
 200        u64 src_handle;
 201
 202        u32 request_options;
 203#define AL_OPT_SCENE_CHANGE             BIT(0)
 204#define AL_OPT_RESTART_GOP              BIT(1)
 205#define AL_OPT_USE_LONG_TERM            BIT(2)
 206#define AL_OPT_UPDATE_PARAMS            BIT(3)
 207
 208        /* u32 scene_change_delay (optional) */
 209        /* rate control param (optional) */
 210        /* gop param (optional) */
 211        u32 src_y;
 212        u32 src_uv;
 213        u32 stride;
 214        u32 ep2;
 215        u64 ep2_v;
 216} __attribute__ ((__packed__));
 217
 218struct mcu_msg_encode_frame_response {
 219        struct mcu_msg_header header;
 220        u32 channel_id;
 221        u64 stream_id;          /* see mcu_msg_put_stream_buffer */
 222        u64 user_param;         /* see mcu_msg_encode_frame */
 223        u64 src_handle;         /* see mcu_msg_encode_frame */
 224        u16 skip;
 225        u16 is_ref;
 226        u32 initial_removal_delay;
 227        u32 dpb_output_delay;
 228        u32 size;
 229        u32 frame_tag_size;
 230        s32 stuffing;
 231        s32 filler;
 232        u16 num_column;
 233        u16 num_row;
 234        u16 qp;
 235        u8 num_ref_idx_l0;
 236        u8 num_ref_idx_l1;
 237        u32 partition_table_offset;
 238        s32 partition_table_size;
 239        u32 sum_complex;
 240        s32 tile_width[4];
 241        s32 tile_height[22];
 242        u32 error_code;
 243
 244        u32 slice_type;
 245#define AL_ENC_SLICE_TYPE_B             0
 246#define AL_ENC_SLICE_TYPE_P             1
 247#define AL_ENC_SLICE_TYPE_I             2
 248
 249        u32 pic_struct;
 250        u8 is_idr;
 251        u8 is_first_slice;
 252        u8 is_last_slice;
 253        u8 reserved;
 254        u16 pps_qp;
 255        u16 reserved1;
 256        u32 reserved2;
 257} __attribute__ ((__packed__));
 258
 259union mcu_msg_response {
 260        struct mcu_msg_header header;
 261        struct mcu_msg_init_response init;
 262        struct mcu_msg_create_channel_response create_channel;
 263        struct mcu_msg_destroy_channel_response destroy_channel;
 264        struct mcu_msg_encode_frame_response encode_frame;
 265};
 266
 267#endif
 268