Support Next HAL for tizen 6.5 82/252582/3 accepted/tizen/unified/20210209.124342 submit/tizen/20210209.044918 submit/tizen/20210209.072453
authorJeongmo Yang <jm80.yang@samsung.com>
Fri, 29 Jan 2021 12:36:21 +0000 (21:36 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Mon, 8 Feb 2021 11:02:57 +0000 (20:02 +0900)
[Version] 0.1.0
[Issue Type] Update

Change-Id: I649fa88fef88033f2efe1ad263219e39c8db1452
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
configure.ac
packaging/camera-hal-v4l2.spec
src/Makefile.am
src/hal_camera_v4l2.c [moved from src/tizen_camera_v4l2.c with 87% similarity]
src/hal_camera_v4l2_private.h [new file with mode: 0644]
src/tizen_camera_v4l2_private.h [deleted file]

index e605900..ef6f7fc 100644 (file)
@@ -35,6 +35,12 @@ PKG_CHECK_MODULES(DLOG, dlog)
 AC_SUBST(DLOG_CFLAGS)
 AC_SUBST(DLOG_LIBS)
 
+PKG_CHECK_MODULES(HAL_API_COMMON, hal-api-common)
+AC_SUBST(HAL_API_COMMON_CFLAGS)
+
+PKG_CHECK_MODULES(HAL_API_CAMERA, hal-api-camera)
+AC_SUBST(HAL_API_CAMERA_CFLAGS)
+
 # Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS([fcntl.h memory.h stdlib.h string.h sys/time.h unistd.h])
index 61e7eee..fa0d652 100644 (file)
@@ -1,6 +1,6 @@
 Name:       camera-hal-v4l2
 Summary:    Tizen Camera Hal for V4L2
-Version:    0.0.13
+Version:    0.1.0
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
@@ -10,8 +10,8 @@ Requires(postun): /sbin/ldconfig
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(libtbm)
 BuildRequires:  pkgconfig(dlog)
-BuildRequires:  mm-hal-interface-devel
-BuildRequires:  gtest-devel
+BuildRequires:  pkgconfig(hal-api-common)
+BuildRequires:  pkgconfig(hal-api-camera)
 
 %description
 Tizen Camera Hal for V4L2.
@@ -23,7 +23,7 @@ Tizen Camera Hal for V4L2.
 
 %build
 ./autogen.sh
-%configure --disable-static
+%configure --disable-static --libdir=%{_hal_libdir}
 make %{?jobs:-j%jobs}
 
 %install
@@ -39,5 +39,5 @@ make %{?jobs:-j%jobs}
 %manifest %{name}.manifest
 %license LICENSE.APLv2
 %defattr(-,root,root,-)
-%{_libdir}/*.so
+%{_hal_libdir}/*.so
 
index 46be497..58cb115 100644 (file)
@@ -1,20 +1,24 @@
 ACLOCAL_AMFLAGS='-I m4'
 
-lib_LTLIBRARIES = libtizen-camera.la
+lib_LTLIBRARIES = libhal-backend-camera.la
 
-noinst_HEADERS = tizen_camera_v4l2_private.h
+noinst_HEADERS = hal_camera_v4l2_private.h
 
-libtizen_camera_la_SOURCES = tizen_camera_v4l2.c
+libhal_backend_camera_la_SOURCES = hal_camera_v4l2.c
 
-libtizen_camera_la_CFLAGS = -I$(srcdir)/include \
-                            $(GLIB_CFLAGS) \
-                            $(DLOG_CFLAGS) \
-                            $(TBM_CFLAGS)
+libhal_backend_camera_la_CFLAGS = \
+       -I$(srcdir)/include \
+       $(GLIB_CFLAGS) \
+       $(DLOG_CFLAGS) \
+       $(HAL_API_COMMON_CFLAGS) \
+       $(HAL_API_CAMERA_CFLAGS) \
+       $(TBM_CFLAGS)
 
-libtizen_camera_la_LIBADD = $(GLIB_LIBS) \
-                           $(DLOG_LIBS) \
-                           $(TBM_LIBS)
+libhal_backend_camera_la_LIBADD = \
+       $(GLIB_LIBS) \
+       $(DLOG_LIBS) \
+       $(TBM_LIBS)
 
-libtizen_camera_la_CFLAGS += -fdata-sections -ffunction-sections -Wl,--gc-sections
-libtizen_camera_la_LDFLAGS = -Wl,--gc-sections -avoid-version
+libhal_backend_camera_la_CFLAGS += -fdata-sections -ffunction-sections -Wl,--gc-sections
+libhal_backend_camera_la_LDFLAGS = -Wl,--gc-sections -avoid-version
 
similarity index 87%
rename from src/tizen_camera_v4l2.c
rename to src/hal_camera_v4l2.c
index 11c1b32..e82d995 100644 (file)
@@ -33,7 +33,7 @@
 #include <glob.h>
 #include <dlog.h>
 #include <sched.h>
-#include "tizen_camera_v4l2_private.h"
+#include "hal_camera_v4l2_private.h"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
        (fourcc >> 24) & 0xff
 
 
-static camera_device_info_list_t *g_device_info_list;
+static camera_device_info_list_s *g_device_info_list;
 static guint32 g_device_caps;
 static GMutex g_device_info_lock;
 
 
 static void __camera_hal_v4l2_destructor(void) __attribute__((destructor));
 
+
 static void __camera_hal_v4l2_destructor(void)
 {
        LOGD("release device info list %p", g_device_info_list);
@@ -68,6 +69,7 @@ static void __camera_hal_v4l2_destructor(void)
        return;
 }
 
+
 static int __camera_v4l2_wait_frame(int device_fd, int wait_time)
 {
        int ret = CAMERA_ERROR_NONE;
@@ -322,6 +324,7 @@ static int __camera_get_format(guint32 fourcc, int *pixel_format)
        return CAMERA_ERROR_NONE;
 }
 
+
 static int __camera_get_fourcc_plane_num(int pixel_format, guint32 *fourcc, guint32 *plane_num)
 {
        if (!fourcc || !plane_num) {
@@ -374,7 +377,7 @@ static int __camera_get_fourcc_plane_num(int pixel_format, guint32 *fourcc, guin
 }
 
 
-static int __camera_get_device_info(int device_index, int device_fd, camera_device_info_t *device_info, char *node_path)
+static int __camera_get_device_info(int device_index, int device_fd, camera_device_info_s *device_info, char *node_path)
 {
        int i = 0;
        int j = 0;
@@ -479,6 +482,7 @@ static int __camera_get_device_info(int device_index, int device_fd, camera_devi
        return CAMERA_ERROR_NONE;
 }
 
+
 static int __camera_get_device_info_list(void)
 {
        int i = 0;
@@ -487,7 +491,7 @@ static int __camera_get_device_info_list(void)
        int device_fd = CAMERA_HAL_INITIAL_FD;
        glob_t glob_buf;
        struct v4l2_capability v4l2_cap;
-       camera_device_info_list_t *device_info_list = NULL;
+       camera_device_info_list_s *device_info_list = NULL;
 
        g_mutex_lock(&g_device_info_lock);
 
@@ -497,7 +501,7 @@ static int __camera_get_device_info_list(void)
                goto _GET_DEVICE_INFO_LIST_DONE;
        }
 
-       device_info_list = g_new0(camera_device_info_list_t, 1);
+       device_info_list = g_new0(camera_device_info_list_s, 1);
        if (!device_info_list) {
                LOGE("failed to alloc device info structure");
                ret = CAMERA_ERROR_OUT_OF_MEMORY;
@@ -585,7 +589,7 @@ _GET_DEVICE_INFO_LIST_DONE:
 }
 
 
-static int __camera_stop_stream(camera_hal_handle *handle, uint32_t buffer_count)
+static int __camera_stop_stream(hal_camera_handle *handle, uint32_t buffer_count)
 {
        int i = 0;
        int ret = CAMERA_ERROR_NONE;
@@ -626,12 +630,12 @@ static int __camera_stop_stream(camera_hal_handle *handle, uint32_t buffer_count
 }
 
 
-static int __camera_start_stream(camera_hal_handle *handle, camera_pixel_format_t pixel_format,
-       camera_resolution_t *resolution, uint32_t fps, uint32_t request_buffer_count)
+static int __camera_start_stream(hal_camera_handle *handle, camera_pixel_format_e pixel_format,
+       camera_resolution_s *resolution, uint32_t fps, uint32_t request_buffer_count)
 {
        int i = 0;
        int ret = CAMERA_ERROR_NONE;
-       camera_buffer_t *buffer = NULL;
+       camera_buffer_s *buffer = NULL;
        struct v4l2_format v4l2_fmt;
        struct v4l2_streamparm v4l2_parm;
        struct v4l2_buffer v4l2_buf;
@@ -770,7 +774,7 @@ _START_STREAM_FAILED:
 }
 
 
-static void __camera_do_capture(camera_hal_handle *handle)
+static void __camera_do_capture(hal_camera_handle *handle)
 {
        int ret = CAMERA_ERROR_NONE;
        int buffer_index = 0;
@@ -851,7 +855,7 @@ static void __camera_do_capture(camera_hal_handle *handle)
                        handle->capture_cb, buffer_index, handle->captured_count);
 
                if (handle->capture_cb) {
-                       ((camera_capture_cb)handle->capture_cb)(&handle->camera_buffers[buffer_index],
+                       handle->capture_cb(&handle->camera_buffers[buffer_index],
                                NULL, NULL, handle->capture_cb_data);
                } else {
                        LOGW("capture callback is NULL");
@@ -902,7 +906,7 @@ _CAPTURE_DONE:
 static void *__camera_buffer_handler_func(gpointer data)
 {
        int index = 0;
-       camera_hal_handle *handle = (camera_hal_handle *)data;
+       hal_camera_handle *handle = (hal_camera_handle *)data;
 
        if (!handle) {
                LOGE("NULL handle for buffer handler");
@@ -942,10 +946,10 @@ static void *__camera_buffer_handler_func(gpointer data)
                g_mutex_unlock(&handle->buffer_lock);
 
                if (handle->preview_cb) {
-                       ((camera_preview_frame_cb)handle->preview_cb)(&handle->camera_buffers[index], NULL, handle->preview_cb_data);
+                       handle->preview_cb(&handle->camera_buffers[index], NULL, handle->preview_cb_data);
                } else {
                        LOGW("preview callback is NULL");
-                       camera_release_preview_buffer((void *)handle, index);
+                       camera_v4l2_release_preview_buffer((void *)handle, index);
                }
 
                /* check capture request flag */
@@ -969,7 +973,7 @@ static void *__camera_buffer_handler_func(gpointer data)
 
 static void __camera_message_release_func(gpointer data)
 {
-       camera_message_t *message = (camera_message_t *)data;
+       camera_message_s *message = (camera_message_s *)data;
 
        if (!message) {
                LOGW("NULL message");
@@ -987,8 +991,8 @@ static void __camera_message_release_func(gpointer data)
 static void *_camera_message_handler_func(gpointer data)
 {
        int i = 0;
-       camera_message_t *message = NULL;
-       camera_hal_handle *handle = (camera_hal_handle *)data;
+       camera_message_s *message = NULL;
+       hal_camera_handle *handle = (hal_camera_handle *)data;
 
        if (!handle) {
                LOGE("NULL handle for capture thread");
@@ -1022,7 +1026,7 @@ static void *_camera_message_handler_func(gpointer data)
                for (i = 0 ; i < MESSAGE_CALLBACK_MAX ; i++) {
                        if (handle->msg_cb[i]) {
                                LOGD("call message callback type %d", message->type);
-                               ((camera_message_cb)handle->msg_cb[i])(message, handle->msg_cb_data[i]);
+                               handle->msg_cb[i](message, handle->msg_cb_data[i]);
                        }
                }
 
@@ -1040,7 +1044,7 @@ static void *_camera_message_handler_func(gpointer data)
 }
 
 
-static void __camera_release_handle(camera_hal_handle *handle)
+static void __camera_release_handle(hal_camera_handle *handle)
 {
        if (!handle) {
                LOGW("NULL handle");
@@ -1076,10 +1080,10 @@ static void __camera_release_handle(camera_hal_handle *handle)
 }
 
 
-int camera_init(void **camera_handle)
+int camera_v4l2_init(void **camera_handle)
 {
        int ret = CAMERA_ERROR_NONE;
-       camera_hal_handle *new_handle = NULL;
+       hal_camera_handle *new_handle = NULL;
        tbm_bufmgr bufmgr = NULL;
 
        LOGD("enter");
@@ -1095,7 +1099,7 @@ int camera_init(void **camera_handle)
                return CAMERA_ERROR_INTERNAL;
        }
 
-       new_handle = g_new0(camera_hal_handle, 1);
+       new_handle = g_new0(hal_camera_handle, 1);
        if (!new_handle) {
                LOGE("failed to alloc camera hal handle");
                tbm_bufmgr_deinit(bufmgr);
@@ -1143,9 +1147,10 @@ _INIT_ERROR:
        return ret;
 }
 
-int camera_deinit(void *camera_handle)
+
+int camera_v4l2_deinit(void *camera_handle)
 {
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle) {
                LOGE("NULL handle");
@@ -1167,7 +1172,8 @@ int camera_deinit(void *camera_handle)
        return CAMERA_ERROR_NONE;
 }
 
-int camera_get_device_info_list(camera_device_info_list_t *device_info_list)
+
+int camera_v4l2_get_device_info_list(camera_device_info_list_s *device_info_list)
 {
        int ret = 0;
 
@@ -1182,17 +1188,18 @@ int camera_get_device_info_list(camera_device_info_list_t *device_info_list)
                return ret;
        }
 
-       memcpy(device_info_list, g_device_info_list, sizeof(camera_device_info_list_t));
+       memcpy(device_info_list, g_device_info_list, sizeof(camera_device_info_list_s));
 
        return CAMERA_ERROR_NONE;
 }
 
-int camera_open_device(void *camera_handle, int device_index)
+
+int camera_v4l2_open_device(void *camera_handle, int device_index)
 {
        int ret = CAMERA_ERROR_NONE;
        int device_fd = CAMERA_HAL_INITIAL_FD;
        char *node_path = NULL;
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle) {
                LOGE("NULL handle");
@@ -1263,9 +1270,17 @@ _OPEN_DEVICE_DONE:
        return ret;
 }
 
-int camera_close_device(void *camera_handle)
+
+int camera_v4l2_open_device_ext(void *camera_handle, const char *device_name)
+{
+       LOGE("NOT SUPPORTED");
+       return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
+}
+
+
+int camera_v4l2_close_device(void *camera_handle)
 {
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle) {
                LOGE("NULL handle");
@@ -1298,10 +1313,11 @@ int camera_close_device(void *camera_handle)
        return CAMERA_ERROR_NONE;
 }
 
-int camera_add_message_callback(void *camera_handle, camera_message_cb callback, void *user_data, uint32_t *cb_id)
+
+int camera_v4l2_add_message_callback(void *camera_handle, hal_camera_message_cb callback, void *user_data, uint32_t *cb_id)
 {
        uint32_t i = 0;
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle) {
                LOGE("NULL handle");
@@ -1339,9 +1355,10 @@ int camera_add_message_callback(void *camera_handle, camera_message_cb callback,
        return CAMERA_ERROR_INTERNAL;
 }
 
-int camera_remove_message_callback(void *camera_handle, uint32_t cb_id)
+
+int camera_v4l2_remove_message_callback(void *camera_handle, uint32_t cb_id)
 {
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle) {
                LOGE("NULL handle");
@@ -1378,14 +1395,15 @@ int camera_remove_message_callback(void *camera_handle, uint32_t cb_id)
        return CAMERA_ERROR_NONE;
 }
 
-int camera_set_preview_stream_format(void *camera_handle, camera_format_t *format)
+
+int camera_v4l2_set_preview_stream_format(void *camera_handle, camera_format_s *format)
 {
        int i = 0;
        int j = 0;
        int ret = CAMERA_ERROR_NONE;
        gboolean capability_check = FALSE;
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
-       camera_device_info_t *device_info = NULL;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
+       camera_device_info_s *device_info = NULL;
 
        if (!handle || !format) {
                LOGE("NULL param %p %p", handle, format);
@@ -1482,7 +1500,7 @@ _SET_PREVIEW_STREAM_FORMAT_DONE:
        else
                handle->capture_restart_stream = TRUE;
 
-       memcpy(&handle->preview_format, format, sizeof(camera_format_t));
+       memcpy(&handle->preview_format, format, sizeof(camera_format_s));
 
        LOGD("set format PREVIEW[%d:%dx%d,fps:%d], CAPTURE[%d:%dx%d,restart:%d]",
                format->stream_format,
@@ -1499,9 +1517,10 @@ _SET_PREVIEW_STREAM_FORMAT_DONE:
        return CAMERA_ERROR_NONE;
 }
 
-int camera_get_preview_stream_format(void *camera_handle, camera_format_t *format)
+
+int camera_v4l2_get_preview_stream_format(void *camera_handle, camera_format_s *format)
 {
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle || !format) {
                LOGE("NULL param %p %p", handle, format);
@@ -1510,7 +1529,7 @@ int camera_get_preview_stream_format(void *camera_handle, camera_format_t *forma
 
        g_mutex_lock(&handle->lock);
 
-       memcpy(format, &handle->preview_format, sizeof(camera_format_t));
+       memcpy(format, &handle->preview_format, sizeof(camera_format_s));
 
        LOGD("get stream format %d, %dx%d", format->stream_format,
                format->stream_resolution.width, format->stream_resolution.height);
@@ -1521,10 +1540,17 @@ int camera_get_preview_stream_format(void *camera_handle, camera_format_t *forma
 }
 
 
-int camera_start_preview(void *camera_handle, camera_preview_frame_cb callback, void *user_data)
+int camera_v4l2_set_user_buffer_fd(void *camera_handle, int *fds, int number)
+{
+       LOGE("NOT SUPPORTED");
+       return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
+}
+
+
+int camera_v4l2_start_preview(void *camera_handle, hal_camera_preview_frame_cb callback, void *user_data)
 {
        int ret = 0;
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle || !callback) {
                LOGE("NULL param %p %p", handle, callback);
@@ -1581,10 +1607,11 @@ int camera_start_preview(void *camera_handle, camera_preview_frame_cb callback,
        return CAMERA_ERROR_NONE;
 }
 
-int camera_release_preview_buffer(void *camera_handle, int buffer_index)
+
+int camera_v4l2_release_preview_buffer(void *camera_handle, int buffer_index)
 {
        int ret = CAMERA_ERROR_NONE;
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle) {
                LOGE("NULL handle");
@@ -1621,11 +1648,11 @@ int camera_release_preview_buffer(void *camera_handle, int buffer_index)
 }
 
 
-int camera_stop_preview(void *camera_handle)
+int camera_v4l2_stop_preview(void *camera_handle)
 {
        int ret = CAMERA_ERROR_NONE;
        gint64 end_time;
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle) {
                LOGE("NULL handle");
@@ -1674,7 +1701,8 @@ int camera_stop_preview(void *camera_handle)
        return CAMERA_ERROR_NONE;
 }
 
-int camera_start_auto_focus(void *camera_handle)
+
+int camera_v4l2_start_auto_focus(void *camera_handle)
 {
        if (!camera_handle) {
                LOGE("NULL handle");
@@ -1687,7 +1715,8 @@ int camera_start_auto_focus(void *camera_handle)
        return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
 }
 
-int camera_stop_auto_focus(void *camera_handle)
+
+int camera_v4l2_stop_auto_focus(void *camera_handle)
 {
        if (!camera_handle) {
                LOGE("NULL handle");
@@ -1701,9 +1730,9 @@ int camera_stop_auto_focus(void *camera_handle)
 }
 
 
-int camera_start_capture(void *camera_handle, camera_capture_cb callback, void *user_data)
+int camera_v4l2_start_capture(void *camera_handle, hal_camera_capture_cb callback, void *user_data)
 {
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle || !callback) {
                LOGE("NULL param %p %p", camera_handle, callback);
@@ -1737,9 +1766,10 @@ int camera_start_capture(void *camera_handle, camera_capture_cb callback, void *
        return CAMERA_ERROR_NONE;
 }
 
-int camera_stop_capture(void *camera_handle)
+
+int camera_v4l2_stop_capture(void *camera_handle)
 {
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle) {
                LOGE("NULL handle");
@@ -1775,7 +1805,8 @@ int camera_stop_capture(void *camera_handle)
        return CAMERA_ERROR_NONE;
 }
 
-int camera_set_video_stream_format(void *camera_handle, camera_format_t *format)
+
+int camera_v4l2_set_video_stream_format(void *camera_handle, camera_format_s *format)
 {
        if (!camera_handle || !format) {
                LOGE("NULL param %p %p", camera_handle, format);
@@ -1788,7 +1819,8 @@ int camera_set_video_stream_format(void *camera_handle, camera_format_t *format)
        return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
 }
 
-int camera_get_video_stream_format(void *camera_handle, camera_format_t *format)
+
+int camera_v4l2_get_video_stream_format(void *camera_handle, camera_format_s *format)
 {
        if (!camera_handle || !format) {
                LOGE("NULL param %p %p", camera_handle, format);
@@ -1801,7 +1833,8 @@ int camera_get_video_stream_format(void *camera_handle, camera_format_t *format)
        return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
 }
 
-int camera_start_record(void *camera_handle, camera_video_frame_cb callback, void *user_data)
+
+int camera_v4l2_start_record(void *camera_handle, hal_camera_video_frame_cb callback, void *user_data)
 {
        if (!camera_handle || !callback) {
                LOGE("NULL param %p %p", camera_handle, callback);
@@ -1814,7 +1847,8 @@ int camera_start_record(void *camera_handle, camera_video_frame_cb callback, voi
        return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
 }
 
-int camera_release_video_buffer(void *camera_handle, int buffer_index)
+
+int camera_v4l2_release_video_buffer(void *camera_handle, int buffer_index)
 {
        if (!camera_handle) {
                LOGE("NULL handle");
@@ -1827,7 +1861,8 @@ int camera_release_video_buffer(void *camera_handle, int buffer_index)
        return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
 }
 
-int camera_stop_record(void *camera_handle)
+
+int camera_v4l2_stop_record(void *camera_handle)
 {
        if (!camera_handle) {
                LOGE("NULL handle");
@@ -1840,13 +1875,14 @@ int camera_stop_record(void *camera_handle)
        return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
 }
 
-int camera_set_command(void *camera_handle, int64_t command, void *value)
+
+int camera_v4l2_set_command(void *camera_handle, int64_t command, void *value)
 {
        int ret = CAMERA_ERROR_NONE;
        int cid = 0;
        int ctrl_ret = 0;
        int set_value = 0;
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle || !value) {
                LOGE("NULL param %p %p", handle, value);
@@ -1943,12 +1979,13 @@ _SET_COMMAND_DONE:
        return ret;
 }
 
-int camera_get_command(void *camera_handle, int64_t command, void **value)
+
+int camera_v4l2_get_command(void *camera_handle, int64_t command, void **value)
 {
        int ret = CAMERA_ERROR_NONE;
        int cid = 0;
        int ctrl_ret = 0;
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle || !value) {
                LOGE("NULL param %p %p", handle, value);
@@ -2010,9 +2047,10 @@ int camera_get_command(void *camera_handle, int64_t command, void **value)
        return ret;
 }
 
-int camera_set_batch_command(void *camera_handle, camera_batch_command_control_t *batch_command, int64_t *error_command)
+
+int camera_v4l2_set_batch_command(void *camera_handle, camera_batch_command_control_s *batch_command, int64_t *error_command)
 {
-       camera_hal_handle *handle = (camera_hal_handle *)camera_handle;
+       hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
 
        if (!handle || !batch_command) {
                LOGE("NULL param %p %p", handle, batch_command);
@@ -2030,3 +2068,64 @@ int camera_set_batch_command(void *camera_handle, camera_batch_command_control_t
 
        return CAMERA_ERROR_NONE;
 }
+
+
+static int camera_v4l2_backend_init(void **data)
+{
+       hal_backend_camera_funcs *funcs;
+
+       funcs = calloc(1, sizeof(hal_backend_camera_funcs));
+       if (!funcs)
+               return CAMERA_ERROR_OUT_OF_MEMORY;
+
+       funcs->init = camera_v4l2_init;
+       funcs->deinit = camera_v4l2_deinit;
+       funcs->get_device_info_list = camera_v4l2_get_device_info_list;
+       funcs->open_device = camera_v4l2_open_device;
+       funcs->open_device_ext = camera_v4l2_open_device_ext;
+       funcs->close_device = camera_v4l2_close_device;
+       funcs->add_message_callback = camera_v4l2_add_message_callback;
+       funcs->remove_message_callback = camera_v4l2_remove_message_callback;
+       funcs->set_preview_stream_format = camera_v4l2_set_preview_stream_format;
+       funcs->get_preview_stream_format = camera_v4l2_get_preview_stream_format;
+       funcs->set_user_buffer_fd = camera_v4l2_set_user_buffer_fd;
+       funcs->start_preview = camera_v4l2_start_preview;
+       funcs->release_preview_buffer = camera_v4l2_release_preview_buffer;
+       funcs->stop_preview = camera_v4l2_stop_preview;
+       funcs->start_auto_focus = camera_v4l2_start_auto_focus;
+       funcs->stop_auto_focus = camera_v4l2_stop_auto_focus;
+       funcs->start_capture = camera_v4l2_start_capture;
+       funcs->stop_capture = camera_v4l2_stop_capture;
+       funcs->set_video_stream_format = camera_v4l2_set_video_stream_format;
+       funcs->get_video_stream_format = camera_v4l2_get_video_stream_format;
+       funcs->start_record = camera_v4l2_start_record;
+       funcs->release_video_buffer = camera_v4l2_release_video_buffer;
+       funcs->stop_record = camera_v4l2_stop_record;
+       funcs->set_command = camera_v4l2_set_command;
+       funcs->get_command = camera_v4l2_get_command;
+       funcs->set_batch_command = camera_v4l2_set_batch_command;
+
+       *data = (void *)funcs;
+
+       return 0;
+}
+
+
+static int camera_v4l2_backend_exit(void *data)
+{
+       if (!data)
+               return 0;
+
+       free(data);
+
+       return 0;
+}
+
+
+hal_backend hal_backend_camera_data = {
+       .name = "camera-v4l2",
+       .vendor = "TIZEN",
+       .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
+       .init = camera_v4l2_backend_init,
+       .exit = camera_v4l2_backend_exit,
+};
diff --git a/src/hal_camera_v4l2_private.h b/src/hal_camera_v4l2_private.h
new file mode 100644 (file)
index 0000000..b6eb18a
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * hal_camera_v4l2_private.h
+ *
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __HAL_CAMERA_V4L2_PRIVATE_H__
+#define __HAL_CAMERA_V4L2_PRIVATE_H__
+
+#include <linux/videodev2.h>
+#include <glib.h>
+#include <tbm_bufmgr.h>
+#include <hal/hal-common-interface.h>
+#include <hal/hal-camera-interface.h>
+
+#define CAMERA_HAL_INITIAL_INDEX    -1
+#define CAMERA_HAL_INITIAL_FD       -1
+#define MESSAGE_CALLBACK_MAX        10
+#define BUFFER_MAX                  4
+#define V4L2_PLANES_MAX             4
+
+typedef struct _camera_hal_handle {
+       /* tbm */
+       tbm_bufmgr bufmgr;
+
+       /* device */
+       gint32 device_index;
+       gint32 device_fd;
+
+       /* buffer */
+       guint32 buffer_dequeued_count;
+       GThread *buffer_thread;
+       gboolean buffer_thread_run;
+       guint32 buffer_count;
+       camera_buffer_s camera_buffers[BUFFER_MAX];
+       enum v4l2_buf_type buffer_type;
+       GMutex buffer_lock;
+       GCond buffer_cond;
+
+       /* preview */
+       camera_format_s preview_format;
+       hal_camera_preview_frame_cb preview_cb;
+       gpointer preview_cb_data;
+
+       /* capture */
+       hal_camera_capture_cb capture_cb;
+       gpointer capture_cb_data;
+       guint32 capture_count;
+       guint32 capture_interval_ms;
+       guint32 captured_count;
+       gboolean capture_request;
+       gboolean capture_restart_stream;
+
+       /* message */
+       GThread *msg_thread;
+       hal_camera_message_cb msg_cb[MESSAGE_CALLBACK_MAX];
+       gpointer msg_cb_data[MESSAGE_CALLBACK_MAX];
+       gboolean msg_cb_run;
+       GQueue *msg_list;
+       GMutex msg_cb_lock;
+       GCond msg_cb_cond;
+
+       /* etc */
+       GMutex lock;
+       camera_state_e state;
+} hal_camera_handle;
+
+int camera_v4l2_init(void **camera_handle);
+int camera_v4l2_deinit(void *camera_handle);
+int camera_v4l2_get_device_info_list(camera_device_info_list_s *device_info_list);
+int camera_v4l2_open_device(void *camera_handle, int device_index);
+int camera_v4l2_open_device_ext(void *camera_handle, const char *device_name);
+int camera_v4l2_close_device(void *camera_handle);
+int camera_v4l2_add_message_callback(void *camera_handle, hal_camera_message_cb callback, void *user_data, uint32_t *cb_id);
+int camera_v4l2_remove_message_callback(void *camera_handle, uint32_t cb_id);
+int camera_v4l2_set_preview_stream_format(void *camera_handle, camera_format_s *format);
+int camera_v4l2_get_preview_stream_format(void *camera_handle, camera_format_s *format);
+int camera_v4l2_set_user_buffer_fd(void *camera_handle, int *fds, int number);
+int camera_v4l2_start_preview(void *camera_handle, hal_camera_preview_frame_cb callback, void *user_data);
+int camera_v4l2_release_preview_buffer(void *camera_handle, int buffer_index);
+int camera_v4l2_stop_preview(void *camera_handle);
+int camera_v4l2_start_auto_focus(void *camera_handle);
+int camera_v4l2_stop_auto_focus(void *camera_handle);
+int camera_v4l2_start_capture(void *camera_handle, hal_camera_capture_cb callback, void *user_data);
+int camera_v4l2_stop_capture(void *camera_handle);
+int camera_v4l2_set_video_stream_format(void *camera_handle, camera_format_s *format);
+int camera_v4l2_get_video_stream_format(void *camera_handle, camera_format_s *format);
+int camera_v4l2_start_record(void *camera_handle, hal_camera_video_frame_cb callback, void *user_data);
+int camera_v4l2_release_video_buffer(void *camera_handle, int buffer_index);
+int camera_v4l2_stop_record(void *camera_handle);
+int camera_v4l2_set_command(void *camera_handle, int64_t command, void *value);
+int camera_v4l2_get_command(void *camera_handle, int64_t command, void **value);
+int camera_v4l2_set_batch_command(void *camera_handle, camera_batch_command_control_s *batch_command, int64_t *error_command);
+
+#endif /* __HAL_CAMERA_V4L2_PRIVATE_H__ */
diff --git a/src/tizen_camera_v4l2_private.h b/src/tizen_camera_v4l2_private.h
deleted file mode 100644 (file)
index 035316b..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * tizen_camera_private.c
- *
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef __TIZEN_CAMERA_PRIVATE_H__
-#define __TIZEN_CAMERA_PRIVATE_H__
-
-#include <linux/videodev2.h>
-#include <glib.h>
-#include <tbm_bufmgr.h>
-#include <tizen-camera.h>
-
-#define CAMERA_HAL_INITIAL_INDEX    -1
-#define CAMERA_HAL_INITIAL_FD       -1
-#define MESSAGE_CALLBACK_MAX        10
-#define BUFFER_MAX                  4
-#define V4L2_PLANES_MAX             4
-
-typedef struct _camera_hal_handle {
-       /* tbm */
-       tbm_bufmgr bufmgr;
-
-       /* device */
-       gint32 device_index;
-       gint32 device_fd;
-
-       /* buffer */
-       guint32 buffer_dequeued_count;
-       GThread *buffer_thread;
-       gboolean buffer_thread_run;
-       guint32 buffer_count;
-       camera_buffer_t camera_buffers[BUFFER_MAX];
-       enum v4l2_buf_type buffer_type;
-       GMutex buffer_lock;
-       GCond buffer_cond;
-
-       /* preview */
-       camera_format_t preview_format;
-       camera_preview_frame_cb preview_cb;
-       gpointer preview_cb_data;
-
-       /* capture */
-       camera_capture_cb capture_cb;
-       gpointer capture_cb_data;
-       guint32 capture_count;
-       guint32 capture_interval_ms;
-       guint32 captured_count;
-       gboolean capture_request;
-       gboolean capture_restart_stream;
-
-       /* message */
-       GThread *msg_thread;
-       camera_message_cb msg_cb[MESSAGE_CALLBACK_MAX];
-       gpointer msg_cb_data[MESSAGE_CALLBACK_MAX];
-       gboolean msg_cb_run;
-       GQueue *msg_list;
-       GMutex msg_cb_lock;
-       GCond msg_cb_cond;
-
-       /* etc */
-       GMutex lock;
-       camera_state_t state;
-} camera_hal_handle;
-
-#endif /* __TIZEN_CAMERA_PRIVATE_H__ */