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__
21 #include <media_packet.h>
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
35 typedef struct vision_source_resolution
39 } vision_source_resolution_s;
41 typedef enum vision_source_pixel_format
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;
55 typedef struct vision_source_pixel_format_list
58 vision_source_pixel_format_e
59 pixel_formats[VISION_SOURCE_PIXEL_FORMAT_MAX];
60 } vision_source_pixel_format_list_s;
62 typedef struct vision_source_resolution_list
65 vision_source_resolution_s resolutions[RESOLUTION_COUNT_MAX];
66 } vision_source_resolution_list_s;
68 typedef struct vision_source_fps_list
71 int fps[FPS_COUNT_MAX];
72 } vision_source_fps_list_s;
74 typedef struct vision_source_resolution_match_fps
76 vision_source_resolution_s resolution;
77 vision_source_fps_list_s fps_list;
78 } vision_source_resolution_match_fps_s;
80 typedef struct vision_source_resolution_match_fps_list
83 vision_source_resolution_match_fps_s resolutions[RESOLUTION_COUNT_MAX];
84 } vision_source_resolution_match_fps_list_s;
86 typedef struct vision_source_pixel_match_resolution
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;
92 typedef struct vision_source_pixel_match_resolution_list
95 vision_source_pixel_match_resolution_s
96 pixels[VISION_SOURCE_PIXEL_FORMAT_MAX];
97 } vision_source_pixel_match_resolution_list_s;
99 typedef struct vision_source_device_info
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;
107 typedef struct vision_source_device_info_list
110 vision_source_device_info_s device_info[DEVICE_COUNT_MAX];
111 } vision_source_device_info_list_s;
113 typedef struct vision_source_plane
116 uint32_t align_width;
117 uint32_t align_height;
120 } vision_source_plane_s;
122 typedef struct vision_source_format
124 vision_source_pixel_format_e pixel_format;
125 vision_source_resolution_s resolution;
129 } vision_source_format_s;
131 typedef struct vision_source_buffer
134 vision_source_pixel_format_e pixel_format;
135 vision_source_resolution_s resolution;
138 vision_source_plane_s planes[BUFFER_PLANE_MAX];
141 } vision_source_buffer_s;
143 typedef enum vision_source_error
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;
152 typedef void *vision_source_h;
154 typedef int (*stream_cb)(media_packet_h pkt, void *user_data);
156 typedef struct vision_source_func
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);
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);
168 int (*start_stream)(vision_source_h handle, stream_cb callback,
170 int (*stop_stream)(vision_source_h handle);
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;
178 void attach_backend(vision_source_func_s *funcp);
184 #endif /* __VISION_SOURCE_INTERFACE__ */