xref: /rockchip-linux_mpp/kmpp/base/inc/kmpp_obj_func.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /* SPDX-License-Identifier: Apache-2.0 OR MIT */
2 /*
3  * Copyright (c) 2024 Rockchip Electronics Co., Ltd.
4  */
5 
6 #include "kmpp_obj_macro.h"
7 
8 #ifndef KMPP_OBJ_NAME
9 #error "KMPP_OBJ_NAME must be defined on using kmpp_obj_func.h"
10 #endif
11 
12 #ifndef KMPP_OBJ_INTF_TYPE
13 #error "KMPP_OBJ_INTF_TYPE must be defined on using kmpp_obj_func.h"
14 #endif
15 
16 #include "rk_type.h"
17 
18 /* always define object common function */
19 #define KMPP_OBJ_FUNC_DEFINE(prefix) \
20     rk_s32 CONCAT_US(prefix, size)(void); \
21     rk_s32 CONCAT_US(prefix, get)(KMPP_OBJ_INTF_TYPE *p); \
22     rk_s32 CONCAT_US(prefix, assign)(KMPP_OBJ_INTF_TYPE *p, void *buf, rk_s32 size); \
23     rk_s32 CONCAT_US(prefix, put)(KMPP_OBJ_INTF_TYPE p); \
24     rk_s32 CONCAT_US(prefix, dump)(KMPP_OBJ_INTF_TYPE p, const char *caller); \
25     KmppObjDef CONCAT_US(prefix, objdef)(void);
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 KMPP_OBJ_FUNC_DEFINE(KMPP_OBJ_NAME)
32 
33 #ifdef __cplusplus
34 }
35 #endif
36 
37 #undef KMPP_OBJ_FUNC_DEFINE
38 
39 /* entry and hook access functions */
40 #ifdef KMPP_OBJ_ENTRY_TABLE
41 /* disable all hierarchy macro in header */
42 #define CFG_DEF_START(...)
43 #define CFG_DEF_END(...)
44 #define STRUCT_START(...)
45 #define STRUCT_END(...)
46 
47 #define ENTRY_DECLARE(prefix, ftype, type, name, flag, ...) \
48     rk_s32 CONCAT_US(prefix, set, __VA_ARGS__)(KMPP_OBJ_INTF_TYPE p, type val); \
49     rk_s32 CONCAT_US(prefix, get, __VA_ARGS__)(KMPP_OBJ_INTF_TYPE p, type* val); \
50     rk_s32 CONCAT_US(prefix, test, __VA_ARGS__)(KMPP_OBJ_INTF_TYPE p);
51 
52 #define STRCT_DECLARE(prefix, ftype, type, name, flag, ...) \
53     rk_s32 CONCAT_US(prefix, set, __VA_ARGS__)(KMPP_OBJ_INTF_TYPE p, type* val); \
54     rk_s32 CONCAT_US(prefix, get, __VA_ARGS__)(KMPP_OBJ_INTF_TYPE p, type* val); \
55     rk_s32 CONCAT_US(prefix, test, __VA_ARGS__)(KMPP_OBJ_INTF_TYPE p);
56 
57 #define ALIAS_DECLARE(prefix, ftype, type, name, flag, ...)
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 KMPP_OBJ_ENTRY_TABLE(KMPP_OBJ_NAME, ENTRY_DECLARE, STRCT_DECLARE,
64                      ENTRY_DECLARE, STRCT_DECLARE, ALIAS_DECLARE)
65 
66 #ifdef __cplusplus
67 }
68 #endif
69 
70 #undef ENTRY_DECLARE
71 #undef ENTRY_TO_ALIAS
72 #undef STRCT_DECLARE
73 
74 #undef CFG_DEF_START
75 #undef CFG_DEF_END
76 #undef STRUCT_START
77 #undef STRUCT_END
78 
79 #endif /* KMPP_OBJ_ENTRY_TABLE */
80 
81 #ifdef KMPP_OBJ_FUNC_IOCTL
82 
83 #define IOCTL_CTX(prefix, func, ...) \
84     rk_s32 CONCAT_US(prefix, func)(KMPP_OBJ_INTF_TYPE ctx);
85 
86 #define IOCTL_IN_(prefix, func, in_type, ...) \
87     rk_s32 CONCAT_US(prefix, func)(KMPP_OBJ_INTF_TYPE ctx, in_type in);
88 
89 #define IOCTL_OUT(prefix, func, out_type, ...) \
90     rk_s32 CONCAT_US(prefix, func)(KMPP_OBJ_INTF_TYPE ctx, out_type *out);
91 
92 #define IOCTL_IO_(prefix, func, in_type, out_type, ...) \
93     rk_s32 CONCAT_US(prefix, func)(KMPP_OBJ_INTF_TYPE ctx, in_type in, out_type *out);
94 
95 #ifdef __cplusplus
96 extern "C" {
97 #endif
98 
99 KMPP_OBJ_FUNC_IOCTL(KMPP_OBJ_NAME, IOCTL_CTX, IOCTL_IN_, IOCTL_OUT, IOCTL_IO_)
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
105 #undef IOCTL_CTX
106 #undef IOCTL_IN_
107 #undef IOCTL_OUT
108 #undef IOCTL_IO_
109 
110 #endif /* KMPP_OBJ_FUNC_IOCTL */
111 
112 #undef KMPP_OBJ_NAME
113 #undef KMPP_OBJ_INTF_TYPE
114 #undef KMPP_OBJ_ENTRY_TABLE
115 #undef KMPP_OBJ_FUNC_IOCTL
116