Support continuous capture
[platform/adaptation/camera-hal-v4l2.git] / src / tizen_camera_v4l2_private.h
1 /*
2  * tizen_camera_private.c
3  *
4  * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19
20 #ifndef __TIZEN_CAMERA_PRIVATE_H__
21 #define __TIZEN_CAMERA_PRIVATE_H__
22
23 #include <linux/videodev2.h>
24 #include <glib.h>
25 #include <tbm_bufmgr.h>
26 #include <tizen-camera.h>
27
28 #define CAMERA_HAL_INITIAL_INDEX    -1
29 #define CAMERA_HAL_INITIAL_FD       -1
30 #define MESSAGE_CALLBACK_MAX        10
31 #define BUFFER_MAX                  4
32 #define V4L2_PLANES_MAX             4
33
34 typedef struct _camera_hal_handle {
35         /* tbm */
36         tbm_bufmgr bufmgr;
37
38         /* device */
39         gint32 device_index;
40         gint32 device_fd;
41
42         /* buffer */
43         guint32 buffer_dequeued_count;
44         GThread *buffer_thread;
45         gboolean buffer_thread_run;
46         guint32 buffer_count;
47         camera_buffer_t camera_buffers[BUFFER_MAX];
48         enum v4l2_buf_type buffer_type;
49         GMutex buffer_lock;
50         GCond buffer_cond;
51
52         /* preview */
53         camera_format_t preview_format;
54         camera_preview_frame_cb preview_cb;
55         gpointer preview_cb_data;
56
57         /* capture */
58         camera_capture_cb capture_cb;
59         gpointer capture_cb_data;
60         guint32 capture_count;
61         guint32 capture_interval_ms;
62         guint32 captured_count;
63         gboolean capture_request;
64         gboolean capture_restart_stream;
65
66         /* message */
67         GThread *msg_thread;
68         camera_message_cb msg_cb[MESSAGE_CALLBACK_MAX];
69         gpointer msg_cb_data[MESSAGE_CALLBACK_MAX];
70         gboolean msg_cb_run;
71         GQueue *msg_list;
72         GMutex msg_cb_lock;
73         GCond msg_cb_cond;
74
75         /* etc */
76         GMutex lock;
77         camera_state_t state;
78 } camera_hal_handle;
79
80 #endif /* __TIZEN_CAMERA_PRIVATE_H__ */