Coverage Report

Created: 2024-07-27 06:20

/src/libhevc/encoder/osal.c
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 *
3
 * Copyright (C) 2018 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
/*                                                                           */
23
/*  File Name         : osal.c                                               */
24
/*                                                                           */
25
/*  Description       : This file contains all the API's of OSAL             */
26
/*                      initialization and closure                           */
27
/*                                                                           */
28
/*  List of Functions : osal_init                                            */
29
/*                      osal_register_callbacks                              */
30
/*                      osal_close                                           */
31
/*                      osal_get_version                                     */
32
/*                      osal_print_status_log                                */
33
/*                                                                           */
34
/*  Issues / Problems : None                                                 */
35
/*                                                                           */
36
/*  Revision History  :                                                      */
37
/*                                                                           */
38
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
39
/*         19 04 2006   Ittiam          Draft                                */
40
/*                                                                           */
41
/*****************************************************************************/
42
43
/*****************************************************************************/
44
/* File Includes                                                             */
45
/*****************************************************************************/
46
47
/* System include files */
48
#include <stdio.h>
49
50
#include <sys/types.h>
51
#include <semaphore.h>
52
#include <pthread.h>
53
54
/* User include files */
55
#include "cast_types.h"
56
#include "osal.h"
57
#include "osal_handle.h"
58
59
/*****************************************************************************/
60
/* Constant Macros                                                           */
61
/*****************************************************************************/
62
63
0
#define OSAL_VERSION "OSAL_v13.1"
64
65
/*****************************************************************************/
66
/*                                                                           */
67
/*  Function Name : osal_init                                                */
68
/*                                                                           */
69
/*  Description   : This function creates and initializes the OSAL instance  */
70
/*                                                                           */
71
/*  Inputs        : Memory for OSAL handle                                   */
72
/*                                                                           */
73
/*  Globals       : None                                                     */
74
/*                                                                           */
75
/*  Processing    : Initializes OSAL handle parameters to default values.    */
76
/*                                                                           */
77
/*  Outputs       : Status of OSAL handle initialization                     */
78
/*                                                                           */
79
/*  Returns       : On SUCCESS - OSAL_SUCCESS                                */
80
/*                  On FAILURE - OSAL_ERROR                                  */
81
/*                                                                           */
82
/*  Issues        : None                                                     */
83
/*                                                                           */
84
/*  Revision History:                                                        */
85
/*                                                                           */
86
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
87
/*         19 04 2006   Ittiam          Draft                                */
88
/*                                                                           */
89
/*****************************************************************************/
90
91
WORD32 osal_init(IN void *osal_handle)
92
17.7k
{
93
17.7k
    osal_t *handle = (osal_t *)osal_handle;
94
95
    /* Validate the input */
96
17.7k
    if(0 == osal_handle)
97
0
        return OSAL_ERROR;
98
99
    /* Initialize call back functions */
100
17.7k
    handle->alloc = 0;
101
17.7k
    handle->free = 0;
102
17.7k
    handle->mmr_handle = 0;
103
104
17.7k
    return OSAL_SUCCESS;
105
17.7k
}
106
107
/*****************************************************************************/
108
/*                                                                           */
109
/*  Function Name : osal_register_callbacks                                  */
110
/*                                                                           */
111
/*  Description   : This function registers MMR handle and allocation and    */
112
/*                  freeing call back functions.                             */
113
/*                                                                           */
114
/*  Inputs        : OSAL handle                                              */
115
/*                  OSAL callback attributes                                 */
116
/*                                                                           */
117
/*  Globals       : None                                                     */
118
/*                                                                           */
119
/*  Processing    : This function initializes OSAL call back parameters.     */
120
/*                                                                           */
121
/*  Outputs       : Status of OSAL callback registration                     */
122
/*                                                                           */
123
/*  Returns       : On SUCCESS - OSAL_SUCCESS                                */
124
/*                  On FAILURE - OSAL_ERROR                                  */
125
/*                                                                           */
126
/*  Issues        : None                                                     */
127
/*                                                                           */
128
/*  Revision History:                                                        */
129
/*                                                                           */
130
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
131
/*         10 05 2006   Ittiam          Draft                                */
132
/*                                                                           */
133
/*****************************************************************************/
134
135
WORD32 osal_register_callbacks(IN void *osal_handle, IN osal_cb_funcs_t *cb_funcs)
136
17.7k
{
137
17.7k
    osal_t *handle = (osal_t *)osal_handle;
138
139
    /* Validate the input */
140
17.7k
    if(0 == handle || 0 == cb_funcs)
141
0
        return OSAL_ERROR;
142
143
17.7k
    if(0 == cb_funcs->osal_alloc || 0 == cb_funcs->osal_free)
144
0
        return OSAL_ERROR;
145
146
    /* Initialize call back parameters */
147
17.7k
    handle->mmr_handle = cb_funcs->mmr_handle;
148
17.7k
    handle->alloc = cb_funcs->osal_alloc;
149
17.7k
    handle->free = cb_funcs->osal_free;
150
151
17.7k
    return OSAL_SUCCESS;
152
17.7k
}
153
154
/*****************************************************************************/
155
/*                                                                           */
156
/*  Function Name : osal_close                                               */
157
/*                                                                           */
158
/*  Description   : This function closes the OSAL instance                   */
159
/*                                                                           */
160
/*  Inputs        : OSAL handle                                              */
161
/*                                                                           */
162
/*  Globals       : None                                                     */
163
/*                                                                           */
164
/*  Processing    : Frees the memory allocated for the OSAL handle           */
165
/*                                                                           */
166
/*  Outputs       : Status of OSAL instance close                            */
167
/*                                                                           */
168
/*  Returns       : On SUCCESS - 0                                           */
169
/*                  On FALIURE - -1                                          */
170
/*                                                                           */
171
/*  Issues        : None                                                     */
172
/*                                                                           */
173
/*  Revision History:                                                        */
174
/*                                                                           */
175
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
176
/*         19 04 2006   Ittiam          Draft                                */
177
/*                                                                           */
178
/*****************************************************************************/
179
180
WORD32 osal_close(IN void *osal_handle)
181
8.88k
{
182
    /* Validate input */
183
8.88k
    if(0 == osal_handle)
184
0
        return OSAL_ERROR;
185
186
8.88k
    return OSAL_SUCCESS;
187
8.88k
}
188
189
/*****************************************************************************/
190
/*                                                                           */
191
/*  Function Name : osal_get_version                                         */
192
/*                                                                           */
193
/*  Description   : This function gets the version of OSAL library.          */
194
/*                                                                           */
195
/*  Inputs        : None                                                     */
196
/*  Globals       : None                                                     */
197
/*                                                                           */
198
/*  Processing    : Returns a NULL terminated string with has the version of */
199
/*                  library being used.                                      */
200
/*                                                                           */
201
/*  Outputs       : Version of OSAL library.                                 */
202
/*                                                                           */
203
/*  Returns       : Pointer to a NULL terminated string                      */
204
/*                                                                           */
205
/*  Issues        : None                                                     */
206
/*                                                                           */
207
/*  Revision History:                                                        */
208
/*                                                                           */
209
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
210
/*         07 03 2006   Ittiam          Draft                                */
211
/*                                                                           */
212
/*****************************************************************************/
213
214
WORD8 *osal_get_version()
215
0
{
216
0
    return ((WORD8 *)OSAL_VERSION);
217
0
}