-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathmtl_sch_api.h
More file actions
147 lines (130 loc) · 3.28 KB
/
mtl_sch_api.h
File metadata and controls
147 lines (130 loc) · 3.28 KB
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
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2023 Intel Corporation
*/
/**
* @file mtl_sch_api.h
*
* This header define the public interfaces of sch.
*
*/
#include "mtl_api.h"
#ifndef _MTL_SCH_API_HEAD_H_
#define _MTL_SCH_API_HEAD_H_
#if defined(__cplusplus)
extern "C" {
#endif
/**
* Handle to mtl sch context
*/
typedef struct mtl_sch_impl* mtl_sch_handle;
typedef struct mt_sch_tasklet_impl* mtl_tasklet_handle;
/** the tasklet is likely has pending task */
#define MTL_TASKLET_HAS_PENDING (1)
/** the tasklet is likely has finished all task */
#define MTL_TASKLET_ALL_DONE (0)
/**
* The structure describing how to create a sch.
*/
struct mtl_sch_ops {
/** name */
const char* name;
/** the max number of tasklet in this sch, leave to zero to use the default value */
uint32_t nb_tasklets;
};
/**
* The structure describing how to create a tasklet. Tasklet share the time slot on a
* sch, only non-block method can be used in handler routine.
*/
struct mtl_tasklet_ops {
/** name */
const char* name;
/** private data to the callback */
void* priv;
/** the callback at the time when the sch started */
int (*start)(void* priv);
/** the callback at the time when the sch stopped */
int (*stop)(void* priv);
/**
* the callback for task routine, only non-block method can be used for this callback
* since all tasklets share the CPU time. Return MTL_TASKLET_ALL_DONE if no any pending
* task, all are done. Return MTL_TASKLET_HAS_PENDING if it has pending tasks.
*/
int (*handler)(void* priv);
/**
* the recommend sleep time(us) if all tasklet report MTL_TASKLET_ALL_DONE.
* also this value can be set by mtl_tasklet_set_sleep at runtime.
* leave to zero if you don't know.
*/
uint64_t advice_sleep_us;
};
/**
* Create one sch from media transport context.
*
* @param mt
* The handle to the media transport context.
* @param ops
* The ops to create the sch.
* @return
* - NULL on error.
* - Otherwise, the handle to the sch.
*/
mtl_sch_handle mtl_sch_create(mtl_handle mt, struct mtl_sch_ops* ops);
/**
* Start the sch.
*
* @param sch
* The handle to sch context.
* @return
* - 0: Success.
* - <0: Error code.
*/
int mtl_sch_start(mtl_sch_handle sch);
/**
* Stop the sch.
*
* @param sch
* The handle to sch context.
* @return
* - 0: Success.
* - <0: Error code.
*/
int mtl_sch_stop(mtl_sch_handle sch);
/**
* Free the sch.
*
* @param sch
* The handle to sch context.
* @return
* - 0: Success.
* - <0: Error code.
*/
int mtl_sch_free(mtl_sch_handle sch);
/**
* Register one tasklet into the sch. One tasklet can be registered at runtime after
* mtl_sch_start.
*
* @param sch
* The sch context.
* @param tasklet_ops
* The tasklet ops
* @return
* - NULL on error.
* - Otherwise, the handle to the tasklet.
*/
mtl_tasklet_handle mtl_sch_register_tasklet(struct mtl_sch_impl* sch,
struct mtl_tasklet_ops* tasklet_ops);
/**
* Unregister the tasklet from the bind sch. One tasklet can be unregistered at runtime
* before mtl_sch_start.
*
* @param sch
* The handle to sch context.
* @return
* - 0: Success.
* - <0: Error code.
*/
int mtl_sch_unregister_tasklet(mtl_tasklet_handle tasklet);
#if defined(__cplusplus)
}
#endif
#endif