Synx APIs
Synx
synx.h
Go to the documentation of this file.
1 // Copyright (c) 2019-2024 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 
65 #define SYNX_NO_TIMEOUT ((uint64_t)-1)
66 
71 #define SYNX_INVALID_HANDLE 0
72 
81 struct synx_session {
82  uint32_t type;
83  void *client;
84 };
85 
94  SYNX_CLIENT_NATIVE = 0,
95  SYNX_CLIENT_MAX,
96 };
97 
105  SYNX_INIT_DEFAULT = 0x00,
106  SYNX_INIT_MAX = 0x01,
107 };
108 
118  const char *name;
119  enum synx_client_id id;
120  enum synx_init_flags flags;
121 };
122 
138  SYNX_CREATE_LOCAL_FENCE = 0x01,
139  SYNX_CREATE_GLOBAL_FENCE = 0x02,
140  SYNX_CREATE_DMA_FENCE = 0x04,
141  SYNX_CREATE_CSL_FENCE = 0x08,
142 };
143 
157  const char *name;
158  uint32_t *h_synx;
159  void *fence;
160  enum synx_create_flags flags;
161 };
162 
176 typedef void (*synx_user_callback)(uint32_t h_synx, int status, void *data);
177 
190  uint32_t h_synx;
191  synx_user_callback cb_func;
192  void *userdata;
193  synx_user_callback cancel_cb_func;
194  uint64_t timeout_ms;
195 };
196 
209  SYNX_STATE_SIGNALED_SUCCESS = 2,
210  SYNX_STATE_SIGNALED_CANCEL = 4,
211  SYNX_STATE_SIGNALED_MAX = 64,
212 };
213 
214 
243  SYNX_IMPORT_LOCAL_FENCE = 0x01,
244  SYNX_IMPORT_GLOBAL_FENCE = 0x02,
245  SYNX_IMPORT_SYNX_FENCE = 0x04,
246  SYNX_IMPORT_DMA_FENCE = 0x08,
247  SYNX_IMPORT_EX_RELEASE = 0x10,
248 };
249 
255  SYNX_IMPORT_INDV_PARAMS = 0x01,
256  SYNX_IMPORT_ARR_PARAMS = 0x02,
257 };
258 
268  uint32_t *new_h_synx;
269  enum synx_import_flags flags;
270  void *fence;
271 };
272 
280  struct synx_import_indv_params *list;
281  uint32_t num_fences;
282 };
283 
292  enum synx_import_type type;
293  union {
294  struct synx_import_indv_params indv;
295  struct synx_import_arr_params arr;
296  };
297 };
298 
315  SYNX_MERGE_LOCAL_FENCE = 0x01,
316  SYNX_MERGE_GLOBAL_FENCE = 0x02,
317  SYNX_MERGE_NOTIFY_ON_ALL = 0x04,
318  SYNX_MERGE_NOTIFY_ON_ANY = 0x08,
319 };
320 
321 /*
322  * struct synx_merge_params - Synx merge parameters
323  *
324  * @h_synxs : Pointer to a array of synx handles to be merged.
325  * @flags : Merge flags.
326  * @num_objs : Number of synx handles to be merged.
327  * @h_merged_obj : Pointer to synx object handle passed by client.
328  * Created merged synx handle filled by function.
329  */
331  uint32_t *h_synxs;
332  enum synx_merge_flags flags;
333  uint32_t num_objs;
334  uint32_t *h_merged_obj;
335 };
336 
337 /*
338  * enum synx_status - Synx status definitions.
339  *
340  * @SYNX_STATUS_INVALID : Invalid synx object.
341  * @SYNX_STATUS_UNSIGNALED : Synx object has not been signaled.
342  * @SYNX_STATUS_SIGNALED_SUCCESS : Synx object has been signaled.
343  * @SYNX_STATUS_SIGNALED_ERROR : Synx object signaled with error.
344  * @SYNX_STATUS_SIGNALED_CANCEL : Synx object signalling cancelled.
345  * @SYNX_STATUS_SIGNALED_EXTERNAL : Synx object signaled by external dma client.
346  * @SYNX_STATUS_SIGNALED_SSR : Synx object signaled with SSR.
347  * @SYNX_STATUS_TIMEOUT : Callback status for synx object
348  * in case of timeout.
349  */
351  SYNX_STATUS_INVALID = 0,
352  SYNX_STATUS_UNSIGNALED,
353  SYNX_STATUS_SIGNALED_SUCCESS,
354  SYNX_STATUS_SIGNALED_ERROR,
355  SYNX_STATUS_SIGNALED_CANCEL,
356  SYNX_STATUS_SIGNALED_EXTERNAL,
357  SYNX_STATUS_SIGNALED_SSR,
358  SYNX_STATUS_TIMEOUT,
359 };
360 
361 
362 /* Userspace APIs */
363 
371 SYNX_API struct synx_session *synx_initialize(struct synx_initialization_params *pParam);
372 
381 SYNX_API int32_t synx_uninitialize(struct synx_session *pSession);
382 
395 SYNX_API int32_t synx_create(struct synx_session *pSession, struct synx_create_params *pParam);
396 
408 SYNX_API int32_t synx_get_status(struct synx_session *pSession, uint32_t hSynx);
409 
420 SYNX_API int32_t synx_release(struct synx_session *pSession, uint32_t hSynx);
421 
436 SYNX_API int32_t synx_signal(struct synx_session *pSession, uint32_t hSynx, enum synx_signal_status state);
437 
454 SYNX_API int32_t synx_wait(struct synx_session *pSession, uint32_t hSynx, uint64_t timeout_ms);
455 
468 SYNX_API int32_t synx_async_wait(struct synx_session *pSession, struct synx_callback_params *pParams);
469 
483 SYNX_API int32_t synx_cancel_async_wait(struct synx_session *pSession, struct synx_callback_params *pParams);
484 
497 SYNX_API int32_t synx_merge( struct synx_session *pSession, struct synx_merge_params *pParams);
498 
507 SYNX_API int32_t synx_import(struct synx_session *pSession, struct synx_import_params *pParams);
508 
522 SYNX_API int32_t synx_get_fd(struct synx_session *pSession, uint32_t hSynx);
523 
524 #ifdef __cplusplus
525 }
526 #endif // __cplusplus
527 
528 #endif // SYNX_H
synx_merge_flags
Definition: synx.h:314
Definition: synx.h:81
void(* synx_user_callback)(uint32_t h_synx, int status, void *data)
Definition: synx.h:176
Definition: synx.h:291
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:104
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:350
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:242
synx_client_id
Definition: synx.h:93
Definition: synx.h:267
synx_import_type
Definition: synx.h:254
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:117
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:208
Definition: synx.h:189
Definition: synx.h:156
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:279
synx_create_flags
Definition: synx.h:137
Definition: synx.h:330