1 /****************************************************************************** 2 * 3 * Copyright 2007, Silicon Image, Inc. All rights reserved. 4 * No part of this work may be reproduced, modified, distributed, transmitted, 5 * transcribed, or translated into any language or computer format, in any form 6 * or by any means without written permission of: Silicon Image, Inc., 1060 7 * East Arques Avenue, Sunnyvale, California 94085 8 * 9 *****************************************************************************/ 10 /** 11 * @file media_buffer.h 12 * 13 * @brief 14 * Media Buffer interface 15 * 16 * <pre> 17 * 18 * Principal Author: Joerg Detert 19 * Creation date: Feb 28, 2008 20 * 21 * </pre> 22 * 23 *****************************************************************************/ 24 #ifndef MEDIA_BUFFER_H_ 25 #define MEDIA_BUFFER_H_ 26 27 #include <assert.h> 28 #include <stddef.h> 29 #include "rk_aiq_comm.h" 30 31 #if defined (__cplusplus) 32 extern "C" { 33 #endif 34 35 #define RET_SUCCESS 0 //!< this has to be 0, if clauses rely on it 36 #define RET_FAILURE 1 //!< general failure 37 #define RET_NOTSUPP 2 //!< feature not supported 38 #define RET_BUSY 3 //!< there's already something going on... 39 #define RET_CANCELED 4 //!< operation canceled 40 #define RET_OUTOFMEM 5 //!< out of memory 41 #define RET_OUTOFRANGE 6 //!< parameter/value out of range 42 #define RET_IDLE 7 //!< feature/subsystem is in idle state 43 #define RET_WRONG_HANDLE 8 //!< handle is wrong 44 #define RET_NULL_POINTER 9 //!< the/one/all parameter(s) is a(are) NULL pointer(s) 45 #define RET_NOTAVAILABLE 10 //!< profile not available 46 #define RET_DIVISION_BY_ZERO 11 //!< a divisor equals ZERO 47 #define RET_WRONG_STATE 12 //!< state machine in wrong state 48 #define RET_INVALID_PARM 13 //!< invalid parameter 49 #define RET_PENDING 14 //!< command pending 50 #define RET_WRONG_CONFIG 15 //!< given configuration is invalid 51 52 typedef unsigned long ulong_t; 53 54 /** 55 * @brief The MediaBufferPool holds elements from type MediaBuffer_t. 56 */ 57 typedef struct MediaBuffer_s 58 { 59 uint8_t* pBaseAddress; /**< Base address of system memory buffer (can differ from 60 actual buffer start address, set in ScmiBuffer). */ 61 uint32_t baseSize; /**< Base size of buffer (can differ from actual buffer 62 size, set in ScmiBuffer). */ 63 uint32_t lockCount; /**< Counting how many times buffer is used. 0 means 64 buffer belongs to pool and is free. */ 65 void* pOwner; 66 67 void* pMetaData; /**< Pointer to optional meta data structure. */ 68 } MediaBuffer_t; 69 70 /*****************************************************************************/ 71 /** 72 * @brief Initialize a mutex. 73 * 74 * @param 75 * 76 *****************************************************************************/ 77 void AtomicMutexInit(); 78 79 /*****************************************************************************/ 80 /** 81 * @brief Destroy a mutex. 82 * 83 * @param 84 * 85 *****************************************************************************/ 86 void AtomicMutexDestory(); 87 88 /*****************************************************************************/ 89 /** 90 * @brief Initialize a @ref MediaBuffer_t. 91 * 92 * @param pBuf Buffer to initialize. 93 * 94 *****************************************************************************/ 95 extern void MediaBufInit(MediaBuffer_t* pBuf); 96 97 /*****************************************************************************/ 98 /** 99 * @brief Lock a buffer of a owning buffer pool. Buffer will not be available as 100 * empty buffer until unlocked as many times as locked before 101 * and released. 102 * 103 * @param pBufQueue Pointer to Media Buffer Queue object. 104 * @param pBuf Pointer to media buffer. 105 * 106 * @return Status of operation. 107 *****************************************************************************/ 108 extern RESULT MediaBufLockBuffer(MediaBuffer_t* pBuf); 109 110 111 /*****************************************************************************/ 112 /** 113 * @brief Unlock a buffer of a owning buffer pool which has previously been locked. 114 * 115 * @param pBufQueue Pointer to Media Buffer Queue object. 116 * @param pBuf Pointer to media buffer. 117 * 118 * @return Status of operation. 119 *****************************************************************************/ 120 extern RESULT MediaBufUnlockBuffer(MediaBuffer_t* pBuf); 121 122 123 #if defined (__cplusplus) 124 } 125 #endif 126 127 128 #endif /*MEDIA_BUFFER_H_*/ 129