2 * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __VISION_SOURCE_INTERFACE__
18 #define __VISION_SOURCE_INTERFACE__
22 #define BUFFER_PLANE_MAX 4
23 #define DEVICE_COUNT_MAX 16
24 #define RESOLUTION_COUNT_MAX 32
25 #define FPS_COUNT_MAX 16
26 #define DEVICE_NAME_LENGTH_MAX 16
27 #define DEVICE_NODE_PATH_LENGTH_MAX 16
34 typedef struct vision_source_resolution
38 } vision_source_resolution_s;
40 typedef enum vision_source_pixel_format
42 VISION_SOURCE_PIXEL_FORMAT_RGB24 = 0x0000,
43 VISION_SOURCE_PIXEL_FORMAT_GREY,
44 VISION_SOURCE_PIXEL_FORMAT_Y10,
45 VISION_SOURCE_PIXEL_FORMAT_NV12,
46 VISION_SOURCE_PIXEL_FORMAT_NV21,
47 VISION_SOURCE_PIXEL_FORMAT_YVU420, //YV12
48 VISION_SOURCE_PIXEL_FORMAT_YUV420, //I420
49 VISION_SOURCE_PIXEL_FORMAT_MAX
50 } vision_source_pixel_format_e;
52 typedef struct vision_source_pixel_format_list
55 vision_source_pixel_format_e
56 pixel_formats[VISION_SOURCE_PIXEL_FORMAT_MAX];
57 } vision_source_pixel_format_list_s;
59 typedef struct vision_source_resolution_list
62 vision_source_resolution_s resolutions[RESOLUTION_COUNT_MAX];
63 } vision_source_resolution_list_s;
65 typedef struct vision_source_fps_list
68 int fps[FPS_COUNT_MAX];
69 } vision_source_fps_list_s;
71 typedef struct vision_source_resolution_match_fps
73 vision_source_resolution_s resolution;
74 vision_source_fps_list_s fps_list;
75 } vision_source_resolution_match_fps_s;
77 typedef struct vision_source_resolution_match_fps_list
80 vision_source_resolution_match_fps_s resolutions[RESOLUTION_COUNT_MAX];
81 } vision_source_resolution_match_fps_list_s;
83 typedef struct vision_source_pixel_match_resolution
85 vision_source_pixel_format_e pixel_format;
86 vision_source_resolution_match_fps_list_s resolution_list;
87 } vision_source_pixel_match_resolution_s;
89 typedef struct vision_source_pixel_match_resolution_list
92 vision_source_pixel_match_resolution_s
93 pixels[VISION_SOURCE_PIXEL_FORMAT_MAX];
94 } vision_source_pixel_match_resolution_list_s;
96 typedef struct vision_source_device_info
99 char name[DEVICE_NAME_LENGTH_MAX];
100 char node_path[DEVICE_NODE_PATH_LENGTH_MAX];
101 vision_source_pixel_match_resolution_list_s pixel_list;
102 } vision_source_device_info_s;
104 typedef struct vision_source_device_info_list
107 vision_source_device_info_s device_info[DEVICE_COUNT_MAX];
108 } vision_source_device_info_list_s;
110 typedef struct vision_source_plane
113 uint32_t align_width;
114 uint32_t align_height;
117 } vision_source_plane_s;
119 typedef struct vision_source_format
121 vision_source_pixel_format_e pixel_format;
122 vision_source_resolution_s resolution;
126 } vision_source_format_s;
128 typedef struct vision_source_buffer
131 vision_source_pixel_format_e pixel_format;
132 vision_source_resolution_s resolution;
135 vision_source_plane_s planes[BUFFER_PLANE_MAX];
137 } vision_source_buffer_s;
139 typedef enum vision_source_error
141 VISION_SOURCE_ERROR_NONE = 0,
142 VISION_SOURCE_ERROR_INVALID_PARAMETER,
143 VISION_SOURCE_ERROR_INTERNAL,
144 VISION_SOURCE_ERROR_NOT_IMPLEMENTED,
145 VISION_SOURCE_ERROR_UNKNOWN
146 } vision_source_error_e;
148 typedef void *vision_source_h;
150 typedef int (*stream_cb)(vision_source_buffer_s *buffer, void *user_data);
152 typedef struct vision_source_func
154 int (*init)(vision_source_h *handle);
155 int (*exit)(vision_source_h handle);
156 int (*open_device)(vision_source_h handle, int device_index);
157 int (*close_device)(vision_source_h handle);
159 int (*enumerate_devices)(vision_source_h handle,
160 vision_source_device_info_list_s *info_list);
161 int (*set_stream_format)(vision_source_h handle,
162 vision_source_format_s *format);
164 int (*start_stream)(vision_source_h handle, stream_cb callback,
166 int (*stop_stream)(vision_source_h handle);
168 int (*get_capture_frame)(vision_source_h handle,
169 vision_source_buffer_s *buffer);
170 int (*release_capture_frame)(vision_source_h handle, int buffer_index);
171 } vision_source_func_s;
173 void attach_backend(vision_source_func_s *funcp);
179 #endif /* __VISION_SOURCE_INTERFACE__ */