ctrl.id = cid;
- ret = ioctl(device_fd, VIDIOC_G_CTRL, &ctrl);
+ ret = v4l2_ioctl(device_fd, VIDIOC_G_CTRL, &ctrl);
*value = ctrl.value;
ctrl.id = cid;
ctrl.value = value;
- ret = ioctl(device_fd, VIDIOC_S_CTRL, &ctrl);
+ ret = v4l2_ioctl(device_fd, VIDIOC_S_CTRL, &ctrl);
LOGD("S_CTRL id 0x%x, value %d, ret %d", cid, value, ret);
return CAMERA_ERROR_INVALID_PARAMETER;
}
- if (ioctl(device_fd, onoff ? VIDIOC_STREAMON : VIDIOC_STREAMOFF, &type) < 0) {
+ if (v4l2_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;
}
v4l2_reqbuf.memory = memory;
v4l2_reqbuf.count = count;
- if (ioctl(device_fd, VIDIOC_REQBUFS, &v4l2_reqbuf) < 0) {
+ if (v4l2_ioctl(device_fd, VIDIOC_REQBUFS, &v4l2_reqbuf) < 0) {
LOGE("REQBUFS[count %d] failed. errno %d", count, errno);
return CAMERA_ERROR_INTERNAL;
}
v4l2_buf.length = 460800;
v4l2_buf.bytesused = 460800;
- if (ioctl(device_fd, VIDIOC_QBUF, &v4l2_buf) < 0) {
+ if (v4l2_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;
v4l2_buf.memory = memory;
v4l2_buf.m.planes = v4l2_planes;
- ret = ioctl(device_fd, VIDIOC_DQBUF, &v4l2_buf);
+ ret = v4l2_ioctl(device_fd, VIDIOC_DQBUF, &v4l2_buf);
if (ret < 0) {
if (errno != EIO) {
LOGE("dqbuf failed. [t: %d, m: %d] errno %d",
v4l2_format.index = i;
v4l2_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- if (ioctl(device_fd, VIDIOC_ENUM_FMT, &v4l2_format) < 0) {
+ if (v4l2_ioctl(device_fd, VIDIOC_ENUM_FMT, &v4l2_format) < 0) {
LOGW("\tformat : end of enumeration");
break;
}
- LOGD("\tformat[%d] "FOURCC_FORMAT, i, FOURCC_CONVERT(v4l2_format.pixelformat));
+ LOGD("\tformat[%d] "FOURCC_FORMAT" (emulated:%d)",
+ i, FOURCC_CONVERT(v4l2_format.pixelformat),
+ ((v4l2_format.flags & V4L2_FMT_FLAG_EMULATED) ? 1 : 0));
if (__camera_get_format(v4l2_format.pixelformat, &camera_format) != CAMERA_ERROR_NONE)
continue;
v4l2_frame.index = j;
v4l2_frame.pixel_format = v4l2_format.pixelformat;
- if (ioctl(device_fd, VIDIOC_ENUM_FRAMESIZES, &v4l2_frame) < 0) {
+ if (v4l2_ioctl(device_fd, VIDIOC_ENUM_FRAMESIZES, &v4l2_frame) < 0) {
LOGW("\t\tframe : end of enumeration ");
break;
}
int ret = 0;
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;
camera_device_info_list_s *device_info_list = NULL;
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 (ioctl(device_fd, VIDIOC_QUERYCAP, &v4l2_cap) < 0) {
+ if (v4l2_ioctl(device_fd, VIDIOC_QUERYCAP, &v4l2_cap) < 0) {
LOGE("querycap failed. errno %d", errno);
- close(device_fd);
+ v4l2_close(device_fd);
continue;
}
if (!(g_device_caps & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_CAPTURE_MPLANE)) ||
(g_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], g_device_caps);
- close(device_fd);
+ v4l2_close(device_fd);
continue;
}
ret = __camera_get_device_info(device_count, device_fd,
&device_info_list->device_info[device_count], glob_buf.gl_pathv[i]);
- close(device_fd);
+ v4l2_close(device_fd);
if (ret == CAMERA_ERROR_NONE)
device_count++;
if (handle->camera_buffers[i].planes[0].data != NULL) {
LOGW("munmap %p", handle->camera_buffers[i].planes[0].data);
- munmap(handle->camera_buffers[i].planes[0].data, handle->camera_buffers[i].planes[0].size);
+ v4l2_munmap(handle->camera_buffers[i].planes[0].data, handle->camera_buffers[i].planes[0].size);
handle->camera_buffers[i].planes[0].data = 0;
handle->camera_buffers[i].planes[0].size = 0;
v4l2_fmt.fmt.pix.bytesperline = resolution->width;
}
- if (ioctl(handle->device_fd, VIDIOC_S_FMT, &v4l2_fmt) < 0) {
+ if (v4l2_ioctl(handle->device_fd, VIDIOC_S_FMT, &v4l2_fmt) < 0) {
LOGE("S_FMT failed. errno %d", errno);
return CAMERA_ERROR_INTERNAL;
}
v4l2_parm.type = handle->buffer_type;
- if (ioctl(handle->device_fd, VIDIOC_G_PARM, &v4l2_parm) < 0) {
+ if (v4l2_ioctl(handle->device_fd, VIDIOC_G_PARM, &v4l2_parm) < 0) {
LOGE("G_PARM failed. errno %d", errno);
return CAMERA_ERROR_INTERNAL;
}
v4l2_parm.parm.capture.timeperframe.numerator = 1;
v4l2_parm.parm.capture.timeperframe.denominator = fps;
- if (ioctl(handle->device_fd, VIDIOC_S_PARM, &v4l2_parm) < 0) {
+ if (v4l2_ioctl(handle->device_fd, VIDIOC_S_PARM, &v4l2_parm) < 0) {
LOGE("S_PARM failed. errno %d", errno);
return CAMERA_ERROR_INTERNAL;
}
v4l2_buf.m.planes = v4l2_planes;
v4l2_buf.length = plane_num;
- if (ioctl(handle->device_fd, VIDIOC_QUERYBUF, &v4l2_buf) < 0) {
+ if (v4l2_ioctl(handle->device_fd, VIDIOC_QUERYBUF, &v4l2_buf) < 0) {
LOGE("[%d] query buf failed. errno %d", i, errno);
goto _START_STREAM_FAILED;
}
buffer->total_size = v4l2_buf.length;
buffer->num_planes = plane_num;
buffer->planes[0].size = v4l2_buf.length;
- buffer->planes[0].data = mmap(0,
+ buffer->planes[0].data = v4l2_mmap(0,
v4l2_buf.length,
PROT_READ | PROT_WRITE,
MAP_SHARED,
goto _INIT_ERROR;
}
+#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);
{
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;
else
handle->buffer_type = V4L2_CAP_VIDEO_CAPTURE;
+#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 */
+
handle->state = CAMERA_STATE_OPENED;
handle->device_index = device_index;
handle->device_fd = device_fd;
if (handle->device_fd >= 0) {
LOGD("close fd %d", handle->device_fd);
- close(handle->device_fd);
+ v4l2_close(handle->device_fd);
handle->device_fd = CAMERA_HAL_INITIAL_FD;
} else {
LOGW("invalid fd %d", handle->device_fd);