Home | History | Annotate | Download | only in common
      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 *  ih264_list.h
     24 *
     25 * @brief
     26 *  Contains functions for buf queue
     27 *
     28 * @author
     29 *  Harish
     30 *
     31 * @par List of Functions:
     32 *
     33 * @remarks
     34 *  None
     35 *
     36 *******************************************************************************
     37 */
     38 
     39 #ifndef _IH264_LIST_H_
     40 #define _IH264_LIST_H_
     41 
     42 typedef struct
     43 {
     44     /** Pointer to buffer base which contains the bufs */
     45     void *pv_buf_base;
     46 
     47     /** Mutex used to keep the functions thread-safe */
     48     void *pv_mutex;
     49 
     50     /** Current write index */
     51     volatile WORD32 i4_buf_wr_idx;
     52 
     53     /** Current read index */
     54     volatile WORD32 i4_buf_rd_idx;
     55 
     56     /** Maximum index */
     57     WORD32 i4_buf_max_idx;
     58 
     59     /** Log2(buf_max_idx) -
     60      * To ensure number of entries is power of two
     61      * This makes it easier to wrap around by using AND with buf_max_idx - 1
     62      * */
     63     WORD32 i4_log2_buf_max_idx;
     64 
     65     /** Flag to indicate list has to be terminated */
     66     WORD32 i4_terminate;
     67 
     68     /** Size of each entry */
     69     WORD32 i4_entry_size;
     70 
     71     /** If the list is to be used frequently send this as zero, else send a large value
     72      * to ensure cores are not loaded unnecessarily.
     73      * For eg: For picture level queues this can be a large value like 100us
     74      * but for jobq this will be zero.
     75      */
     76     WORD32 i4_yeild_interval_us;
     77 
     78 }list_t;
     79 
     80 WORD32 ih264_list_size(WORD32 num_entries, WORD32 entry_size);
     81 void* ih264_list_init(void *pv_buf,
     82                       WORD32 buf_size,
     83                       WORD32 num_entries,
     84                       WORD32 entry_size,
     85                       WORD32 yeild_interval_us);
     86 IH264_ERROR_T ih264_list_free(list_t *ps_list);
     87 IH264_ERROR_T ih264_list_reset(list_t *ps_list);
     88 IH264_ERROR_T ih264_list_deinit(list_t *ps_list);
     89 IH264_ERROR_T ih264_list_terminate(list_t *ps_list);
     90 IH264_ERROR_T ih264_list_queue(list_t *ps_list, void *pv_buf, WORD32 blocking);
     91 IH264_ERROR_T ih264_list_dequeue(list_t *ps_list, void *pv_buf, WORD32 blocking);
     92 
     93 #endif /* _IH264_PROCESS_SLICE_H_ */
     94