• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright (C) 2015 The Android Open Source Project
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  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 /**
21 *******************************************************************************
22 * @file
23 *  impeg2_buf_mgr.h
24 *
25 * @brief
26 *  Function declarations used for buffer management
27 *
28 * @author
29 *  Srinivas T
30 *
31 * @remarks
32 *  None
33 *
34 *******************************************************************************
35 */
36 #ifndef _IMPEG2_BUF_MGR_H_
37 #define _IMPEG2_BUF_MGR_H_
38 
39 #define BUF_MGR_MAX_CNT 64
40 
41 #define BUF_MGR_DEC         1
42 #define BUF_MGR_REF         (1 << 1)
43 #define BUF_MGR_DISP        (1 << 2)
44 
45 typedef struct
46 {
47     /**
48      * max_buf_cnt
49      */
50     UWORD32 u4_max_buf_cnt;
51 
52     /**
53      * active_buf_cnt
54      */
55     UWORD32 u4_active_buf_cnt;
56     /**
57      *  au4_status[BUF_MGR_MAX_CNT]
58      */
59     UWORD32 au4_status[BUF_MGR_MAX_CNT];
60     /* The last three bit of status are:    */
61     /* Bit 0 - DEC                          */
62     /* Bit 1 - REF                          */
63     /* Bit 2 - DISP                         */
64 
65     void    *apv_ptr[BUF_MGR_MAX_CNT];
66 }buf_mgr_t;
67 
68 // intializes the buffer API structure
69 void impeg2_buf_mgr_init(
70                 buf_mgr_t *ps_buf_mgr);
71 
72 // resets the buffer API structure
73 void impeg2_buf_mgr_reset(
74                 buf_mgr_t *ps_buf_mgr);
75 
76 // Add buffer to buffer manager. 0: success, -1: fail (u4_active_buf_cnt has reached u4_max_buf_cnt)
77 WORD32 impeg2_buf_mgr_add(
78                 buf_mgr_t *ps_buf_mgr,
79                 void *pv_ptr,
80                 WORD32 buf_id);
81 
82 // this function will set the buffer status to DEC
83 void* impeg2_buf_mgr_get_next_free(
84                 buf_mgr_t *ps_buf_mgr,
85                 WORD32 *pi4_id);
86 
87 // this function will check if there are any free buffers
88 WORD32 impeg2_buf_mgr_check_free(
89                 buf_mgr_t *ps_buf_mgr);
90 
91 // mask will have who released it: DISP:REF:DEC
92 WORD32 impeg2_buf_mgr_release(
93                 buf_mgr_t *ps_buf_mgr,
94                 WORD32 id,
95                 UWORD32 mask);
96 
97 // sets the status to one or all of DISP:REF:DEC
98 WORD32 impeg2_buf_mgr_set_status(
99                 buf_mgr_t *ps_buf_mgr,
100                 WORD32 id,
101                 UWORD32 mask);
102 
103 // Gets status of the buffer
104 UWORD32 impeg2_buf_mgr_get_status(
105                 buf_mgr_t *ps_buf_mgr,
106                 WORD32 id);
107 
108 // pass the ID - buffer will be returned
109 void* impeg2_buf_mgr_get_buf(
110                 buf_mgr_t *ps_buf_mgr,
111                 WORD32 id);
112 
113 // will return number of active buffers
114 UWORD32 impeg2_buf_mgr_get_num_active_buf(
115                 buf_mgr_t *ps_buf_mgr);
116 
117 
118 
119 #endif  //_IMPEG2_BUF_MGR_H_
120