| 1 | /* |
| 2 | Copyright (c) 2012, Broadcom Europe Ltd |
| 3 | All rights reserved. |
| 4 | |
| 5 | Redistribution and use in source and binary forms, with or without |
| 6 | modification, are permitted provided that the following conditions are met: |
| 7 | * Redistributions of source code must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above copyright |
| 10 | notice, this list of conditions and the following disclaimer in the |
| 11 | documentation and/or other materials provided with the distribution. |
| 12 | * Neither the name of the copyright holder nor the |
| 13 | names of its contributors may be used to endorse or promote products |
| 14 | derived from this software without specific prior written permission. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
| 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef MMAL_VC_MSGS_H |
| 29 | #define MMAL_VC_MSGS_H |
| 30 | |
| 31 | /** @file mmal_vc_msgs.h |
| 32 | * |
| 33 | * Private message definitions, defining the message API between |
| 34 | * the host and VideoCore. |
| 35 | */ |
| 36 | #include "interface/vcos/vcos.h" |
| 37 | #include "interface/mmal/mmal.h" |
| 38 | #include "mmal_vc_api.h" |
| 39 | |
| 40 | #define MMAL_CONTROL_FOURCC() VCHIQ_MAKE_FOURCC('m','m','a','l') |
| 41 | |
| 42 | /* Major version indicates binary backwards compatibility */ |
| 43 | #define WORKER_VER_MAJOR 16 |
| 44 | #define WORKER_VER_MINIMUM 10 |
| 45 | /* Minor version is not used normally. |
| 46 | */ |
| 47 | #define WORKER_VER_MINOR 1 |
| 48 | #ifndef WORKER_VER_MINIMUM |
| 49 | #endif |
| 50 | |
| 51 | #define VIDEOCORE_PREFIX "vc" |
| 52 | |
| 53 | #define MMAL_MAX_PORTS 8 /**< Max ports per component */ |
| 54 | |
| 55 | #define MMAL_WORKER_MAX_MSG_LEN 512 |
| 56 | #define MMAL_VC_CORE_STATS_NAME_MAX 32 /**< Length of the name in the core stats message */ |
| 57 | |
| 58 | /** A MMAL_CONTROL_SERVICE_T gets space for a single message. This |
| 59 | * is the space allocated for these messages. |
| 60 | */ |
| 61 | #define MMAL_WORKER_MSG_LEN 28 |
| 62 | |
| 63 | /** Maximum size of the format extradata. |
| 64 | * FIXME: should probably be made bigger and maybe be passed separately from the info. |
| 65 | */ |
| 66 | #define 128 |
| 67 | |
| 68 | /** Size of space reserved in a buffer message for short messages. |
| 69 | */ |
| 70 | #define MMAL_VC_SHORT_DATA 128 |
| 71 | |
| 72 | /** Message ids sent to worker thread. |
| 73 | */ |
| 74 | |
| 75 | /* Please update the array in mmal_vc_msgnames.c if this is updated. |
| 76 | */ |
| 77 | typedef enum { |
| 78 | MMAL_WORKER_QUIT = 1, |
| 79 | MMAL_WORKER_SERVICE_CLOSED, |
| 80 | MMAL_WORKER_GET_VERSION, |
| 81 | MMAL_WORKER_COMPONENT_CREATE, |
| 82 | MMAL_WORKER_COMPONENT_DESTROY, |
| 83 | MMAL_WORKER_COMPONENT_ENABLE, |
| 84 | MMAL_WORKER_COMPONENT_DISABLE, |
| 85 | MMAL_WORKER_PORT_INFO_GET, |
| 86 | MMAL_WORKER_PORT_INFO_SET, |
| 87 | MMAL_WORKER_PORT_ACTION, |
| 88 | MMAL_WORKER_BUFFER_FROM_HOST, |
| 89 | MMAL_WORKER_BUFFER_TO_HOST, |
| 90 | MMAL_WORKER_GET_STATS, |
| 91 | MMAL_WORKER_PORT_PARAMETER_SET, |
| 92 | MMAL_WORKER_PORT_PARAMETER_GET, |
| 93 | MMAL_WORKER_EVENT_TO_HOST, |
| 94 | MMAL_WORKER_GET_CORE_STATS_FOR_PORT, |
| 95 | MMAL_WORKER_OPAQUE_ALLOCATOR, |
| 96 | /* VC debug mode only - due to security, denial of service implications */ |
| 97 | MMAL_WORKER_CONSUME_MEM, |
| 98 | MMAL_WORKER_LMK, |
| 99 | MMAL_WORKER_OPAQUE_ALLOCATOR_DESC, |
| 100 | MMAL_WORKER_DRM_GET_LHS32, |
| 101 | MMAL_WORKER_DRM_GET_TIME, |
| 102 | MMAL_WORKER_BUFFER_FROM_HOST_ZEROLEN, |
| 103 | MMAL_WORKER_PORT_FLUSH, |
| 104 | MMAL_WORKER_HOST_LOG, |
| 105 | MMAL_WORKER_COMPACT, |
| 106 | MMAL_WORKER_MSG_LAST |
| 107 | } MMAL_WORKER_CMD_T; |
| 108 | |
| 109 | /** Every message has one of these at the start. |
| 110 | */ |
| 111 | typedef struct |
| 112 | { |
| 113 | uint32_t magic; |
| 114 | uint32_t msgid; |
| 115 | uint32_t control_service; /** Handle to the control service (unused) */ |
| 116 | |
| 117 | union { |
| 118 | uint32_t waiter; /** User-land wait structure, passed back */ |
| 119 | } u; |
| 120 | |
| 121 | MMAL_STATUS_T status; /** Result code, passed back */ |
| 122 | /* Make sure this structure is 64 bit aligned */ |
| 123 | uint32_t dummy; |
| 124 | } ; |
| 125 | |
| 126 | /* Make sure mmal_worker_msg_header will preserve 64 bits alignment */ |
| 127 | vcos_static_assert(!(sizeof(mmal_worker_msg_header) & 0x7)); |
| 128 | |
| 129 | /* Message structures sent to worker thread. |
| 130 | */ |
| 131 | |
| 132 | /** Tell the worker a service has closed. It should start to delete |
| 133 | * the associated components. |
| 134 | */ |
| 135 | typedef struct |
| 136 | { |
| 137 | mmal_worker_msg_header ; |
| 138 | } mmal_worker_service_closed; |
| 139 | vcos_static_assert(sizeof(mmal_worker_service_closed) <= MMAL_WORKER_MSG_LEN); |
| 140 | |
| 141 | /** Send from VC to host to report our version */ |
| 142 | typedef struct |
| 143 | { |
| 144 | mmal_worker_msg_header ; |
| 145 | uint32_t flags; |
| 146 | uint32_t major; |
| 147 | uint32_t minor; |
| 148 | uint32_t minimum; |
| 149 | } mmal_worker_version; |
| 150 | |
| 151 | /** Request component creation */ |
| 152 | typedef struct |
| 153 | { |
| 154 | mmal_worker_msg_header ; |
| 155 | uint32_t client_component; /** Client component */ |
| 156 | char name[128]; |
| 157 | uint32_t pid; /**< For debug */ |
| 158 | } mmal_worker_component_create; |
| 159 | |
| 160 | /** Reply to component-creation message. Reports back |
| 161 | * the number of ports. |
| 162 | */ |
| 163 | typedef struct |
| 164 | { |
| 165 | mmal_worker_msg_header ; |
| 166 | MMAL_STATUS_T status; |
| 167 | uint32_t component_handle; /** Handle on VideoCore for component */ |
| 168 | uint32_t input_num; /**< Number of input ports */ |
| 169 | uint32_t output_num; /**< Number of output ports */ |
| 170 | uint32_t clock_num; /**< Number of clock ports */ |
| 171 | } mmal_worker_component_create_reply; |
| 172 | vcos_static_assert(sizeof(mmal_worker_component_create_reply) <= MMAL_WORKER_MAX_MSG_LEN); |
| 173 | |
| 174 | /** Destroys a component |
| 175 | */ |
| 176 | typedef struct |
| 177 | { |
| 178 | mmal_worker_msg_header ; |
| 179 | uint32_t component_handle; /**< which component */ |
| 180 | } mmal_worker_component_destroy; |
| 181 | |
| 182 | /** Enables a component |
| 183 | */ |
| 184 | typedef struct |
| 185 | { |
| 186 | mmal_worker_msg_header ; |
| 187 | uint32_t component_handle; /**< which component */ |
| 188 | } mmal_worker_component_enable; |
| 189 | |
| 190 | /** Disable a component |
| 191 | */ |
| 192 | typedef struct |
| 193 | { |
| 194 | mmal_worker_msg_header ; |
| 195 | uint32_t component_handle; /**< Which component */ |
| 196 | } mmal_worker_component_disable; |
| 197 | |
| 198 | /** Component port info. Used to get port info. |
| 199 | */ |
| 200 | typedef struct |
| 201 | { |
| 202 | mmal_worker_msg_header ; |
| 203 | uint32_t component_handle; /**< Which component */ |
| 204 | MMAL_PORT_TYPE_T port_type; /**< Type of port */ |
| 205 | uint32_t index; /**< Which port of given type to get */ |
| 206 | } mmal_worker_port_info_get; |
| 207 | vcos_static_assert(sizeof(mmal_worker_port_info_get) <= MMAL_WORKER_MAX_MSG_LEN); |
| 208 | |
| 209 | typedef struct |
| 210 | { |
| 211 | MMAL_ES_TYPE_T type; /**< Type of the elementary stream */ |
| 212 | |
| 213 | MMAL_FOURCC_T encoding; /**< FourCC specifying the encoding of the elementary stream. |
| 214 | * See the \ref MmalEncodings "pre-defined encodings" for some |
| 215 | * examples. |
| 216 | */ |
| 217 | MMAL_FOURCC_T encoding_variant;/**< FourCC specifying the specific encoding variant of |
| 218 | * the elementary stream. See the \ref MmalEncodingVariants |
| 219 | * "pre-defined encoding variants" for some examples. |
| 220 | */ |
| 221 | |
| 222 | uint32_t es; /**< Type specific information for the elementary stream */ |
| 223 | |
| 224 | uint32_t bitrate; /**< Bitrate in bits per second */ |
| 225 | uint32_t flags; /**< Flags describing properties of the elementary stream. |
| 226 | * See \ref elementarystreamflags "Elementary stream flags". |
| 227 | */ |
| 228 | |
| 229 | uint32_t ; /**< Size of the codec specific data */ |
| 230 | uint32_t ; /**< Codec specific data */ |
| 231 | |
| 232 | } MMAL_VC_ES_FORMAT_T; |
| 233 | |
| 234 | typedef struct |
| 235 | { |
| 236 | uint32_t priv; /**< Private member used by the framework */ |
| 237 | uint32_t name; /**< Port name. Used for debugging purposes (Read Only) */ |
| 238 | |
| 239 | MMAL_PORT_TYPE_T type; /**< Type of the port (Read Only) */ |
| 240 | uint16_t index; /**< Index of the port in its type list (Read Only) */ |
| 241 | uint16_t index_all; /**< Index of the port in the list of all ports (Read Only) */ |
| 242 | |
| 243 | uint32_t is_enabled; /**< Indicates whether the port is enabled or not (Read Only) */ |
| 244 | uint32_t format; /**< Format of the elementary stream */ |
| 245 | |
| 246 | uint32_t buffer_num_min; /**< Minimum number of buffers the port requires (Read Only). |
| 247 | This is set by the component. */ |
| 248 | uint32_t buffer_size_min; /**< Minimum size of buffers the port requires (Read Only). |
| 249 | This is set by the component. */ |
| 250 | uint32_t buffer_alignment_min; /**< Minimum alignment requirement for the buffers (Read Only). |
| 251 | A value of zero means no special alignment requirements. |
| 252 | This is set by the component. */ |
| 253 | uint32_t buffer_num_recommended; /**< Number of buffers the port recommends for optimal performance (Read Only). |
| 254 | A value of zero means no special recommendation. |
| 255 | This is set by the component. */ |
| 256 | uint32_t buffer_size_recommended; /**< Size of buffers the port recommends for optimal performance (Read Only). |
| 257 | A value of zero means no special recommendation. |
| 258 | This is set by the component. */ |
| 259 | uint32_t buffer_num; /**< Actual number of buffers the port will use. |
| 260 | This is set by the client. */ |
| 261 | uint32_t buffer_size; /**< Actual maximum size of the buffers that will be sent |
| 262 | to the port. This is set by the client. */ |
| 263 | |
| 264 | uint32_t component; /**< Component this port belongs to (Read Only) */ |
| 265 | uint32_t userdata; /**< Field reserved for use by the client */ |
| 266 | |
| 267 | uint32_t capabilities; /**< Flags describing the capabilities of a port (Read Only). |
| 268 | * Bitwise combination of \ref portcapabilities "Port capabilities" |
| 269 | * values. |
| 270 | */ |
| 271 | |
| 272 | } MMAL_VC_PORT_T; |
| 273 | |
| 274 | /** Component port info. Used to set port info. |
| 275 | */ |
| 276 | typedef struct |
| 277 | { |
| 278 | mmal_worker_msg_header ; |
| 279 | uint32_t component_handle; /**< Which component */ |
| 280 | MMAL_PORT_TYPE_T port_type; /**< Type of port */ |
| 281 | uint32_t index; /**< Which port of given type to get */ |
| 282 | MMAL_VC_PORT_T port; |
| 283 | MMAL_VC_ES_FORMAT_T format; |
| 284 | MMAL_ES_SPECIFIC_FORMAT_T es; |
| 285 | uint8_t [MMAL_FORMAT_EXTRADATA_MAX_SIZE]; |
| 286 | } mmal_worker_port_info_set; |
| 287 | vcos_static_assert(sizeof(mmal_worker_port_info_set) <= MMAL_WORKER_MAX_MSG_LEN); |
| 288 | |
| 289 | /** Report port info back in response to a get / set. */ |
| 290 | typedef struct |
| 291 | { |
| 292 | mmal_worker_msg_header ; |
| 293 | MMAL_STATUS_T status; /**< Result of query */ |
| 294 | uint32_t component_handle; /**< Which component */ |
| 295 | MMAL_PORT_TYPE_T port_type; /**< Type of port */ |
| 296 | uint32_t index; /**< Which port of given type to get */ |
| 297 | int32_t found; /**< Did we find anything? */ |
| 298 | uint32_t port_handle; /**< Handle to use for this port */ |
| 299 | MMAL_VC_PORT_T port; |
| 300 | MMAL_VC_ES_FORMAT_T format; |
| 301 | MMAL_ES_SPECIFIC_FORMAT_T es; |
| 302 | uint8_t [MMAL_FORMAT_EXTRADATA_MAX_SIZE]; |
| 303 | } mmal_worker_port_info; |
| 304 | vcos_static_assert(sizeof(mmal_worker_port_info) <= MMAL_WORKER_MAX_MSG_LEN); |
| 305 | |
| 306 | typedef struct |
| 307 | { |
| 308 | mmal_worker_msg_header ; |
| 309 | MMAL_STATUS_T status; |
| 310 | } mmal_worker_reply; |
| 311 | |
| 312 | typedef struct |
| 313 | { |
| 314 | mmal_worker_msg_header ; |
| 315 | MMAL_STATUS_T status; |
| 316 | uint8_t secret[32]; |
| 317 | } mmal_worker_drm_get_lhs32_reply; |
| 318 | vcos_static_assert(sizeof(mmal_worker_drm_get_lhs32_reply) <= MMAL_WORKER_MAX_MSG_LEN); |
| 319 | |
| 320 | typedef struct |
| 321 | { |
| 322 | mmal_worker_msg_header ; |
| 323 | MMAL_STATUS_T status; |
| 324 | uint32_t time; |
| 325 | } mmal_worker_drm_get_time_reply; |
| 326 | vcos_static_assert(sizeof(mmal_worker_drm_get_time_reply) <= MMAL_WORKER_MAX_MSG_LEN); |
| 327 | |
| 328 | /** List of actions for a port */ |
| 329 | enum MMAL_WORKER_PORT_ACTIONS |
| 330 | { |
| 331 | MMAL_WORKER_PORT_ACTION_UNKNOWN = 0, /**< Unknown action */ |
| 332 | MMAL_WORKER_PORT_ACTION_ENABLE, /**< Enable a port */ |
| 333 | MMAL_WORKER_PORT_ACTION_DISABLE, /**< Disable a port */ |
| 334 | MMAL_WORKER_PORT_ACTION_FLUSH, /**< Flush a port */ |
| 335 | MMAL_WORKER_PORT_ACTION_CONNECT, /**< Connect 2 ports together */ |
| 336 | MMAL_WORKER_PORT_ACTION_DISCONNECT, /**< Disconnect 2 ports connected together */ |
| 337 | MMAL_WORKER_PORT_ACTION_SET_REQUIREMENTS, /**< Set buffer requirements */ |
| 338 | MMAL_WORKER_PORT_ACTION_MAX = 0x7fffffff /**< Make the enum 32bits */ |
| 339 | }; |
| 340 | |
| 341 | /** Trigger an action on a port. |
| 342 | */ |
| 343 | typedef struct |
| 344 | { |
| 345 | mmal_worker_msg_header ; |
| 346 | uint32_t component_handle; |
| 347 | uint32_t port_handle; |
| 348 | enum MMAL_WORKER_PORT_ACTIONS action; |
| 349 | |
| 350 | /** Action parameter */ |
| 351 | union { |
| 352 | struct { |
| 353 | MMAL_VC_PORT_T port; |
| 354 | } enable; |
| 355 | struct { |
| 356 | uint32_t component_handle; |
| 357 | uint32_t port_handle; |
| 358 | } connect; |
| 359 | } param; |
| 360 | |
| 361 | } mmal_worker_port_action; |
| 362 | vcos_static_assert(sizeof(mmal_worker_port_action) <= MMAL_WORKER_MAX_MSG_LEN); |
| 363 | |
| 364 | #define MMAL_WORKER_PORT_PARAMETER_SPACE 96 |
| 365 | |
| 366 | #define MMAL_WORKER_PORT_PARAMETER_SET_MAX \ |
| 367 | (MMAL_WORKER_PORT_PARAMETER_SPACE*sizeof(uint32_t)+sizeof(MMAL_PARAMETER_HEADER_T)) |
| 368 | |
| 369 | #define MMAL_WORKER_PORT_PARAMETER_GET_MAX MMAL_WORKER_PORT_PARAMETER_SET_MAX |
| 370 | |
| 371 | /** Component port parameter set. Doesn't include space for the parameter data. |
| 372 | */ |
| 373 | typedef struct |
| 374 | { |
| 375 | mmal_worker_msg_header ; |
| 376 | uint32_t component_handle; /**< Which component */ |
| 377 | uint32_t port_handle; /**< Which port */ |
| 378 | MMAL_PARAMETER_HEADER_T param; /**< Parameter ID and size */ |
| 379 | uint32_t space[MMAL_WORKER_PORT_PARAMETER_SPACE]; |
| 380 | } mmal_worker_port_param_set; |
| 381 | vcos_static_assert(sizeof(mmal_worker_port_param_set) <= MMAL_WORKER_MAX_MSG_LEN); |
| 382 | |
| 383 | /** Component port parameter get. |
| 384 | */ |
| 385 | typedef struct |
| 386 | { |
| 387 | mmal_worker_msg_header ; |
| 388 | uint32_t component_handle; /**< Which component */ |
| 389 | uint32_t port_handle; /**< Which port */ |
| 390 | MMAL_PARAMETER_HEADER_T param; /**< Parameter ID and size */ |
| 391 | uint32_t space[MMAL_WORKER_PORT_PARAMETER_SPACE]; |
| 392 | } mmal_worker_port_param_get; |
| 393 | vcos_static_assert(sizeof(mmal_worker_port_param_get) <= MMAL_WORKER_MAX_MSG_LEN); |
| 394 | |
| 395 | typedef struct |
| 396 | { |
| 397 | mmal_worker_msg_header ; |
| 398 | uint32_t component_handle; /**< Which component */ |
| 399 | uint32_t port_handle; /**< Which port */ |
| 400 | MMAL_PARAMETER_HEADER_T param; /**< Parameter ID and size */ |
| 401 | } mmal_worker_port_param_get_old; |
| 402 | |
| 403 | /** Component port parameter get reply. Doesn't include space for the parameter data. |
| 404 | */ |
| 405 | typedef struct |
| 406 | { |
| 407 | mmal_worker_msg_header ; |
| 408 | MMAL_STATUS_T status; /**< Status of mmal_port_parameter_get call */ |
| 409 | MMAL_PARAMETER_HEADER_T param; /**< Parameter ID and size */ |
| 410 | uint32_t space[MMAL_WORKER_PORT_PARAMETER_SPACE]; |
| 411 | } mmal_worker_port_param_get_reply; |
| 412 | vcos_static_assert(sizeof(mmal_worker_port_param_get_reply) <= MMAL_WORKER_MAX_MSG_LEN); |
| 413 | |
| 414 | /** Buffer header driver area structure. In the private area |
| 415 | * of a buffer header there is a driver area where we can |
| 416 | * put values. This structure defines the layout of that. |
| 417 | */ |
| 418 | struct MMAL_DRIVER_BUFFER_T |
| 419 | { |
| 420 | uint32_t magic; |
| 421 | uint32_t component_handle; /**< The component this buffer is from */ |
| 422 | uint32_t port_handle; /**< Index into array of ports for this component */ |
| 423 | |
| 424 | /** Client side uses this to get back to its context structure. */ |
| 425 | uint32_t client_context; |
| 426 | }; |
| 427 | |
| 428 | typedef struct |
| 429 | { |
| 430 | uint32_t ; /**< Used to link several buffer headers together */ |
| 431 | |
| 432 | uint32_t ; /**< Data private to the framework */ |
| 433 | |
| 434 | uint32_t ; /**< Defines what the buffer header contains. This is a FourCC |
| 435 | with 0 as a special value meaning stream data */ |
| 436 | |
| 437 | uint32_t ; /**< Pointer to the start of the payload buffer (should not be |
| 438 | changed by component) */ |
| 439 | uint32_t ; /**< Allocated size in bytes of payload buffer */ |
| 440 | uint32_t ; /**< Number of bytes currently used in the payload buffer (starting |
| 441 | from offset) */ |
| 442 | uint32_t ; /**< Offset in bytes to the start of valid data in the payload buffer */ |
| 443 | |
| 444 | uint32_t ; /**< Flags describing properties of a buffer header (see |
| 445 | \ref bufferheaderflags "Buffer header flags") */ |
| 446 | |
| 447 | int64_t ; /**< Presentation timestamp in microseconds. \ref MMAL_TIME_UNKNOWN |
| 448 | is used when the pts is unknown. */ |
| 449 | int64_t ; /**< Decode timestamp in microseconds (dts = pts, except in the case |
| 450 | of video streams with B frames). \ref MMAL_TIME_UNKNOWN |
| 451 | is used when the dts is unknown. */ |
| 452 | |
| 453 | /** Type specific data that's associated with a payload buffer */ |
| 454 | uint32_t ; |
| 455 | |
| 456 | uint32_t ; /**< Field reserved for use by the client */ |
| 457 | |
| 458 | } ; |
| 459 | |
| 460 | /** Receive a buffer from the host. |
| 461 | * |
| 462 | * @sa mmal_port_send_buffer() |
| 463 | */ |
| 464 | |
| 465 | typedef struct mmal_worker_buffer_from_host |
| 466 | { |
| 467 | mmal_worker_msg_header ; |
| 468 | |
| 469 | /** Our control data, copied from the buffer header "driver area" |
| 470 | * @sa mmal_buffer_header_driver_data(). |
| 471 | */ |
| 472 | struct MMAL_DRIVER_BUFFER_T drvbuf; |
| 473 | |
| 474 | /** Referenced buffer control data. |
| 475 | * This is set if the buffer is referencing another |
| 476 | * buffer as is the case with passthrough ports where |
| 477 | * buffers on the output port reference buffers on the |
| 478 | * input port. */ |
| 479 | struct MMAL_DRIVER_BUFFER_T drvbuf_ref; |
| 480 | |
| 481 | /** the buffer header itself */ |
| 482 | MMAL_VC_BUFFER_HEADER_T ; |
| 483 | MMAL_BUFFER_HEADER_TYPE_SPECIFIC_T ; |
| 484 | |
| 485 | MMAL_BOOL_T is_zero_copy; |
| 486 | MMAL_BOOL_T has_reference; |
| 487 | |
| 488 | /** If the data is short enough, then send it in the control message rather |
| 489 | * than using a separate VCHIQ bulk transfer. |
| 490 | */ |
| 491 | uint32_t payload_in_message; |
| 492 | uint8_t short_data[MMAL_VC_SHORT_DATA]; |
| 493 | |
| 494 | } mmal_worker_buffer_from_host; |
| 495 | vcos_static_assert(sizeof(mmal_worker_buffer_from_host) <= MMAL_WORKER_MAX_MSG_LEN); |
| 496 | |
| 497 | /** Maximum number of event data bytes that can be passed in the message. |
| 498 | * More than this and the data is passed in a bulk message. |
| 499 | */ |
| 500 | #define MMAL_WORKER_EVENT_SPACE 256 |
| 501 | |
| 502 | /** Send an event buffer from the host. |
| 503 | * |
| 504 | * @sa mmal_port_send_event() |
| 505 | */ |
| 506 | |
| 507 | typedef struct mmal_worker_event_to_host |
| 508 | { |
| 509 | mmal_worker_msg_header ; |
| 510 | |
| 511 | uint32_t client_component; |
| 512 | uint32_t port_type; |
| 513 | uint32_t port_num; |
| 514 | |
| 515 | uint32_t cmd; |
| 516 | uint32_t length; |
| 517 | uint8_t data[MMAL_WORKER_EVENT_SPACE]; |
| 518 | MMAL_BUFFER_HEADER_T *delayed_buffer; /* Only used to remember buffer for bulk rx */ // FIXME |
| 519 | } mmal_worker_event_to_host; |
| 520 | vcos_static_assert(sizeof(mmal_worker_event_to_host) <= MMAL_WORKER_MAX_MSG_LEN); |
| 521 | |
| 522 | typedef struct mmal_worker_event_format_changed |
| 523 | { |
| 524 | uint32_t buffer_size_min; /**< Minimum size of buffers the port requires */ |
| 525 | uint32_t buffer_num_min; /**< Minimum number of buffers the port requires */ |
| 526 | uint32_t buffer_size_recommended; /**< Size of buffers the port recommends for optimal performance. |
| 527 | A value of zero means no special recommendation. */ |
| 528 | uint32_t buffer_num_recommended; /**< Number of buffers the port recommends for optimal |
| 529 | performance. A value of zero means no special recommendation. */ |
| 530 | |
| 531 | uint32_t format; /**< New elementary stream format */ |
| 532 | } mmal_worker_event_format_changed; |
| 533 | |
| 534 | typedef struct |
| 535 | { |
| 536 | mmal_worker_msg_header ; |
| 537 | MMAL_VC_STATS_T stats; |
| 538 | uint32_t reset; |
| 539 | } mmal_worker_stats; |
| 540 | vcos_static_assert(sizeof(mmal_worker_stats) <= MMAL_WORKER_MAX_MSG_LEN); |
| 541 | |
| 542 | typedef enum { |
| 543 | MMAL_WORKER_OPAQUE_MEM_ALLOC, |
| 544 | MMAL_WORKER_OPAQUE_MEM_RELEASE, |
| 545 | MMAL_WORKER_OPAQUE_MEM_ACQUIRE, |
| 546 | MMAL_WORKER_OPAQUE_MEM_MAX = 0x7fffffff, |
| 547 | } MMAL_WORKER_OPAQUE_MEM_OP; |
| 548 | |
| 549 | typedef struct |
| 550 | { |
| 551 | mmal_worker_msg_header ; |
| 552 | MMAL_WORKER_OPAQUE_MEM_OP op; |
| 553 | uint32_t handle; |
| 554 | MMAL_STATUS_T status; |
| 555 | char description[32]; |
| 556 | } mmal_worker_opaque_allocator; |
| 557 | |
| 558 | /* |
| 559 | * Per-port core statistics |
| 560 | */ |
| 561 | typedef struct |
| 562 | { |
| 563 | mmal_worker_msg_header ; |
| 564 | uint32_t component_index; |
| 565 | uint32_t port_index; |
| 566 | MMAL_PORT_TYPE_T type; |
| 567 | MMAL_CORE_STATS_DIR dir; |
| 568 | MMAL_BOOL_T reset; |
| 569 | } mmal_worker_get_core_stats_for_port; |
| 570 | |
| 571 | typedef struct |
| 572 | { |
| 573 | mmal_worker_msg_header ; |
| 574 | MMAL_STATUS_T status; |
| 575 | MMAL_STATS_RESULT_T result; |
| 576 | MMAL_CORE_STATISTICS_T stats; |
| 577 | char component_name[MMAL_VC_CORE_STATS_NAME_MAX]; |
| 578 | } mmal_worker_get_core_stats_for_port_reply; |
| 579 | |
| 580 | typedef struct |
| 581 | { |
| 582 | mmal_worker_msg_header ; |
| 583 | MMAL_STATUS_T status; |
| 584 | /* The amount of memory to reserve */ |
| 585 | uint32_t size; |
| 586 | /* Handle to newly allocated memory or MEM_HANDLE_INVALD on failure */ |
| 587 | uint32_t handle; |
| 588 | } mmal_worker_consume_mem; |
| 589 | vcos_static_assert(sizeof(mmal_worker_consume_mem) <= MMAL_WORKER_MAX_MSG_LEN); |
| 590 | |
| 591 | typedef struct |
| 592 | { |
| 593 | mmal_worker_msg_header ; |
| 594 | MMAL_STATUS_T status; |
| 595 | uint32_t mode; |
| 596 | uint32_t duration; |
| 597 | } mmal_worker_compact; |
| 598 | vcos_static_assert(sizeof(mmal_worker_compact) <= MMAL_WORKER_MAX_MSG_LEN); |
| 599 | |
| 600 | typedef struct |
| 601 | { |
| 602 | mmal_worker_msg_header ; |
| 603 | /* Message text to add to the circular buffer */ |
| 604 | char msg[MMAL_WORKER_MAX_MSG_LEN - sizeof(mmal_worker_msg_header)]; |
| 605 | } mmal_worker_host_log; |
| 606 | vcos_static_assert(sizeof(mmal_worker_host_log) <= MMAL_WORKER_MAX_MSG_LEN); |
| 607 | |
| 608 | typedef struct |
| 609 | { |
| 610 | mmal_worker_msg_header ; |
| 611 | /* The memory allocation size to pass to lmk, as if in a response to an |
| 612 | * allocation for this amount of memory. */ |
| 613 | uint32_t alloc_size; |
| 614 | } mmal_worker_lmk; |
| 615 | vcos_static_assert(sizeof(mmal_worker_lmk) <= MMAL_WORKER_MAX_MSG_LEN); |
| 616 | |
| 617 | static inline void (mmal_worker_buffer_from_host *msg, |
| 618 | MMAL_BUFFER_HEADER_T *) |
| 619 | { |
| 620 | msg->buffer_header.cmd = header->cmd; |
| 621 | msg->buffer_header.offset = header->offset; |
| 622 | msg->buffer_header.length = header->length; |
| 623 | msg->buffer_header.flags = header->flags; |
| 624 | msg->buffer_header.pts = header->pts; |
| 625 | msg->buffer_header.dts = header->dts; |
| 626 | msg->buffer_header.alloc_size = header->alloc_size; |
| 627 | msg->buffer_header.data = (uintptr_t)header->data; |
| 628 | msg->buffer_header_type_specific = *header->type; |
| 629 | } |
| 630 | |
| 631 | static inline void (MMAL_BUFFER_HEADER_T *, |
| 632 | mmal_worker_buffer_from_host *msg) |
| 633 | { |
| 634 | header->cmd = msg->buffer_header.cmd; |
| 635 | header->offset = msg->buffer_header.offset; |
| 636 | header->length = msg->buffer_header.length; |
| 637 | header->flags = msg->buffer_header.flags; |
| 638 | header->pts = msg->buffer_header.pts; |
| 639 | header->dts = msg->buffer_header.dts; |
| 640 | *header->type = msg->buffer_header_type_specific; |
| 641 | } |
| 642 | |
| 643 | static inline void mmal_vc_copy_es_format_from_vc(MMAL_VC_ES_FORMAT_T *src, MMAL_ES_FORMAT_T *dest) |
| 644 | { |
| 645 | // IPC MMAL_VC_ES_FORMAT_T is not necessarily the same as MMAL_ES_FORMAT_T, |
| 646 | // so copy fields individually. |
| 647 | dest->type = src->type; |
| 648 | dest->encoding = src->encoding; |
| 649 | dest->encoding_variant = src->encoding_variant; |
| 650 | dest->bitrate = src->bitrate; |
| 651 | dest->flags = src->flags; |
| 652 | dest->extradata_size = src->extradata_size; |
| 653 | } |
| 654 | |
| 655 | #endif |
| 656 | |
| 657 | |