aboutsummaryrefslogtreecommitdiff
path: root/encoder/osal.c
blob: 92e9a8de8103c913e26642adfad3d8f407f74d00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/******************************************************************************
 *
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *****************************************************************************
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
*/

/*****************************************************************************/
/*                                                                           */
/*  File Name         : osal.c                                               */
/*                                                                           */
/*  Description       : This file contains all the API's of OSAL             */
/*                      initialization and closure                           */
/*                                                                           */
/*  List of Functions : osal_init                                            */
/*                      osal_register_callbacks                              */
/*                      osal_close                                           */
/*                      osal_get_version                                     */
/*                      osal_print_status_log                                */
/*                                                                           */
/*  Issues / Problems : None                                                 */
/*                                                                           */
/*  Revision History  :                                                      */
/*                                                                           */
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
/*         19 04 2006   Ittiam          Draft                                */
/*                                                                           */
/*****************************************************************************/

/*****************************************************************************/
/* File Includes                                                             */
/*****************************************************************************/

/* System include files */
#include <stdio.h>

#include <sys/types.h>
#include <semaphore.h>
#include <pthread.h>

/* User include files */
#include "cast_types.h"
#include "osal.h"
#include "osal_handle.h"

/*****************************************************************************/
/* Constant Macros                                                           */
/*****************************************************************************/

#define OSAL_VERSION "OSAL_v13.1"

/*****************************************************************************/
/*                                                                           */
/*  Function Name : osal_init                                                */
/*                                                                           */
/*  Description   : This function creates and initializes the OSAL instance  */
/*                                                                           */
/*  Inputs        : Memory for OSAL handle                                   */
/*                                                                           */
/*  Globals       : None                                                     */
/*                                                                           */
/*  Processing    : Initializes OSAL handle parameters to default values.    */
/*                                                                           */
/*  Outputs       : Status of OSAL handle initialization                     */
/*                                                                           */
/*  Returns       : On SUCCESS - OSAL_SUCCESS                                */
/*                  On FAILURE - OSAL_ERROR                                  */
/*                                                                           */
/*  Issues        : None                                                     */
/*                                                                           */
/*  Revision History:                                                        */
/*                                                                           */
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
/*         19 04 2006   Ittiam          Draft                                */
/*                                                                           */
/*****************************************************************************/

WORD32 osal_init(IN void *osal_handle)
{
    osal_t *handle = (osal_t *)osal_handle;

    /* Validate the input */
    if(0 == osal_handle)
        return OSAL_ERROR;

    /* Initialize call back functions */
    handle->alloc = 0;
    handle->free = 0;
    handle->mmr_handle = 0;

    return OSAL_SUCCESS;
}

/*****************************************************************************/
/*                                                                           */
/*  Function Name : osal_register_callbacks                                  */
/*                                                                           */
/*  Description   : This function registers MMR handle and allocation and    */
/*                  freeing call back functions.                             */
/*                                                                           */
/*  Inputs        : OSAL handle                                              */
/*                  OSAL callback attributes                                 */
/*                                                                           */
/*  Globals       : None                                                     */
/*                                                                           */
/*  Processing    : This function initializes OSAL call back parameters.     */
/*                                                                           */
/*  Outputs       : Status of OSAL callback registration                     */
/*                                                                           */
/*  Returns       : On SUCCESS - OSAL_SUCCESS                                */
/*                  On FAILURE - OSAL_ERROR                                  */
/*                                                                           */
/*  Issues        : None                                                     */
/*                                                                           */
/*  Revision History:                                                        */
/*                                                                           */
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
/*         10 05 2006   Ittiam          Draft                                */
/*                                                                           */
/*****************************************************************************/

WORD32 osal_register_callbacks(IN void *osal_handle, IN osal_cb_funcs_t *cb_funcs)
{
    osal_t *handle = (osal_t *)osal_handle;

    /* Validate the input */
    if(0 == handle || 0 == cb_funcs)
        return OSAL_ERROR;

    if(0 == cb_funcs->osal_alloc || 0 == cb_funcs->osal_free)
        return OSAL_ERROR;

    /* Initialize call back parameters */
    handle->mmr_handle = cb_funcs->mmr_handle;
    handle->alloc = cb_funcs->osal_alloc;
    handle->free = cb_funcs->osal_free;

    return OSAL_SUCCESS;
}

/*****************************************************************************/
/*                                                                           */
/*  Function Name : osal_close                                               */
/*                                                                           */
/*  Description   : This function closes the OSAL instance                   */
/*                                                                           */
/*  Inputs        : OSAL handle                                              */
/*                                                                           */
/*  Globals       : None                                                     */
/*                                                                           */
/*  Processing    : Frees the memory allocated for the OSAL handle           */
/*                                                                           */
/*  Outputs       : Status of OSAL instance close                            */
/*                                                                           */
/*  Returns       : On SUCCESS - 0                                           */
/*                  On FALIURE - -1                                          */
/*                                                                           */
/*  Issues        : None                                                     */
/*                                                                           */
/*  Revision History:                                                        */
/*                                                                           */
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
/*         19 04 2006   Ittiam          Draft                                */
/*                                                                           */
/*****************************************************************************/

WORD32 osal_close(IN void *osal_handle)
{
    /* Validate input */
    if(0 == osal_handle)
        return OSAL_ERROR;

    return OSAL_SUCCESS;
}

/*****************************************************************************/
/*                                                                           */
/*  Function Name : osal_get_version                                         */
/*                                                                           */
/*  Description   : This function gets the version of OSAL library.          */
/*                                                                           */
/*  Inputs        : None                                                     */
/*  Globals       : None                                                     */
/*                                                                           */
/*  Processing    : Returns a NULL terminated string with has the version of */
/*                  library being used.                                      */
/*                                                                           */
/*  Outputs       : Version of OSAL library.                                 */
/*                                                                           */
/*  Returns       : Pointer to a NULL terminated string                      */
/*                                                                           */
/*  Issues        : None                                                     */
/*                                                                           */
/*  Revision History:                                                        */
/*                                                                           */
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
/*         07 03 2006   Ittiam          Draft                                */
/*                                                                           */
/*****************************************************************************/

WORD8 *osal_get_version()
{
    return ((WORD8 *)OSAL_VERSION);
}