Add new type and ioctl function
[platform/core/multimedia/vision-source.git] / include / vision_source_interface.h
1 /**
2  * Copyright (c) 2022 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 __VISION_SOURCE_INTERFACE__
18 #define __VISION_SOURCE_INTERFACE__
19
20 #include <stdint.h>
21 #include <media_packet.h>
22
23 #define BUFFER_PLANE_MAX 4
24 #define DEVICE_COUNT_MAX 16
25 #define RESOLUTION_COUNT_MAX 32
26 #define FPS_COUNT_MAX 16
27 #define DEVICE_NAME_LENGTH_MAX 16
28 #define DEVICE_NODE_PATH_LENGTH_MAX 16
29
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34
35 typedef struct vision_source_resolution
36 {
37         uint32_t width;
38         uint32_t height;
39 } vision_source_resolution_s;
40
41 typedef enum vision_source_pixel_format
42 {
43         VISION_SOURCE_PIXEL_FORMAT_RGB24 = 0x0000,
44         VISION_SOURCE_PIXEL_FORMAT_GREY,
45         VISION_SOURCE_PIXEL_FORMAT_Y10,
46         VISION_SOURCE_PIXEL_FORMAT_NV12,
47         VISION_SOURCE_PIXEL_FORMAT_NV21,
48         VISION_SOURCE_PIXEL_FORMAT_YVU420, //YV12
49         VISION_SOURCE_PIXEL_FORMAT_YUV420, //I420
50         VISION_SOURCE_PIXEL_FORMAT_Z32F, //FP32 depth data(millimeter distance)
51         VISION_SOURCE_PIXEL_FORMAT_Z16U, //U16 depth data(millimeter distance)
52         VISION_SOURCE_PIXEL_FORMAT_MAX
53 } vision_source_pixel_format_e;
54
55 typedef struct vision_source_pixel_format_list
56 {
57         uint32_t count;
58         vision_source_pixel_format_e
59                         pixel_formats[VISION_SOURCE_PIXEL_FORMAT_MAX];
60 } vision_source_pixel_format_list_s;
61
62 typedef struct vision_source_resolution_list
63 {
64         uint32_t count;
65         vision_source_resolution_s resolutions[RESOLUTION_COUNT_MAX];
66 } vision_source_resolution_list_s;
67
68 typedef struct vision_source_fps_list
69 {
70         uint32_t count;
71         int fps[FPS_COUNT_MAX];
72 } vision_source_fps_list_s;
73
74 typedef struct vision_source_resolution_match_fps
75 {
76         vision_source_resolution_s resolution;
77         vision_source_fps_list_s fps_list;
78 } vision_source_resolution_match_fps_s;
79
80 typedef struct vision_source_resolution_match_fps_list
81 {
82         uint32_t count;
83         vision_source_resolution_match_fps_s resolutions[RESOLUTION_COUNT_MAX];
84 } vision_source_resolution_match_fps_list_s;
85
86 typedef struct vision_source_pixel_match_resolution
87 {
88         vision_source_pixel_format_e pixel_format;
89         vision_source_resolution_match_fps_list_s resolution_list;
90 } vision_source_pixel_match_resolution_s;
91
92 typedef struct vision_source_pixel_match_resolution_list
93 {
94         uint32_t count;
95         vision_source_pixel_match_resolution_s
96                         pixels[VISION_SOURCE_PIXEL_FORMAT_MAX];
97 } vision_source_pixel_match_resolution_list_s;
98
99 typedef struct vision_source_device_info
100 {
101         uint32_t index;
102         char name[DEVICE_NAME_LENGTH_MAX];
103         char node_path[DEVICE_NODE_PATH_LENGTH_MAX];
104         vision_source_pixel_match_resolution_list_s pixel_list;
105 } vision_source_device_info_s;
106
107 typedef struct vision_source_device_info_list
108 {
109         uint32_t count;
110         vision_source_device_info_s device_info[DEVICE_COUNT_MAX];
111 } vision_source_device_info_list_s;
112
113 typedef struct vision_source_plane
114 {
115         unsigned char *data;
116         uint32_t align_width;
117         uint32_t align_height;
118         uint32_t size;
119         uint32_t used_size;
120 } vision_source_plane_s;
121
122 typedef struct vision_source_format
123 {
124         vision_source_pixel_format_e pixel_format;
125         vision_source_resolution_s resolution;
126         uint32_t fps;
127         uint32_t quality;
128         uint32_t bitrate;
129 } vision_source_format_s;
130
131 typedef struct vision_source_buffer
132 {
133         int index;
134         vision_source_pixel_format_e pixel_format;
135         vision_source_resolution_s resolution;
136         uint32_t total_size;
137         uint32_t num_planes;
138         vision_source_plane_s planes[BUFFER_PLANE_MAX];
139         uint64_t timestamp;
140         void *priv;
141 } vision_source_buffer_s;
142
143 typedef enum vision_source_error
144 {
145         VISION_SOURCE_ERROR_NONE = 0,
146         VISION_SOURCE_ERROR_INVALID_PARAMETER,
147         VISION_SOURCE_ERROR_INTERNAL,
148         VISION_SOURCE_ERROR_NOT_IMPLEMENTED,
149         VISION_SOURCE_ERROR_UNKNOWN
150 } vision_source_error_e;
151
152 typedef void *vision_source_h;
153
154 typedef int (*stream_cb)(media_packet_h pkt, void *user_data);
155
156 typedef struct vision_source_func
157 {
158         int (*init)(vision_source_h *handle);
159         int (*exit)(vision_source_h handle);
160         int (*open_device)(vision_source_h handle, int device_index);
161         int (*close_device)(vision_source_h handle);
162
163         int (*enumerate_devices)(vision_source_h handle,
164                                                                 vision_source_device_info_list_s *info_list);
165         int (*set_stream_format)(vision_source_h handle,
166                                                                 vision_source_format_s *format);
167
168         int (*start_stream)(vision_source_h handle, stream_cb callback,
169                                                 void *user_data);
170         int (*stop_stream)(vision_source_h handle);
171
172         int (*get_capture_frame)(vision_source_h handle,
173                                                                 vision_source_buffer_s *buffer);
174         int (*release_capture_frame)(vision_source_h handle, int buffer_index);
175         int (*ioctl)(vision_source_h handle, int request, void *arg);
176 } vision_source_func_s;
177
178 void attach_backend(vision_source_func_s *funcp);
179
180 #ifdef __cplusplus
181 }
182 #endif
183
184 #endif /* __VISION_SOURCE_INTERFACE__ */