halcc: Introduce halcc library
[platform/hal/api/common.git] / halcc / src / halcc-object.h
1 /*
2  * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __HALCC_OBJECT_H__
18 #define __HALCC_OBJECT_H__
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 #include <stdbool.h>
25 #include <glib.h>
26
27 typedef enum halcc_manifest_type_e {
28         HALCC_MANIFEST_TYPE_NONE = 0,
29         HALCC_MANIFEST_TYPE_HAL_API,
30         HALCC_MANIFEST_TYPE_HAL_BACKEND,
31 } halcc_manifest_type_e;
32
33 typedef enum halcc_transport_e {
34         HALCC_TRANSPORT_NONE = 0,
35         HALCC_TRANSPORT_PASSTHROUGH,
36         HALCC_TRANSPORT_IPC,
37 } halcc_transport_e;
38
39 typedef enum halcc_dependency_state_e {
40         HALCC_DEPENDENCY_STATE_NONE = 0,
41         HALCC_DEPENDENCY_STATE_VALIDATING,
42         HALCC_DEPENDENCY_STATE_SUCCESS,
43         HALCC_DEPENDENCY_STATE_FAIL,
44 } halcc_dependency_state_e;
45
46 typedef struct halcc_manifest halcc_manifest;
47 typedef struct halcc_hal halcc_hal;
48 typedef struct halcc_interface halcc_interface;
49
50 typedef void (*halcc_iter_cb) (void *, void *);
51
52 int halcc_manifest_new(halcc_manifest **manifest);
53 void halcc_manifest_free(halcc_manifest *manifest);
54 int halcc_manifest_set_type(halcc_manifest *manifest, halcc_manifest_type_e type);
55 int halcc_manifest_get_type(halcc_manifest *manifest, halcc_manifest_type_e *type);
56 int halcc_manifest_set_version(halcc_manifest *manifest, int major, int minor);
57 int halcc_manifest_get_version(halcc_manifest *manifest, int *major, int *minor);
58 int halcc_manifest_set_level(halcc_manifest *manifest, int level);
59 int halcc_manifest_get_level(halcc_manifest *manifest, int *level);
60 int halcc_manifest_add_hal(halcc_manifest *manifest, halcc_hal *hal);
61 int halcc_manifest_find_hal(halcc_manifest *manifest,
62         const char *hal_name, int major, int minor, halcc_hal **hal);
63 int halcc_manifest_find_hal_raw(halcc_manifest *manifest,
64         halcc_hal *raw, halcc_hal **hal);
65 int halcc_manifest_find_hal_backward_compatible(halcc_manifest *manifest,
66         const char *hal_name, int major, int minor, halcc_hal **hal);
67 int halcc_manifest_find_hal_backward_compatible_raw(halcc_manifest *manifest,
68         halcc_hal *raw, halcc_hal **hal);
69 int halcc_manifest_find_hal_forward_compatible(halcc_manifest *manifest,
70         const char *hal_name, int major, int minor, halcc_hal **hal);
71 int halcc_manifest_find_hal_forward_compatible_raw(halcc_manifest *manifest,
72         halcc_hal *raw, halcc_hal **hal);
73 int halcc_manifest_steal_hal(halcc_manifest *manifest,
74         const char *hal_name, int major, int minor, halcc_hal **hal);
75 void halcc_manifest_remove_hal(halcc_manifest *manifest,
76         const char *hal_name, int major, int minor);
77 void halcc_manifest_foreach_hal(halcc_manifest *manifest,
78         halcc_iter_cb cb, void *user_data);
79
80 int halcc_hal_new(halcc_hal **hal);
81 void halcc_hal_free(halcc_hal *hal);
82 int halcc_hal_set_name(halcc_hal *hal, const char *hal_name);
83 int halcc_hal_get_name(halcc_hal *hal, const char **hal_name);
84 int halcc_hal_set_version(halcc_hal *hal, int major, int min_minor, int max_minor);
85 int halcc_hal_get_version(halcc_hal *hal, int *major, int *min_minor, int *max_minor);
86 int halcc_hal_set_transport(halcc_hal *hal, halcc_transport_e transport);
87 int halcc_hal_get_transport(halcc_hal *hal, halcc_transport_e *transport);
88 int halcc_hal_add_dependency(halcc_hal *hal, halcc_hal *dependency);
89 void halcc_hal_remove_dependency(halcc_hal *hal,
90         const char *dependency_hal_name, int major, int minor);
91 void halcc_hal_foreach_dependency(halcc_hal *hal, halcc_iter_cb cb, void *user_data);
92 int halcc_hal_add_interface(halcc_hal *hal, halcc_interface *interface);
93 void halcc_hal_remove_interface(halcc_hal *hal,
94         const char *interface_name, const char *instance_id);
95 void halcc_hal_foreach_interface(halcc_hal *hal, halcc_iter_cb cb, void *user_data);
96
97 int halcc_interface_new(halcc_interface **interface);
98 void halcc_interface_free(halcc_interface *interface);
99 int halcc_interface_set_name(halcc_interface *interface, const char *interface_name);
100 int halcc_interface_get_name(halcc_interface *interface, const char **interface_name);
101 int halcc_interface_set_instance_id(halcc_interface *interface, const char *instance_id);
102 int halcc_interface_get_instance_id(halcc_interface *interface, const char **instance_id);
103
104 #ifdef __cplusplus
105 }
106 #endif
107
108 #endif // __HALCC_OBJECT_H__