2 * hal_camera_v4l2_private.h
4 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #ifndef __HAL_CAMERA_V4L2_PRIVATE_H__
21 #define __HAL_CAMERA_V4L2_PRIVATE_H__
23 #include <linux/videodev2.h>
25 #include <tbm_bufmgr.h>
26 #include <hal/hal-common-interface.h>
27 #include <hal/hal-camera-interface.h>
32 #define v4l2_fd_open(fd, flags) (fd)
33 #define v4l2_close close
35 #define v4l2_ioctl ioctl
36 #define v4l2_read read
37 #define v4l2_mmap mmap
38 #define v4l2_munmap munmap
39 #endif /* ENABLE_LIBV4L2 */
41 #define CAMERA_HAL_INITIAL_INDEX -1
42 #define CAMERA_HAL_INITIAL_FD -1
43 #define MESSAGE_CALLBACK_MAX 10
45 #define V4L2_PLANES_MAX 4
46 #define EXTRA_PREVIEW_STREAM_MAX 10
48 typedef struct _set_batch_table_s {
53 typedef struct _camera_hal_handle {
62 guint32 buffer_dequeued_count;
63 GThread *buffer_thread;
64 gboolean buffer_thread_run;
66 camera_buffer_s camera_buffers[BUFFER_MAX];
67 enum v4l2_buf_type buffer_type;
72 camera_format_s preview_format;
73 hal_camera_preview_frame_cb preview_cb;
74 gpointer preview_cb_data;
75 hal_camera_extra_preview_frame_cb extra_preview_cb;
76 gpointer extra_preview_cb_data;
77 GMutex extra_preview_lock;
78 camera_format_s extra_preview_format[EXTRA_PREVIEW_STREAM_MAX];
81 hal_camera_capture_cb capture_cb;
82 gpointer capture_cb_data;
83 guint32 capture_count;
84 guint32 capture_interval_ms;
85 guint32 captured_count;
86 gboolean capture_request;
87 gboolean capture_restart_stream;
91 hal_camera_message_cb msg_cb[MESSAGE_CALLBACK_MAX];
92 gpointer msg_cb_data[MESSAGE_CALLBACK_MAX];
105 camera_state_e state;
108 int camera_v4l2_init(void **camera_handle);
109 int camera_v4l2_deinit(void *camera_handle);
110 int camera_v4l2_get_device_info_list(camera_device_info_list_s *device_info_list);
111 int camera_v4l2_open_device(void *camera_handle, int device_index);
112 int camera_v4l2_open_device_ext(void *camera_handle, const char *device_name);
113 int camera_v4l2_close_device(void *camera_handle);
114 int camera_v4l2_add_message_callback(void *camera_handle, hal_camera_message_cb callback, void *user_data, uint32_t *cb_id);
115 int camera_v4l2_remove_message_callback(void *camera_handle, uint32_t cb_id);
116 int camera_v4l2_set_preview_stream_format(void *camera_handle, camera_format_s *format);
117 int camera_v4l2_get_preview_stream_format(void *camera_handle, camera_format_s *format);
118 int camera_v4l2_set_user_buffer_fd(void *camera_handle, int *fds, int number);
119 int camera_v4l2_start_preview(void *camera_handle, hal_camera_preview_frame_cb callback, void *user_data);
120 int camera_v4l2_release_preview_buffer(void *camera_handle, int buffer_index);
121 int camera_v4l2_stop_preview(void *camera_handle);
122 int camera_v4l2_start_auto_focus(void *camera_handle);
123 int camera_v4l2_stop_auto_focus(void *camera_handle);
124 int camera_v4l2_start_capture(void *camera_handle, hal_camera_capture_cb callback, void *user_data);
125 int camera_v4l2_stop_capture(void *camera_handle);
126 int camera_v4l2_set_video_stream_format(void *camera_handle, camera_format_s *format);
127 int camera_v4l2_get_video_stream_format(void *camera_handle, camera_format_s *format);
128 int camera_v4l2_start_record(void *camera_handle, hal_camera_video_frame_cb callback, void *user_data);
129 int camera_v4l2_release_video_buffer(void *camera_handle, int buffer_index);
130 int camera_v4l2_stop_record(void *camera_handle);
131 int camera_v4l2_set_command(void *camera_handle, int64_t command, void *value);
132 int camera_v4l2_get_command(void *camera_handle, int64_t command, void **value);
133 int camera_v4l2_set_batch_command(void *camera_handle, camera_batch_command_control_s *batch_command, int64_t *error_command);
135 #endif /* __HAL_CAMERA_V4L2_PRIVATE_H__ */