My Project
/home/jvcleave/Desktop/RASPBERRY_PI/userland/interface/mmal/vc/mmal_vc_msgs.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2012, Broadcom Europe Ltd
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007     * Redistributions of source code must retain the above copyright
00008       notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright
00010       notice, this list of conditions and the following disclaimer in the
00011       documentation and/or other materials provided with the distribution.
00012     * Neither the name of the copyright holder nor the
00013       names of its contributors may be used to endorse or promote products
00014       derived from this software without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
00020 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00023 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 */
00027 
00028 #ifndef MMAL_VC_MSGS_H
00029 #define MMAL_VC_MSGS_H
00030 
00036 #include "interface/vcos/vcos.h"
00037 #include "interface/mmal/mmal.h"
00038 #include "mmal_vc_api.h"
00039 
00040 #define MMAL_CONTROL_FOURCC() VCHIQ_MAKE_FOURCC('m','m','a','l')
00041 
00042 /* Major version indicates binary backwards compatiblity */
00043 #define WORKER_VER_MAJOR   15
00044 #define WORKER_VER_MINIMUM 10
00045 /* Minor version is not used normally.
00046  */
00047 #define WORKER_VER_MINOR   1
00048 #ifndef WORKER_VER_MINIMUM
00049 #endif
00050 
00051 #define VIDEOCORE_PREFIX "vc"
00052 
00053 #define MMAL_MAX_PORTS     8                 
00055 #define MMAL_WORKER_MAX_MSG_LEN  512
00056 #define MMAL_VC_CORE_STATS_NAME_MAX      32  
00061 #define MMAL_WORKER_MSG_LEN  28
00062 
00066 #define MMAL_FORMAT_EXTRADATA_MAX_SIZE 128
00067 
00070 #define MMAL_VC_SHORT_DATA 128
00071 
00075 /* Please update the array in mmal_vc_msgnames.c if this is updated.
00076  */
00077 typedef enum {
00078    MMAL_WORKER_QUIT = 1,
00079    MMAL_WORKER_SERVICE_CLOSED,
00080    MMAL_WORKER_GET_VERSION,
00081    MMAL_WORKER_COMPONENT_CREATE,
00082    MMAL_WORKER_COMPONENT_DESTROY,
00083    MMAL_WORKER_COMPONENT_ENABLE,
00084    MMAL_WORKER_COMPONENT_DISABLE,
00085    MMAL_WORKER_PORT_INFO_GET,
00086    MMAL_WORKER_PORT_INFO_SET,
00087    MMAL_WORKER_PORT_ACTION,
00088    MMAL_WORKER_BUFFER_FROM_HOST,
00089    MMAL_WORKER_BUFFER_TO_HOST,
00090    MMAL_WORKER_GET_STATS,
00091    MMAL_WORKER_PORT_PARAMETER_SET,
00092    MMAL_WORKER_PORT_PARAMETER_GET,
00093    MMAL_WORKER_EVENT_TO_HOST,
00094    MMAL_WORKER_GET_CORE_STATS_FOR_PORT,
00095    MMAL_WORKER_OPAQUE_ALLOCATOR,
00096    /* VC debug mode only - due to security, denial of service implications */
00097    MMAL_WORKER_CONSUME_MEM,
00098    MMAL_WORKER_LMK,
00099    MMAL_WORKER_OPAQUE_ALLOCATOR_DESC,
00100    MMAL_WORKER_DRM_GET_LHS32,
00101    MMAL_WORKER_DRM_GET_TIME,
00102    MMAL_WORKER_BUFFER_FROM_HOST_ZEROLEN,
00103    MMAL_WORKER_PORT_FLUSH,
00104    MMAL_WORKER_HOST_LOG,
00105    MMAL_WORKER_MSG_LAST
00106 } MMAL_WORKER_CMD_T;
00107 
00110 typedef struct
00111 {
00112    uint32_t magic;
00113    uint32_t msgid;
00114    struct MMAL_CONTROL_SERVICE_T *control_service;       
00116    union {
00117       struct MMAL_WAITER_T *waiter;    
00118    } u;
00119 
00120    MMAL_STATUS_T status;            
00121    /* Make sure this structure is 64 bit aligned */
00122    uint32_t dummy;
00123 } mmal_worker_msg_header;
00124 
00125 /* Make sure mmal_worker_msg_header will preserve 64 bits alignment */
00126 vcos_static_assert(!(sizeof(mmal_worker_msg_header) & 0x7));
00127 
00128 /* Message structures sent to worker thread.
00129  */
00130 
00134 typedef struct
00135 {
00136    mmal_worker_msg_header header;
00137 } mmal_worker_service_closed;
00138 vcos_static_assert(sizeof(mmal_worker_service_closed) <= MMAL_WORKER_MSG_LEN);
00139 
00141 typedef struct
00142 {
00143    mmal_worker_msg_header header;
00144    uint32_t flags;
00145    uint32_t major;
00146    uint32_t minor;
00147    uint32_t minimum;
00148 } mmal_worker_version;
00149 
00151 typedef struct
00152 {
00153    mmal_worker_msg_header header;
00154    void *client_component;             
00155    char name[128];
00156    uint32_t pid;                       
00157 } mmal_worker_component_create;
00158 
00162 typedef struct
00163 {
00164    mmal_worker_msg_header header;
00165    MMAL_STATUS_T status;
00166    uint32_t component_handle;          
00167    uint32_t input_num;                 
00168    uint32_t output_num;                
00169    uint32_t clock_num;                 
00170 } mmal_worker_component_create_reply;
00171 vcos_static_assert(sizeof(mmal_worker_component_create_reply) <= MMAL_WORKER_MAX_MSG_LEN);
00172 
00175 typedef struct
00176 {
00177    mmal_worker_msg_header header;
00178    uint32_t component_handle;          
00179 } mmal_worker_component_destroy;
00180 
00183 typedef struct
00184 {
00185    mmal_worker_msg_header header;
00186    uint32_t component_handle;          
00187 } mmal_worker_component_enable;
00188 
00191 typedef struct
00192 {
00193    mmal_worker_msg_header header;
00194    uint32_t component_handle;          
00195 } mmal_worker_component_disable;
00196 
00199 typedef struct
00200 {
00201    mmal_worker_msg_header header;
00202    uint32_t component_handle;          
00203    MMAL_PORT_TYPE_T port_type;         
00204    uint32_t index;                     
00205 } mmal_worker_port_info_get;
00206 vcos_static_assert(sizeof(mmal_worker_port_info_get) <= MMAL_WORKER_MAX_MSG_LEN);
00207 
00210 typedef struct
00211 {
00212    mmal_worker_msg_header header;
00213    uint32_t component_handle;          
00214    MMAL_PORT_TYPE_T port_type;         
00215    uint32_t index;                     
00216    MMAL_PORT_T port;
00217    MMAL_ES_FORMAT_T format;
00218    MMAL_ES_SPECIFIC_FORMAT_T es;
00219    uint8_t  extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
00220 } mmal_worker_port_info_set;
00221 vcos_static_assert(sizeof(mmal_worker_port_info_set) <= MMAL_WORKER_MAX_MSG_LEN);
00222 
00224 typedef struct
00225 {
00226    mmal_worker_msg_header header;
00227    MMAL_STATUS_T status;               
00228    uint32_t component_handle;          
00229    MMAL_PORT_TYPE_T port_type;         
00230    uint32_t index;                     
00231    int32_t found;                      
00232    uint32_t port_handle;               
00233    MMAL_PORT_T port;
00234    MMAL_ES_FORMAT_T format;
00235    MMAL_ES_SPECIFIC_FORMAT_T es;
00236    uint8_t  extradata[MMAL_FORMAT_EXTRADATA_MAX_SIZE];
00237 } mmal_worker_port_info;
00238 vcos_static_assert(sizeof(mmal_worker_port_info) <= MMAL_WORKER_MAX_MSG_LEN);
00239 
00240 typedef struct
00241 {
00242    mmal_worker_msg_header header;
00243    MMAL_STATUS_T status;
00244 } mmal_worker_reply;
00245 
00246 typedef struct
00247 {
00248    mmal_worker_msg_header header;
00249    MMAL_STATUS_T status;
00250    uint8_t secret[32];
00251 } mmal_worker_drm_get_lhs32_reply;
00252 vcos_static_assert(sizeof(mmal_worker_drm_get_lhs32_reply) <= MMAL_WORKER_MAX_MSG_LEN);
00253 
00254 typedef struct
00255 {
00256    mmal_worker_msg_header header;
00257    MMAL_STATUS_T status;
00258    uint32_t time;
00259 } mmal_worker_drm_get_time_reply;
00260 vcos_static_assert(sizeof(mmal_worker_drm_get_time_reply) <= MMAL_WORKER_MAX_MSG_LEN);
00261 
00263 enum MMAL_WORKER_PORT_ACTIONS
00264 {
00265    MMAL_WORKER_PORT_ACTION_UNKNOWN = 0,        
00266    MMAL_WORKER_PORT_ACTION_ENABLE,             
00267    MMAL_WORKER_PORT_ACTION_DISABLE,            
00268    MMAL_WORKER_PORT_ACTION_FLUSH,              
00269    MMAL_WORKER_PORT_ACTION_CONNECT,            
00270    MMAL_WORKER_PORT_ACTION_DISCONNECT,         
00271    MMAL_WORKER_PORT_ACTION_SET_REQUIREMENTS,   
00272    MMAL_WORKER_PORT_ACTION_MAX = 0x7fffffff    
00273 };
00274 
00277 typedef struct
00278 {
00279    mmal_worker_msg_header header;
00280    uint32_t component_handle;
00281    uint32_t port_handle;
00282    enum MMAL_WORKER_PORT_ACTIONS action;
00283 
00285    union {
00286       struct {
00287          MMAL_PORT_T port;
00288       } enable;
00289       struct {
00290          uint32_t component_handle;
00291          uint32_t port_handle;
00292       } connect;
00293    } param;
00294 
00295 } mmal_worker_port_action;
00296 vcos_static_assert(sizeof(mmal_worker_port_action) <= MMAL_WORKER_MAX_MSG_LEN);
00297 
00298 #define MMAL_WORKER_PORT_PARAMETER_SPACE      96
00299 
00300 #define MMAL_WORKER_PORT_PARAMETER_SET_MAX \
00301    (MMAL_WORKER_PORT_PARAMETER_SPACE*sizeof(uint32_t)+sizeof(MMAL_PARAMETER_HEADER_T))
00302 
00303 #define MMAL_WORKER_PORT_PARAMETER_GET_MAX   MMAL_WORKER_PORT_PARAMETER_SET_MAX
00304 
00307 typedef struct
00308 {
00309    mmal_worker_msg_header header;
00310    uint32_t component_handle;          
00311    uint32_t port_handle;               
00312    MMAL_PARAMETER_HEADER_T param;      
00313    uint32_t space[MMAL_WORKER_PORT_PARAMETER_SPACE];
00314 } mmal_worker_port_param_set;
00315 vcos_static_assert(sizeof(mmal_worker_port_param_set) <= MMAL_WORKER_MAX_MSG_LEN);
00316 
00319 typedef struct
00320 {
00321    mmal_worker_msg_header header;
00322    uint32_t component_handle;          
00323    uint32_t port_handle;               
00324    MMAL_PARAMETER_HEADER_T param;      
00325 } mmal_worker_port_param_get;
00326 vcos_static_assert(sizeof(mmal_worker_port_param_get) <= MMAL_WORKER_MAX_MSG_LEN);
00327 
00330 typedef struct
00331 {
00332    mmal_worker_msg_header header;
00333    MMAL_STATUS_T status;               
00334    MMAL_PARAMETER_HEADER_T param;      
00335    uint32_t space[MMAL_WORKER_PORT_PARAMETER_SPACE];
00336 } mmal_worker_port_param_get_reply;
00337 vcos_static_assert(sizeof(mmal_worker_port_param_get_reply) <= MMAL_WORKER_MAX_MSG_LEN);
00338 
00343 struct MMAL_DRIVER_BUFFER_T
00344 {
00345    uint32_t magic;
00346    uint32_t component_handle;    
00347    uint32_t port_handle;         
00350    struct MMAL_VC_CLIENT_BUFFER_CONTEXT_T *client_context;
00351 };
00352 
00358 typedef struct mmal_worker_buffer_from_host
00359 {
00360    mmal_worker_msg_header header;
00361 
00365    struct MMAL_DRIVER_BUFFER_T drvbuf;
00366 
00372    struct MMAL_DRIVER_BUFFER_T drvbuf_ref;
00373 
00375    MMAL_BUFFER_HEADER_T buffer_header;
00376    MMAL_BUFFER_HEADER_TYPE_SPECIFIC_T buffer_header_type_specific;
00377 
00378    MMAL_BOOL_T is_zero_copy;
00379    MMAL_BOOL_T has_reference;
00380 
00384    uint32_t payload_in_message;
00385    uint8_t short_data[MMAL_VC_SHORT_DATA];
00386 
00387 } mmal_worker_buffer_from_host;
00388 vcos_static_assert(sizeof(mmal_worker_buffer_from_host) <= MMAL_WORKER_MAX_MSG_LEN);
00389 
00393 #define MMAL_WORKER_EVENT_SPACE 256
00394 
00400 typedef struct mmal_worker_event_to_host
00401 {
00402    mmal_worker_msg_header header;
00403 
00404    struct MMAL_COMPONENT_T *client_component;
00405    uint32_t port_type;
00406    uint32_t port_num;
00407 
00408    uint32_t cmd;
00409    uint32_t length;
00410    uint8_t data[MMAL_WORKER_EVENT_SPACE];
00411    MMAL_BUFFER_HEADER_T *delayed_buffer;  /* Only used to remember buffer for bulk rx */
00412 } mmal_worker_event_to_host;
00413 vcos_static_assert(sizeof(mmal_worker_event_to_host) <= MMAL_WORKER_MAX_MSG_LEN);
00414 
00415 typedef struct
00416 {
00417    mmal_worker_msg_header header;
00418    MMAL_VC_STATS_T stats;
00419    uint32_t reset;
00420 } mmal_worker_stats;
00421 vcos_static_assert(sizeof(mmal_worker_stats) <= MMAL_WORKER_MAX_MSG_LEN);
00422 
00423 typedef enum {
00424    MMAL_WORKER_OPAQUE_MEM_ALLOC,
00425    MMAL_WORKER_OPAQUE_MEM_RELEASE,
00426    MMAL_WORKER_OPAQUE_MEM_ACQUIRE,
00427    MMAL_WORKER_OPAQUE_MEM_MAX = 0x7fffffff,
00428 } MMAL_WORKER_OPAQUE_MEM_OP;
00429 
00430 typedef struct
00431 {
00432    mmal_worker_msg_header header;
00433    MMAL_WORKER_OPAQUE_MEM_OP op;
00434    uint32_t handle;
00435    MMAL_STATUS_T status;
00436    char description[32];
00437 } mmal_worker_opaque_allocator;
00438 
00439 /*
00440  * Per-port core statistics
00441  */
00442 typedef struct
00443 {
00444    mmal_worker_msg_header header;
00445    uint32_t component_index;
00446    uint32_t port_index;
00447    MMAL_PORT_TYPE_T type;
00448    MMAL_CORE_STATS_DIR dir;
00449    MMAL_BOOL_T reset;
00450 } mmal_worker_get_core_stats_for_port;
00451 
00452 typedef struct
00453 {
00454    mmal_worker_msg_header header;
00455    MMAL_STATUS_T status;
00456    MMAL_STATS_RESULT_T result;
00457    MMAL_CORE_STATISTICS_T stats;
00458    char component_name[MMAL_VC_CORE_STATS_NAME_MAX];
00459 } mmal_worker_get_core_stats_for_port_reply;
00460 
00461 typedef struct
00462 {
00463    mmal_worker_msg_header header;
00464    MMAL_STATUS_T status;
00465    /* The amount of memory to reserve */
00466    uint32_t size;
00467    /* Handle to newly allocated memory or MEM_HANDLE_INVALD on failure */
00468    uint32_t handle;
00469 } mmal_worker_consume_mem;
00470 vcos_static_assert(sizeof(mmal_worker_consume_mem) <= MMAL_WORKER_MAX_MSG_LEN);
00471 
00472 typedef struct
00473 {
00474    mmal_worker_msg_header header;
00475    /* Message text to add to the circular buffer */
00476    char msg[MMAL_WORKER_MAX_MSG_LEN - sizeof(mmal_worker_msg_header)];
00477 } mmal_worker_host_log;
00478 vcos_static_assert(sizeof(mmal_worker_host_log) <= MMAL_WORKER_MAX_MSG_LEN);
00479 
00480 typedef struct
00481 {
00482    mmal_worker_msg_header header;
00483    /* The memory allocation size to pass to lmk, as if in a response to an
00484     * allocation for this amount of memory. */
00485    uint32_t alloc_size;
00486 } mmal_worker_lmk;
00487 vcos_static_assert(sizeof(mmal_worker_lmk) <= MMAL_WORKER_MAX_MSG_LEN);
00488 
00489 static inline void mmal_vc_buffer_header_to_msg(mmal_worker_buffer_from_host *msg,
00490                                                 MMAL_BUFFER_HEADER_T *header)
00491 {
00492    msg->buffer_header.cmd           = header->cmd;
00493    msg->buffer_header.offset        = header->offset;
00494    msg->buffer_header.length        = header->length;
00495    msg->buffer_header.flags         = header->flags;
00496    msg->buffer_header.pts           = header->pts;
00497    msg->buffer_header.dts           = header->dts;
00498    msg->buffer_header.alloc_size    = header->alloc_size;
00499    msg->buffer_header.data          = header->data;
00500    msg->buffer_header_type_specific = *header->type;
00501 }
00502 
00503 static inline void mmal_vc_msg_to_buffer_header(MMAL_BUFFER_HEADER_T *header,
00504                                                 mmal_worker_buffer_from_host *msg)
00505 {
00506    header->cmd    = msg->buffer_header.cmd;
00507    header->offset = msg->buffer_header.offset;
00508    header->length = msg->buffer_header.length;
00509    header->flags  = msg->buffer_header.flags;
00510    header->pts    = msg->buffer_header.pts;
00511    header->dts    = msg->buffer_header.dts;
00512    *header->type  = msg->buffer_header_type_specific;
00513 }
00514 
00515 #endif
00516 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines