diff options
author | Jeongmo Yang <jm80.yang@samsung.com> | 2024-08-29 17:24:34 +0900 |
---|---|---|
committer | Jeongmo Yang <jm80.yang@samsung.com> | 2024-08-29 17:25:04 +0900 |
commit | 90765181ccd282fbe431b9e7bc3371877301fd5f (patch) | |
tree | be9cd7ff906185736f86051933e78788e99bbce6 | |
parent | d912eb5a0491286d587778380e82560b3aae32e4 (diff) | |
download | camera-v4l2-90765181ccd282fbe431b9e7bc3371877301fd5f.tar.gz camera-v4l2-90765181ccd282fbe431b9e7bc3371877301fd5f.tar.bz2 camera-v4l2-90765181ccd282fbe431b9e7bc3371877301fd5f.zip |
Remove libv4l2 dependency
[Version] 1.2.0
[Issue Type] Clean up
Change-Id: Iec5969ff430b42680107fffd222adc428e914897
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r-- | configure.ac | 15 | ||||
-rw-r--r-- | packaging/hal-backend-camera-v4l2.spec | 14 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/hal_backend_camera_v4l2.c | 70 | ||||
-rw-r--r-- | src/hal_backend_camera_v4l2_private.h | 13 |
5 files changed, 22 insertions, 95 deletions
diff --git a/configure.ac b/configure.ac index 9bdd6e8..e7d1c06 100644 --- a/configure.ac +++ b/configure.ac @@ -41,21 +41,6 @@ AC_SUBST(HAL_API_COMMON_CFLAGS) PKG_CHECK_MODULES(HAL_API_CAMERA, hal-api-camera) AC_SUBST(HAL_API_CAMERA_CFLAGS) -AC_ARG_ENABLE(libv4l2, AC_HELP_STRING([--enable-libv4l2], [enable libv4l2]), -[ - case "${enableval}" in - yes) HAVE_LIBV4L2=yes ;; - no) HAVE_LIBV4L2=no ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-libv4l2) ;; - esac -],[HAVE_LIBV4L2=no]) -if test "x$HAVE_LIBV4L2" = "xyes"; then -PKG_CHECK_MODULES(LIBV4L2, libv4l2) -AC_SUBST(LIBV4L2_CFLAGS) -AC_SUBST(LIBV4L2_LIBS) -fi -AM_CONDITIONAL([HAVE_LIBV4L2], [test "x$HAVE_LIBV4L2" = "xyes"]) - # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([fcntl.h memory.h stdlib.h string.h sys/time.h unistd.h]) diff --git a/packaging/hal-backend-camera-v4l2.spec b/packaging/hal-backend-camera-v4l2.spec index 112478b..9e8f2ab 100644 --- a/packaging/hal-backend-camera-v4l2.spec +++ b/packaging/hal-backend-camera-v4l2.spec @@ -1,14 +1,8 @@ %define enable_zero_copy 0 -%if 0%{?enable_zero_copy} -%define enable_libv4l2 0 -%else -%define enable_libv4l2 1 -%endif - Name: hal-backend-camera-v4l2 Summary: Tizen Camera Hal using generic V4L2 interface -Version: 1.1.1 +Version: 1.2.0 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 @@ -20,9 +14,6 @@ BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(hal-api-common) BuildRequires: pkgconfig(hal-api-camera) -%if 0%{?enable_libv4l2} -BuildRequires: pkgconfig(libv4l2) -%endif %description Tizen Camera Hal using generic V4L2 interface. @@ -38,9 +29,6 @@ export CFLAGS+=" -DTIZEN_FEATURE_ZERO_COPY_SUPPORT" %endif ./autogen.sh %configure \ -%if 0%{?enable_libv4l2} - --enable-libv4l2\ -%endif --disable-static\ --libdir=%{_hal_libdir} make %{?jobs:-j%jobs} diff --git a/src/Makefile.am b/src/Makefile.am index 76ed725..f8293f8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,11 +19,6 @@ libhal_backend_camera_la_LIBADD = \ $(DLOG_LIBS) \ $(TBM_LIBS) -if HAVE_LIBV4L2 -libhal_backend_camera_la_CFLAGS += $(LIBV4L2_CFLAGS) -DHAVE_LIBV4L2 -libhal_backend_camera_la_LIBADD += $(LIBV4L2_LIBS) -endif - libhal_backend_camera_la_CFLAGS += -fdata-sections -ffunction-sections -Wl,--gc-sections libhal_backend_camera_la_LDFLAGS = -Wl,--gc-sections -avoid-version diff --git a/src/hal_backend_camera_v4l2.c b/src/hal_backend_camera_v4l2.c index cb4ff1c..a72348a 100644 --- a/src/hal_backend_camera_v4l2.c +++ b/src/hal_backend_camera_v4l2.c @@ -333,7 +333,7 @@ static int __camera_v4l2_g_ctrl(int device_fd, int cid, int *value) ctrl.id = cid; if (!g_is_virtual_camera_mode) - ret = v4l2_ioctl(device_fd, VIDIOC_G_CTRL, &ctrl); + ret = ioctl(device_fd, VIDIOC_G_CTRL, &ctrl); if (ret == 0) *value = ctrl.value; @@ -355,7 +355,7 @@ static int __camera_v4l2_s_ctrl(int device_fd, int cid, int value) ctrl.value = value; if (!g_is_virtual_camera_mode) - ret = v4l2_ioctl(device_fd, VIDIOC_S_CTRL, &ctrl); + ret = ioctl(device_fd, VIDIOC_S_CTRL, &ctrl); LOGD("S_CTRL id 0x%x, value %d, ret %d", cid, value, ret); @@ -371,7 +371,7 @@ static int __camera_v4l2_stream(int device_fd, int type, gboolean onoff) } if (!g_is_virtual_camera_mode) { - if (v4l2_ioctl(device_fd, onoff ? VIDIOC_STREAMON : VIDIOC_STREAMOFF, &type) < 0) { + if (ioctl(device_fd, onoff ? VIDIOC_STREAMON : VIDIOC_STREAMOFF, &type) < 0) { LOGE("stream %d failed. [t:%d] errno %d", onoff, type, errno); return CAMERA_ERROR_INTERNAL; } @@ -406,7 +406,7 @@ static int __camera_v4l2_reqbufs(int device_fd, int type, int memory, uint32_t c v4l2_reqbuf.count = count; if (!g_is_virtual_camera_mode) { - if (v4l2_ioctl(device_fd, VIDIOC_REQBUFS, &v4l2_reqbuf) < 0) { + if (ioctl(device_fd, VIDIOC_REQBUFS, &v4l2_reqbuf) < 0) { LOGE("REQBUFS[count %d] failed. errno %d", count, errno); return CAMERA_ERROR_INTERNAL; } @@ -447,7 +447,7 @@ static int __camera_v4l2_qbuf(int device_fd, int type, int memory, int index, in } if (!g_is_virtual_camera_mode) { - if (v4l2_ioctl(device_fd, VIDIOC_QBUF, &v4l2_buf) < 0) { + if (ioctl(device_fd, VIDIOC_QBUF, &v4l2_buf) < 0) { LOGE("qbuf failed. [i: %d, t: %d, m: %d] errno %d", index, type, memory, errno); return CAMERA_ERROR_INTERNAL; @@ -486,7 +486,7 @@ static int __camera_v4l2_dqbuf(int device_fd, int type, int memory, int *index, v4l2_buf.m.planes = v4l2_planes; if (!g_is_virtual_camera_mode) { - ret = v4l2_ioctl(device_fd, VIDIOC_DQBUF, &v4l2_buf); + ret = ioctl(device_fd, VIDIOC_DQBUF, &v4l2_buf); if (ret < 0) { LOGE("dqbuf failed. [t: %d, m: %d] errno %d", type, memory, errno); @@ -641,7 +641,7 @@ static void __camera_get_fps_list(int device_fd, guint32 pixel_format, int width ival.width = width; ival.height = height; - while (v4l2_ioctl(device_fd, VIDIOC_ENUM_FRAMEINTERVALS, &ival) >= 0) { + while (ioctl(device_fd, VIDIOC_ENUM_FRAMEINTERVALS, &ival) >= 0) { if (ival.type != V4L2_FRMIVAL_TYPE_DISCRETE) { LOGE("NOT DISCRETE type[%u] for [%dx%d]", ival.type, width, height); return; @@ -697,7 +697,7 @@ static int __camera_get_device_info(int device_index, int device_fd, char *node_ v4l2_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (!g_is_virtual_camera_mode) { - if (v4l2_ioctl(device_fd, VIDIOC_ENUM_FMT, &v4l2_format) < 0) { + if (ioctl(device_fd, VIDIOC_ENUM_FMT, &v4l2_format) < 0) { LOGW("\tformat : end of enumeration"); break; } @@ -732,7 +732,7 @@ static int __camera_get_device_info(int device_index, int device_fd, char *node_ v4l2_frame.pixel_format = v4l2_format.pixelformat; if (!g_is_virtual_camera_mode) { - if (v4l2_ioctl(device_fd, VIDIOC_ENUM_FRAMESIZES, &v4l2_frame) < 0) { + if (ioctl(device_fd, VIDIOC_ENUM_FRAMESIZES, &v4l2_frame) < 0) { LOGW("\t\tframesize : end of enumeration"); break; } @@ -861,9 +861,6 @@ static int __camera_get_device_info_list(void) int ret = CAMERA_ERROR_NONE; int device_count = 0; int device_fd = CAMERA_HAL_INITIAL_FD; -#ifdef HAVE_LIBV4L2 - int libv4l2_fd = CAMERA_HAL_INITIAL_FD; -#endif /* HAVE_LIBV4L2 */ glob_t glob_buf; struct v4l2_capability v4l2_cap; guint32 device_caps; @@ -941,20 +938,11 @@ static int __camera_get_device_info_list(void) continue; } -#ifdef HAVE_LIBV4L2 - libv4l2_fd = v4l2_fd_open(device_fd, V4L2_ENABLE_ENUM_FMT_EMULATION); - - LOGI("device_fd[%d], libv4l2_fd[%d]", device_fd, libv4l2_fd); - - if (libv4l2_fd != CAMERA_HAL_INITIAL_FD) - device_fd = libv4l2_fd; -#endif /* HAVE_LIBV4L2 */ - memset(&v4l2_cap, 0x0, sizeof(struct v4l2_capability)); - if (v4l2_ioctl(device_fd, VIDIOC_QUERYCAP, &v4l2_cap) < 0) { + if (ioctl(device_fd, VIDIOC_QUERYCAP, &v4l2_cap) < 0) { LOGE("querycap failed. errno %d", errno); - v4l2_close(device_fd); + close(device_fd); continue; } @@ -969,7 +957,7 @@ static int __camera_get_device_info_list(void) if (!(device_caps & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE)) || (device_caps & (V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_VIDEO_OUTPUT_MPLANE))) { LOGW("[%s] is not a capture device 0x%x", glob_buf.gl_pathv[i], device_caps); - v4l2_close(device_fd); + close(device_fd); continue; } @@ -978,7 +966,7 @@ static int __camera_get_device_info_list(void) &device_info_list->device_info[device_count], &device_capability_list->capability[device_count]); - v4l2_close(device_fd); + close(device_fd); if (ret == CAMERA_ERROR_NONE && device_capability_list->capability[device_count]) { g_device_caps[device_count] = device_caps; @@ -1063,7 +1051,7 @@ static int __camera_stop_stream(hal_camera_handle *handle, uint32_t buffer_count if (buffer->planes[0].data) { #ifndef TIZEN_FEATURE_ZERO_COPY_SUPPORT LOGI(" munmap %p", buffer->planes[0].data); - v4l2_munmap(buffer->planes[0].data, buffer->planes[0].size); + munmap(buffer->planes[0].data, buffer->planes[0].size); #endif buffer->planes[0].data = NULL; buffer->planes[0].size = 0; @@ -1130,7 +1118,7 @@ static int __camera_start_stream(hal_camera_handle *handle, camera_pixel_format_ } if (!g_is_virtual_camera_mode) { - if (v4l2_ioctl(handle->device_fd, VIDIOC_S_FMT, &v4l2_fmt) < 0) { + if (ioctl(handle->device_fd, VIDIOC_S_FMT, &v4l2_fmt) < 0) { LOGE("S_FMT failed. errno %d", errno); return CAMERA_ERROR_INTERNAL; } @@ -1170,7 +1158,7 @@ static int __camera_start_stream(hal_camera_handle *handle, camera_pixel_format_ v4l2_parm.type = handle->buffer_type; if (!g_is_virtual_camera_mode) { - if (v4l2_ioctl(handle->device_fd, VIDIOC_G_PARM, &v4l2_parm) < 0) { + if (ioctl(handle->device_fd, VIDIOC_G_PARM, &v4l2_parm) < 0) { LOGE("G_PARM failed. errno %d", errno); return CAMERA_ERROR_INTERNAL; } @@ -1181,7 +1169,7 @@ static int __camera_start_stream(hal_camera_handle *handle, camera_pixel_format_ v4l2_parm.parm.capture.timeperframe.denominator = fps; if (!g_is_virtual_camera_mode) { - if (v4l2_ioctl(handle->device_fd, VIDIOC_S_PARM, &v4l2_parm) < 0) { + if (ioctl(handle->device_fd, VIDIOC_S_PARM, &v4l2_parm) < 0) { LOGE("S_PARM failed. errno %d", errno); return CAMERA_ERROR_INTERNAL; } @@ -1255,7 +1243,7 @@ static int __camera_start_stream(hal_camera_handle *handle, camera_pixel_format_ v4l2_buf.m.planes = v4l2_planes; v4l2_buf.length = plane_num; - if (v4l2_ioctl(handle->device_fd, VIDIOC_QUERYBUF, &v4l2_buf) < 0) { + if (ioctl(handle->device_fd, VIDIOC_QUERYBUF, &v4l2_buf) < 0) { LOGE("[%d] query buf failed. errno %d", i, errno); ret = CAMERA_ERROR_INTERNAL; goto _START_STREAM_FAILED; @@ -1268,7 +1256,7 @@ static int __camera_start_stream(hal_camera_handle *handle, camera_pixel_format_ buffer->total_size = v4l2_buf.length; buffer->num_planes = plane_num; buffer->planes[0].size = v4l2_buf.length; - buffer->planes[0].data = v4l2_mmap(0, + buffer->planes[0].data = mmap(0, v4l2_buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, @@ -1766,12 +1754,6 @@ int camera_v4l2_init(void **camera_handle) for (i = 0 ; i < BUFFER_MAX ; i++) new_handle->tbm_buffers[i].dmabuf_fd = CAMERA_HAL_INITIAL_FD; -#ifdef HAVE_LIBV4L2 - LOGI("libv4l2 ENABLED"); -#else /* HAVE_LIBV4L2 */ - LOGI("libv4l2 DISABLED"); -#endif /* HAVE_LIBV4L2 */ - *camera_handle = new_handle; LOGD("camera HAL handle %p", new_handle); @@ -1835,9 +1817,6 @@ int camera_v4l2_open_device(void *camera_handle, int device_index) { int ret = CAMERA_ERROR_NONE; int device_fd = CAMERA_HAL_INITIAL_FD; -#ifdef HAVE_LIBV4L2 - int libv4l2_fd = CAMERA_HAL_INITIAL_FD; -#endif /* HAVE_LIBV4L2 */ char *node_path = NULL; hal_camera_handle *handle = (hal_camera_handle *)camera_handle; @@ -1910,15 +1889,6 @@ int camera_v4l2_open_device(void *camera_handle, int device_index) handle->memory_type = V4L2_MEMORY_MMAP; #endif -#ifdef HAVE_LIBV4L2 - libv4l2_fd = v4l2_fd_open(device_fd, V4L2_ENABLE_ENUM_FMT_EMULATION); - - LOGI("device_fd[%d], libv4l2_fd[%d]", device_fd, libv4l2_fd); - - if (libv4l2_fd != CAMERA_HAL_INITIAL_FD) - device_fd = libv4l2_fd; -#endif /* HAVE_LIBV4L2 */ - _OPEN_DEVICE_DONE: handle->state = CAMERA_STATE_OPENED; handle->device_index = device_index; @@ -1961,7 +1931,7 @@ int camera_v4l2_close_device(void *camera_handle) if (!g_is_virtual_camera_mode) { if (handle->device_fd >= 0) { LOGD("close fd %d", handle->device_fd); - v4l2_close(handle->device_fd); + close(handle->device_fd); handle->device_fd = CAMERA_HAL_INITIAL_FD; } else { LOGW("invalid fd %d", handle->device_fd); diff --git a/src/hal_backend_camera_v4l2_private.h b/src/hal_backend_camera_v4l2_private.h index db67861..845e792 100644 --- a/src/hal_backend_camera_v4l2_private.h +++ b/src/hal_backend_camera_v4l2_private.h @@ -26,18 +26,6 @@ #include <hal/hal-common-interface.h> #include <hal/hal-camera-interface.h> -#ifdef HAVE_LIBV4L2 -#include <libv4l2.h> -#else -#define v4l2_fd_open(fd, flags) (fd) -#define v4l2_close close -#define v4l2_dup dup -#define v4l2_ioctl ioctl -#define v4l2_read read -#define v4l2_mmap mmap -#define v4l2_munmap munmap -#endif /* ENABLE_LIBV4L2 */ - #define CAMERA_HAL_INITIAL_INDEX -1 #define CAMERA_HAL_INITIAL_FD -1 #define MESSAGE_CALLBACK_MAX 10 @@ -45,6 +33,7 @@ #define V4L2_PLANES_MAX 4 #define EXTRA_PREVIEW_STREAM_MAX 10 + typedef struct _set_batch_table_s { int64_t command; void *value; |