• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 *
3 * SPDX-License-Identifier: GPL-2.0
4 *
5 * Copyright (C) 2011-2018 ARM or its affiliates
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19 
20 #ifndef __SYSTEM_SEMAPHORE_H__
21 #define __SYSTEM_SEMAPHORE_H__
22 //-----------------------------------------------------------------------------
23 #include "acamera_types.h"
24 //-----------------------------------------------------------------------------
25 typedef void *semaphore_t;
26 
27 //-----------------------------------------------------------------------------
28 
29 /**
30  *   Initialize system semaphore
31  *
32  *   The function initializes a system dependent semaphore
33  *
34  *   @param void ** sem - the pointer to system semaphore will be returned
35  *
36  *   @return  0 - on success
37  *           -1 - on error
38  */
39 int32_t system_semaphore_init( semaphore_t *sem );
40 
41 
42 /**
43  *   Unlock the semaphore pointed to by sem
44  *
45  *   The function increments (unlocks) the semaphore.
46  *   If the semaphore value becomes greater than zero, then
47  *   another process which is blocked by system_semaphore_wait will be
48  *   woken up
49  *
50  *   @param   sem - pointer to semaphore returned by system_semaphore_init
51  *
52  *   @return  0 - on success
53  *           -1 - on error
54  */
55 int32_t system_semaphore_raise( semaphore_t sem );
56 
57 
58 /**
59  *   Locks the semaphore pointed to by sem
60  *
61  *   The function decrements (locks) the semaphore.
62  *   If the semaphore value is greater than zero, then
63  *   the decrement proceeds, and the function returns.
64  *
65  *   @param   sem - pointer to semaphore returned by system_semaphore_init
66  *
67  *   @return  0 - on success
68  *           -1 - on error
69  */
70 int32_t system_semaphore_wait( semaphore_t sem, uint32_t timeout_ms );
71 
72 
73 /**
74  *   Destroy semaphore
75  *
76  *   The function destroys semaphore which was created by system_semaphore_init
77  *
78  *   @return  0 - on success
79  *           -1 - on error
80  */
81 int32_t system_semaphore_destroy( semaphore_t sem );
82 
83 //-----------------------------------------------------------------------------
84 #endif //__SYSTEM_SEMAPHORE_H__
85