1 /* 2 * 3 * Copyright 2013 Rockchip Electronics S.LSI Co. LTD 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* 19 * @file Rockchip_OMX_Macros.h 20 * @brief Macros 21 * @author csy(csy@rock-chips.com) 22 * @version 1.0.0 23 * @history 24 * 2013.11.26 : Create 25 */ 26 27 #ifndef ROCKCHIP_OMX_MACROS 28 #define ROCKCHIP_OMX_MACROS 29 30 #include "Rockchip_OMX_Def.h" 31 #include "Rockchip_OSAL_Memory.h" 32 33 34 /* 35 * MACROS 36 */ 37 #define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) 38 #define ALIGN_TO_16B(x) ((((x) + (1 << 4) - 1) >> 4) << 4) 39 #define ALIGN_TO_32B(x) ((((x) + (1 << 5) - 1) >> 5) << 5) 40 #define ALIGN_TO_128B(x) ((((x) + (1 << 7) - 1) >> 7) << 7) 41 #define ALIGN_TO_8KB(x) ((((x) + (1 << 13) - 1) >> 13) << 13) 42 43 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) 44 45 #define INIT_SET_SIZE_VERSION(_struct_, _structType_) \ 46 do { \ 47 Rockchip_OSAL_Memset((_struct_), 0, sizeof(_structType_)); \ 48 (_struct_)->nSize = sizeof(_structType_); \ 49 (_struct_)->nVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; \ 50 (_struct_)->nVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; \ 51 (_struct_)->nVersion.s.nRevision = REVISION_NUMBER; \ 52 (_struct_)->nVersion.s.nStep = STEP_NUMBER; \ 53 } while (0) 54 /* 55 * Port Specific 56 */ 57 #define ROCKCHIP_TUNNEL_ESTABLISHED 0x0001 58 #define ROCKCHIP_TUNNEL_IS_SUPPLIER 0x0002 59 60 #define CHECK_PORT_BEING_FLUSHED(port) \ 61 (((port)->bIsPortFlushed) == OMX_TRUE) 62 #define CHECK_PORT_BEING_DISABLED(port) \ 63 (((port)->bIsPortDisabled) == OMX_TRUE) 64 #define CHECK_PORT_BEING_FLUSHED_OR_DISABLED(port) \ 65 (((port)->bIsPortFlushed == OMX_TRUE) || (port->bIsPortDisabled == OMX_TRUE)) 66 #define CHECK_PORT_ENABLED(port) \ 67 (((port)->portDefinition.bEnabled) == OMX_TRUE) 68 #define CHECK_PORT_POPULATED(port) \ 69 (((port)->portDefinition.bPopulated) == OMX_TRUE) 70 #define CHECK_PORT_TUNNELED(port) \ 71 (((port)->tunnelFlags) & ROCKCHIP_TUNNEL_ESTABLISHED) 72 #define CHECK_PORT_BUFFER_SUPPLIER(port) \ 73 (((port)->tunnelFlags) & ROCKCHIP_TUNNEL_IS_SUPPLIER) 74 75 #endif 76