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 #ifndef MMAL_MSG_H
  27 #define MMAL_MSG_H
  28 
  29 #define VC_MMAL_VER 15
  30 #define VC_MMAL_MIN_VER 10
  31 #define VC_MMAL_SERVER_NAME  MAKE_FOURCC("mmal")
  32 
  33 
  34 #define MMAL_MSG_MAX_SIZE 512
  35 
  36 #define MMAL_MSG_MAX_PAYLOAD 488
  37 
  38 #include "mmal-msg-common.h"
  39 #include "mmal-msg-format.h"
  40 #include "mmal-msg-port.h"
  41 
  42 enum mmal_msg_type {
  43         MMAL_MSG_TYPE_QUIT = 1,
  44         MMAL_MSG_TYPE_SERVICE_CLOSED,
  45         MMAL_MSG_TYPE_GET_VERSION,
  46         MMAL_MSG_TYPE_COMPONENT_CREATE,
  47         MMAL_MSG_TYPE_COMPONENT_DESTROY,        
  48         MMAL_MSG_TYPE_COMPONENT_ENABLE,
  49         MMAL_MSG_TYPE_COMPONENT_DISABLE,
  50         MMAL_MSG_TYPE_PORT_INFO_GET,
  51         MMAL_MSG_TYPE_PORT_INFO_SET,
  52         MMAL_MSG_TYPE_PORT_ACTION,              
  53         MMAL_MSG_TYPE_BUFFER_FROM_HOST,
  54         MMAL_MSG_TYPE_BUFFER_TO_HOST,
  55         MMAL_MSG_TYPE_GET_STATS,
  56         MMAL_MSG_TYPE_PORT_PARAMETER_SET,
  57         MMAL_MSG_TYPE_PORT_PARAMETER_GET,       
  58         MMAL_MSG_TYPE_EVENT_TO_HOST,
  59         MMAL_MSG_TYPE_GET_CORE_STATS_FOR_PORT,
  60         MMAL_MSG_TYPE_OPAQUE_ALLOCATOR,
  61         MMAL_MSG_TYPE_CONSUME_MEM,
  62         MMAL_MSG_TYPE_LMK,                      
  63         MMAL_MSG_TYPE_OPAQUE_ALLOCATOR_DESC,
  64         MMAL_MSG_TYPE_DRM_GET_LHS32,
  65         MMAL_MSG_TYPE_DRM_GET_TIME,
  66         MMAL_MSG_TYPE_BUFFER_FROM_HOST_ZEROLEN,
  67         MMAL_MSG_TYPE_PORT_FLUSH,               
  68         MMAL_MSG_TYPE_HOST_LOG,
  69         MMAL_MSG_TYPE_MSG_LAST
  70 };
  71 
  72 
  73 enum mmal_msg_port_action_type {
  74         MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0,  
  75         MMAL_MSG_PORT_ACTION_TYPE_ENABLE,       
  76         MMAL_MSG_PORT_ACTION_TYPE_DISABLE,      
  77         MMAL_MSG_PORT_ACTION_TYPE_FLUSH,        
  78         MMAL_MSG_PORT_ACTION_TYPE_CONNECT,      
  79         MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT,   
  80         MMAL_MSG_PORT_ACTION_TYPE_SET_REQUIREMENTS, 
  81 };
  82 
  83 struct mmal_msg_header {
  84         u32 magic;
  85         u32 type;       
  86 
  87         
  88         u32 control_service;
  89 
  90         u32 context;    
  91         u32 status;     
  92         u32 padding;
  93 };
  94 
  95 
  96 struct mmal_msg_version {
  97         u32 flags;
  98         u32 major;
  99         u32 minor;
 100         u32 minimum;
 101 };
 102 
 103 
 104 struct mmal_msg_component_create {
 105         u32 client_component;   
 106         char name[128];
 107         u32 pid;                
 108 };
 109 
 110 
 111 struct mmal_msg_component_create_reply {
 112         u32 status;     
 113 
 114 
 115         u32 component_handle; 
 116         u32 input_num;        
 117         u32 output_num;       
 118         u32 clock_num;        
 119 };
 120 
 121 
 122 struct mmal_msg_component_destroy {
 123         u32 component_handle;
 124 };
 125 
 126 struct mmal_msg_component_destroy_reply {
 127         u32 status; 
 128 };
 129 
 130 
 131 struct mmal_msg_component_enable {
 132         u32 component_handle;
 133 };
 134 
 135 struct mmal_msg_component_enable_reply {
 136         u32 status; 
 137 };
 138 
 139 
 140 struct mmal_msg_component_disable {
 141         u32 component_handle;
 142 };
 143 
 144 struct mmal_msg_component_disable_reply {
 145         u32 status; 
 146 };
 147 
 148 
 149 struct mmal_msg_port_info_get {
 150         u32 component_handle;  
 151         u32 port_type;         
 152         u32 index;             
 153 };
 154 
 155 
 156 struct mmal_msg_port_info_get_reply {
 157         u32 status;             
 158         u32 component_handle;   
 159         u32 port_type;          
 160         u32 port_index;         
 161         s32 found;              
 162         u32 port_handle;        
 163         struct mmal_port port;
 164         struct mmal_es_format format; 
 165         union mmal_es_specific_format es; 
 166         u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE]; 
 167 };
 168 
 169 
 170 struct mmal_msg_port_info_set {
 171         u32 component_handle;
 172         u32 port_type;          
 173         u32 port_index;         
 174         struct mmal_port port;
 175         struct mmal_es_format format;
 176         union mmal_es_specific_format es;
 177         u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
 178 };
 179 
 180 
 181 struct mmal_msg_port_info_set_reply {
 182         u32 status;
 183         u32 component_handle;   
 184         u32 port_type;          
 185         u32 index;              
 186         s32 found;              
 187         u32 port_handle;        
 188         struct mmal_port port;
 189         struct mmal_es_format format;
 190         union mmal_es_specific_format es;
 191         u8 extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
 192 };
 193 
 194 
 195 struct mmal_msg_port_action_port {
 196         u32 component_handle;
 197         u32 port_handle;
 198         u32 action;             
 199         struct mmal_port port;
 200 };
 201 
 202 
 203 struct mmal_msg_port_action_handle {
 204         u32 component_handle;
 205         u32 port_handle;
 206         u32 action;             
 207         u32 connect_component_handle;
 208         u32 connect_port_handle;
 209 };
 210 
 211 struct mmal_msg_port_action_reply {
 212         u32 status;     
 213 };
 214 
 215 
 216 
 217 
 218 #define MMAL_VC_SHORT_DATA 128
 219 
 220 
 221 #define MMAL_BUFFER_HEADER_FLAG_EOS                    BIT(0)
 222 
 223 #define MMAL_BUFFER_HEADER_FLAG_FRAME_START            BIT(1)
 224 
 225 #define MMAL_BUFFER_HEADER_FLAG_FRAME_END              BIT(2)
 226 
 227 #define MMAL_BUFFER_HEADER_FLAG_FRAME                  \
 228         (MMAL_BUFFER_HEADER_FLAG_FRAME_START | \
 229          MMAL_BUFFER_HEADER_FLAG_FRAME_END)
 230 
 231 #define MMAL_BUFFER_HEADER_FLAG_KEYFRAME               BIT(3)
 232 
 233 
 234 
 235 
 236 #define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY          BIT(4)
 237 
 238 
 239 
 240 
 241 #define MMAL_BUFFER_HEADER_FLAG_CONFIG                 BIT(5)
 242 
 243 #define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED              BIT(6)
 244 
 245 #define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO          BIT(7)
 246 
 247 
 248 
 249 
 250 #define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT              BIT(8)
 251 
 252 #define MMAL_BUFFER_HEADER_FLAG_CORRUPTED              BIT(9)
 253 
 254 #define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED    BIT(10)
 255 
 256 struct mmal_driver_buffer {
 257         u32 magic;
 258         u32 component_handle;
 259         u32 port_handle;
 260         u32 client_context;
 261 };
 262 
 263 
 264 struct mmal_buffer_header {
 265         u32 next;       
 266         u32 priv;       
 267         u32 cmd;
 268         u32 data;
 269         u32 alloc_size;
 270         u32 length;
 271         u32 offset;
 272         u32 flags;
 273         s64 pts;
 274         s64 dts;
 275         u32 type;
 276         u32 user_data;
 277 };
 278 
 279 struct mmal_buffer_header_type_specific {
 280         union {
 281                 struct {
 282                 u32 planes;
 283                 u32 offset[4];
 284                 u32 pitch[4];
 285                 u32 flags;
 286                 } video;
 287         } u;
 288 };
 289 
 290 struct mmal_msg_buffer_from_host {
 291         
 292 
 293 
 294 
 295 
 296 
 297         
 298         struct mmal_driver_buffer drvbuf;
 299 
 300         
 301         struct mmal_driver_buffer drvbuf_ref;
 302         struct mmal_buffer_header buffer_header; 
 303         struct mmal_buffer_header_type_specific buffer_header_type_specific;
 304         s32 is_zero_copy;
 305         s32 has_reference;
 306 
 307         
 308         u32 payload_in_message;
 309         u8 short_data[MMAL_VC_SHORT_DATA];
 310 };
 311 
 312 
 313 
 314 #define MMAL_WORKER_PORT_PARAMETER_SPACE      96
 315 
 316 struct mmal_msg_port_parameter_set {
 317         u32 component_handle;   
 318         u32 port_handle;        
 319         u32 id;                 
 320         u32 size;               
 321         u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE];
 322 };
 323 
 324 struct mmal_msg_port_parameter_set_reply {
 325         u32 status;     
 326 
 327 
 328 };
 329 
 330 
 331 
 332 struct mmal_msg_port_parameter_get {
 333         u32 component_handle;   
 334         u32 port_handle;        
 335         u32 id;                 
 336         u32 size;               
 337 };
 338 
 339 struct mmal_msg_port_parameter_get_reply {
 340         u32 status;             
 341         u32 id;                 
 342         u32 size;               
 343         u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE];
 344 };
 345 
 346 
 347 #define MMAL_WORKER_EVENT_SPACE 256
 348 
 349 struct mmal_msg_event_to_host {
 350         u32 client_component;   
 351 
 352         u32 port_type;
 353         u32 port_num;
 354 
 355         u32 cmd;
 356         u32 length;
 357         u8 data[MMAL_WORKER_EVENT_SPACE];
 358         u32 delayed_buffer;
 359 };
 360 
 361 
 362 struct mmal_msg {
 363         
 364         struct mmal_msg_header h;
 365         
 366         union {
 367                 struct mmal_msg_version version;
 368 
 369                 struct mmal_msg_component_create component_create;
 370                 struct mmal_msg_component_create_reply component_create_reply;
 371 
 372                 struct mmal_msg_component_destroy component_destroy;
 373                 struct mmal_msg_component_destroy_reply component_destroy_reply;
 374 
 375                 struct mmal_msg_component_enable component_enable;
 376                 struct mmal_msg_component_enable_reply component_enable_reply;
 377 
 378                 struct mmal_msg_component_disable component_disable;
 379                 struct mmal_msg_component_disable_reply component_disable_reply;
 380 
 381                 struct mmal_msg_port_info_get port_info_get;
 382                 struct mmal_msg_port_info_get_reply port_info_get_reply;
 383 
 384                 struct mmal_msg_port_info_set port_info_set;
 385                 struct mmal_msg_port_info_set_reply port_info_set_reply;
 386 
 387                 struct mmal_msg_port_action_port port_action_port;
 388                 struct mmal_msg_port_action_handle port_action_handle;
 389                 struct mmal_msg_port_action_reply port_action_reply;
 390 
 391                 struct mmal_msg_buffer_from_host buffer_from_host;
 392 
 393                 struct mmal_msg_port_parameter_set port_parameter_set;
 394                 struct mmal_msg_port_parameter_set_reply
 395                         port_parameter_set_reply;
 396                 struct mmal_msg_port_parameter_get
 397                         port_parameter_get;
 398                 struct mmal_msg_port_parameter_get_reply
 399                         port_parameter_get_reply;
 400 
 401                 struct mmal_msg_event_to_host event_to_host;
 402 
 403                 u8 payload[MMAL_MSG_MAX_PAYLOAD];
 404         } u;
 405 };
 406 #endif