Synx APIs
Synx
synx.h
Go to the documentation of this file.
1 // Copyright (c) 2019-2023 Qualcomm Technologies, Inc.
3 // All Rights Reserved.
4 // Confidential and Proprietary - Qualcomm Technologies, Inc.
6 
11 
12 #ifndef SYNX_H
13 #define SYNX_H
14 
15 #include <stdint.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif // __cplusplus
20 
22  // Entry Point
24  #if defined (_WIN32)
25  #define SYNX_DLL_EXPORT __declspec(dllexport)
26  #define SYNX_DLL_IMPORT __declspec(dllimport)
27  #elif defined(__GNUC__)
28  #define SYNX_DLL_EXPORT __attribute((visibility("default")))
29  #define SYNX_DLL_IMPORT
30  #endif
31 
32  #if defined(SYNX_LIB_EXPORT)
33  #define SYNX_API SYNX_DLL_EXPORT
34  #define SYNX_INLINE inline
35  #else
36  #define SYNX_INLINE
37  #define SYNX_API SYNX_DLL_IMPORT
38  #endif
39 
40 
41 #define SYNX_DEVICE_NAME "synx_device"
42 
43 
44 
51 #define SYNX_SUCCESS 0
52 #define SYNX_NOMEM ENOMEM
53 #define SYNX_NOSUPPORT EPERM
54 #define SYNX_NOPERM EPERM
55 #define SYNX_TIMEOUT ETIMEDOUT
56 #define SYNX_ALREADY EALREADY
57 #define SYNX_NOENT ENOENT
58 #define SYNX_INVALID EINVAL
59 #define SYNX_ERROR_FAILED EPERM
60 
61 #define SYNX_NO_TIMEOUT ((uint64_t)-1)
62 
67 #define SYNX_INVALID_HANDLE 0
68 
77 struct synx_session {
78  uint32_t type;
79  void *client;
80 };
81 
89  SYNX_CLIENT_NATIVE = 0,
90  SYNX_CLIENT_MAX,
91 };
92 
100  SYNX_INIT_DEFAULT = 0x00,
101  SYNX_INIT_MAX = 0x01,
102 };
103 
113  const char *name;
114  enum synx_client_id id;
115  enum synx_init_flags flags;
116 };
117 
133  SYNX_CREATE_LOCAL_FENCE = 0x01,
134  SYNX_CREATE_GLOBAL_FENCE = 0x02,
135  SYNX_CREATE_DMA_FENCE = 0x04,
136  SYNX_CREATE_CSL_FENCE = 0x08,
137 };
138 
151  const char *name;
152  uint32_t *h_synx;
153  void *fence;
154  enum synx_create_flags flags;
155 };
156 
164 typedef void (*synx_user_callback)(uint32_t h_synx, int status, void *data);
165 
177  uint32_t h_synx;
178  synx_user_callback cb_func;
179  void *userdata;
180  synx_user_callback cancel_cb_func;
181  uint64_t timeout_ms;
182 };
183 
196  SYNX_STATE_SIGNALED_SUCCESS = 2,
197  SYNX_STATE_SIGNALED_CANCEL = 4,
198  SYNX_STATE_SIGNALED_MAX = 64,
199 };
200 
201 
230  SYNX_IMPORT_LOCAL_FENCE = 0x01,
231  SYNX_IMPORT_GLOBAL_FENCE = 0x02,
232  SYNX_IMPORT_SYNX_FENCE = 0x04,
233  SYNX_IMPORT_DMA_FENCE = 0x08,
234  SYNX_IMPORT_EX_RELEASE = 0x10,
235 };
236 
242  SYNX_IMPORT_INDV_PARAMS = 0x01,
243  SYNX_IMPORT_ARR_PARAMS = 0x02,
244 };
245 
255  uint32_t *new_h_synx;
256  enum synx_import_flags flags;
257  void *fence;
258 };
259 
267  struct synx_import_indv_params *list;
268  uint32_t num_fences;
269 };
270 
279  enum synx_import_type type;
280  union {
281  struct synx_import_indv_params indv;
282  struct synx_import_arr_params arr;
283  };
284 };
285 
302  SYNX_MERGE_LOCAL_FENCE = 0x01,
303  SYNX_MERGE_GLOBAL_FENCE = 0x02,
304  SYNX_MERGE_NOTIFY_ON_ALL = 0x04,
305  SYNX_MERGE_NOTIFY_ON_ANY = 0x08,
306 };
307 
308 /*
309  * struct synx_merge_params - Synx merge parameters
310  *
311  * @h_synxs : Pointer to a array of synx handles to be merged.
312  * @flags : Merge flags.
313  * @num_objs : Number of synx handles to be merged.
314  * @h_merged_obj : Merged synx handle. (filled by function)
315  */
317  uint32_t *h_synxs;
318  enum synx_merge_flags flags;
319  uint32_t num_objs;
320  uint32_t *h_merged_obj;
321 };
322 
323 /*
324  * enum synx_status - Synx status definitions
325  *
326  * @SYNX_STATUS_INVALID : Invalid synx object.
327  * @SYNX_STATUS_UNSIGNALED : Synx object has not been signalled.
328  * @SYNX_STATUS_SIGNALED_SUCCESS : Synx object has been signalled.
329  * @SYNX_STATUS_SIGNALED_ERROR : Synx object signalled with error.
330  * @SYNX_STATUS_SIGNALED_CANCEL : Synx object signalling cancelled.
331  * @SYNX_STATUS_SIGNALED_EXTERNAL : Synx object signaled by external dma client.
332  * @SYNX_STATUS_SIGNALED_SSR : Synx object signaled with SSR.
333  * @SYNX_STATUS_TIMEOUT : Callback status for synx object
334  * in case of timeout.
335  */
337  SYNX_STATUS_INVALID = 0,
338  SYNX_STATUS_UNSIGNALED,
339  SYNX_STATUS_SIGNALED_SUCCESS,
340  SYNX_STATUS_SIGNALED_ERROR,
341  SYNX_STATUS_SIGNALED_CANCEL,
342  SYNX_STATUS_SIGNALED_EXTERNAL,
343  SYNX_STATUS_SIGNALED_SSR,
344  SYNX_STATUS_TIMEOUT,
345 };
346 
347 
348 /* Userspace APIs */
349 
357 SYNX_API struct synx_session *synx_initialize(struct synx_initialization_params *pParam);
358 
367 SYNX_API int32_t synx_uninitialize(struct synx_session *pSession);
368 
381 SYNX_API int32_t synx_create(struct synx_session *pSession, struct synx_create_params *pParam);
382 
394 SYNX_API int32_t synx_get_status(struct synx_session *pSession, uint32_t hSynx);
395 
406 SYNX_API int32_t synx_release(struct synx_session *pSession, uint32_t hSynx);
407 
422 SYNX_API int32_t synx_signal(struct synx_session *pSession, uint32_t hSynx, enum synx_signal_status state);
423 
440 SYNX_API int32_t synx_wait(struct synx_session *pSession, uint32_t hSynx, uint64_t timeout_ms);
441 
454 SYNX_API int32_t synx_async_wait(struct synx_session *pSession, struct synx_callback_params *pParams);
455 
469 SYNX_API int32_t synx_cancel_async_wait(struct synx_session *pSession, struct synx_callback_params *pParams);
470 
483 SYNX_API int32_t synx_merge( struct synx_session *pSession, struct synx_merge_params *pParams);
484 
493 SYNX_API int32_t synx_import(struct synx_session *pSession, struct synx_import_params *pParams);
494 
508 SYNX_API int32_t synx_get_fd(struct synx_session *pSession, uint32_t hSynx);
509 
510 #ifdef __cplusplus
511 }
512 #endif // __cplusplus
513 
514 #endif // SYNX_H
synx_merge_flags
Definition: synx.h:301
Definition: synx.h:77
void(* synx_user_callback)(uint32_t h_synx, int status, void *data)
Definition: synx.h:164
Definition: synx.h:278
SYNX_API struct synx_session * synx_initialize(struct synx_initialization_params *pParam)
: Initializes a new client session.
SYNX_API int32_t synx_import(struct synx_session *pSession, struct synx_import_params *pParams)
: Imports (looks up) synx object from given handle or fence.
synx_init_flags
Definition: synx.h:99
SYNX_API int32_t synx_get_status(struct synx_session *pSession, uint32_t hSynx)
: Returns the status of the synx object. This API should not be used in polling mode to check if the ...
synx_status
Definition: synx.h:336
SYNX_API int32_t synx_release(struct synx_session *pSession, uint32_t hSynx)
: Releases the synx object. Every created, imported or merged synx object should be released...
synx_import_flags
Definition: synx.h:229
synx_client_id
Definition: synx.h:88
Definition: synx.h:254
synx_import_type
Definition: synx.h:241
SYNX_API int32_t synx_signal(struct synx_session *pSession, uint32_t hSynx, enum synx_signal_status state)
: Signals a synx object with the status argument.
SYNX_API int32_t synx_cancel_async_wait(struct synx_session *pSession, struct synx_callback_params *pParams)
: De-registers a callback with a synx object
SYNX_API int32_t synx_merge(struct synx_session *pSession, struct synx_merge_params *pParams)
: Merges multiple synx objects.
SYNX_API int32_t synx_wait(struct synx_session *pSession, uint32_t hSynx, uint64_t timeout_ms)
: Waits for a synx object synchronously
Definition: synx.h:112
SYNX_API int32_t synx_get_fd(struct synx_session *pSession, uint32_t hSynx)
: Obtain an fd for the synx object(Not supported for DSP)
SYNX_API int32_t synx_create(struct synx_session *pSession, struct synx_create_params *pParam)
: Creates a synx object.
synx_signal_status
Definition: synx.h:195
Definition: synx.h:176
Definition: synx.h:150
SYNX_API int32_t synx_async_wait(struct synx_session *pSession, struct synx_callback_params *pParams)
: Registers a callback with a synx object.
SYNX_API int32_t synx_uninitialize(struct synx_session *pSession)
: Destroys the client session. Every initialized session should be uninitialized. ...
Definition: synx.h:266
synx_create_flags
Definition: synx.h:132
Definition: synx.h:316