}
-int camera_v4l2_set_command(void *camera_handle, int64_t command, void *value)
+static int __set_command(hal_camera_handle *handle, int64_t command, void *value)
{
- int ret = CAMERA_ERROR_NONE;
int cid = 0;
int ctrl_ret = 0;
int set_value = 0;
- hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
if (!handle || !value) {
LOGE("NULL param %p %p", handle, value);
set_value = *(int *)value;
- g_mutex_lock(&handle->lock);
-
if (handle->state < CAMERA_STATE_OPENED) {
LOGE("invalid state %d", handle->state);
- ret = CAMERA_ERROR_INVALID_STATE;
- goto _SET_COMMAND_DONE;
+ return CAMERA_ERROR_INVALID_STATE;
}
LOGD("set command %"PRIx64" - state %d", command, handle->state);
case CAMERA_COMMAND_PTZ_TYPE:
if (set_value != CAMERA_PTZ_TYPE_ELECTRONIC) {
LOGE("not supported PTZ type %d", set_value);
- ret = CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
+ return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
}
- goto _SET_COMMAND_DONE;
+ return CAMERA_ERROR_NONE;
case CAMERA_COMMAND_PAN:
cid = V4L2_CID_PAN_ABSOLUTE;
break;
case CAMERA_COMMAND_FLIP:
if (set_value != CAMERA_FLIP_NONE) {
LOGE("NOT_SUPPORTED flip %d", set_value);
- ret = CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
+ return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
}
- goto _SET_COMMAND_DONE;
+ return CAMERA_ERROR_NONE;
case CAMERA_COMMAND_CAPTURE_COUNT:
handle->capture_count = set_value;
LOGI("capture count %u", handle->capture_count);
- goto _SET_COMMAND_DONE;
+ return CAMERA_ERROR_NONE;
case CAMERA_COMMAND_CAPTURE_INTERVAL:
handle->capture_interval_ms = set_value;
LOGI("capture interval %u ms", handle->capture_interval_ms);
- goto _SET_COMMAND_DONE;
+ return CAMERA_ERROR_NONE;
+ case CAMERA_COMMAND_FOCUS_MODE:
+ LOGI("set focus mode [old:%d -> new:%d]", handle->focus_mode, set_value);
+ handle->focus_mode = set_value;
+ return CAMERA_ERROR_NONE;
+ case CAMERA_COMMAND_FOCUS_RANGE:
+ LOGI("set focus range [old:%d -> new:%d]", handle->focus_range, set_value);
+ handle->focus_range = set_value;
+ return CAMERA_ERROR_NONE;
+ case CAMERA_COMMAND_FOCUS_LEVEL:
+ LOGI("set focus level [old:%d -> new:%d]", handle->focus_level, set_value);
+ handle->focus_level = set_value;
+ return CAMERA_ERROR_NONE;
default:
LOGE("NOT_SUPPORTED command %"PRIx64, command);
- ret = CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
- goto _SET_COMMAND_DONE;
+ return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
}
ctrl_ret = __camera_v4l2_s_ctrl(handle->device_fd, cid, set_value);
case EACCES:
case EPERM:
LOGE("Permission denied %d", errno);
- ret = CAMERA_ERROR_PERMISSION_DENIED;
- break;
+ return CAMERA_ERROR_PERMISSION_DENIED;
case EINVAL:
LOGE("Invalid argument");
- ret = CAMERA_ERROR_INVALID_PARAMETER;
- break;
+ return CAMERA_ERROR_INVALID_PARAMETER;
case EBUSY:
LOGE("Device busy");
- ret = CAMERA_ERROR_DEVICE_BUSY;
- break;
+ return CAMERA_ERROR_DEVICE_BUSY;
case ENOTSUP:
LOGE("Not supported");
- ret = CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
- break;
+ return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
default:
LOGE("Unknown errro %d", errno);
- ret = CAMERA_ERROR_INTERNAL;
- break;
+ return CAMERA_ERROR_INTERNAL;
}
}
-_SET_COMMAND_DONE:
+ return CAMERA_ERROR_NONE;
+}
+
+
+int camera_v4l2_set_command(void *camera_handle, int64_t command, void *value)
+{
+ int ret = CAMERA_ERROR_NONE;
+ hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
+
+ g_mutex_lock(&handle->lock);
+
+ ret = __set_command(handle, command, value);
+
g_mutex_unlock(&handle->lock);
return ret;
g_mutex_lock(&handle->lock);
- LOGD("get command %"PRId64" - state %d", command, handle->state);
+ LOGD("get command %"PRIx64" - state %d", command, handle->state);
switch (command) {
case CAMERA_COMMAND_BRIGHTNESS:
case CAMERA_COMMAND_SHARPNESS:
cid = V4L2_CID_SHARPNESS;
break;
+ case CAMERA_COMMAND_FOCUS_MODE:
+ **(int **)value = handle->focus_mode;
+ LOGI("get focus mode %d", **(int **)value);
+ goto _GET_COMMAND_DONE;
+ case CAMERA_COMMAND_FOCUS_RANGE:
+ **(int **)value = handle->focus_range;
+ LOGI("get focus range %d", **(int **)value);
+ goto _GET_COMMAND_DONE;
+ case CAMERA_COMMAND_FOCUS_LEVEL:
+ **(int **)value = handle->focus_level;
+ LOGI("get focus level %d", **(int **)value);
+ goto _GET_COMMAND_DONE;
default:
- LOGE("NOT_SUPPORTED %"PRId64, command);
+ LOGE("NOT_SUPPORTED %"PRIx64, command);
g_mutex_unlock(&handle->lock);
return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
}
- ctrl_ret = __camera_v4l2_g_ctrl(handle->device_fd, cid, (int *)value);
+ ctrl_ret = __camera_v4l2_g_ctrl(handle->device_fd, cid, (int *)*value);
if (ctrl_ret < 0) {
switch (errno) {
case EACCES:
}
}
+_GET_COMMAND_DONE:
g_mutex_unlock(&handle->lock);
return ret;
}
+static void __dump_batch_command(camera_batch_command_control_s *batch_command)
+{
+ if (!batch_command) {
+ LOGE("NULL batch command");
+ return;
+ }
+
+ LOGI("[WHITE_BALANCE] %d", batch_command->white_balance);
+ LOGI("[ISO] %d", batch_command->iso);
+ LOGI("[CONTRAST] %d", batch_command->contrast);
+ LOGI("[HUE] %d", batch_command->hue);
+ LOGI("[SATURATION] %d", batch_command->saturation);
+ LOGI("[SHARPNESS] %d", batch_command->sharpness);
+ LOGI("[BRIGHTNESS] %d", batch_command->brightness);
+ LOGI("[EFFECT] %d", batch_command->effect);
+ LOGI("[SCENE_MODE] %d", batch_command->scene_mode);
+ LOGI("[EXPOSURE_MODE] %d", batch_command->exposure_mode);
+ LOGI("[EXPOSURE] %d", batch_command->exposure);
+ LOGI("[ROTATION] %d", batch_command->rotation);
+ LOGI("[FLIP] %d", batch_command->flip);
+ LOGI("[FOCUS_MODE] %d", batch_command->focus_mode);
+ LOGI("[FOCUS_RANGE] %d", batch_command->focus_range);
+ LOGI("[FOCUS_AREA] %d,%d,%dx%d", batch_command->focus_area.x, batch_command->focus_area.y,
+ batch_command->focus_area.width, batch_command->focus_area.height);
+ LOGI("[FOCUS_LEVEL] %d", batch_command->focus_level);
+ LOGI("[SHOT_MODE] %d", batch_command->shot_mode);
+ LOGI("[ANTI_SHAKE] %d", batch_command->anti_shake);
+ LOGI("[DIGITAL_ZOOM] %d", batch_command->digital_zoom);
+ LOGI("[OPTICAL_ZOOM] %d", batch_command->optical_zoom);
+ LOGI("[RECORDING_HINT] %d", batch_command->recording_hint);
+ LOGI("[WDR] %d", batch_command->wdr);
+ LOGI("[SHUTTER_SPEED] %d/%d", batch_command->shutter_speed.numerator, batch_command->shutter_speed.denominator);
+ LOGI("[FLASH_MODE] %d", batch_command->flash_mode);
+ LOGI("[FLASH_BRIGHTNESS] %d", batch_command->flash_brightness);
+ LOGI("[FACE_DETECTION] %d", batch_command->face_detection);
+ LOGI("[PTZ_TYPE] %d", batch_command->ptz_type);
+ LOGI("[PAN] %d", batch_command->pan);
+ LOGI("[TILT] %d", batch_command->tilt);
+ LOGI("[BITRATE] %d", batch_command->bitrate);
+ LOGI("[GOP_INTERVAL] %d", batch_command->gop_interval);
+ LOGI("[CAPTURE_COUNT] %d", batch_command->capture_count);
+ LOGI("[CAPTURE_INTERVAL] %d", batch_command->capture_interval);
+}
+
+
int camera_v4l2_set_batch_command(void *camera_handle, camera_batch_command_control_s *batch_command, int64_t *error_command)
{
+ int ret = CAMERA_ERROR_NONE;
+ int i = 0;
+ int support_count = 0;
hal_camera_handle *handle = (hal_camera_handle *)camera_handle;
+ set_batch_table_s set_table[] = {
+ {CAMERA_COMMAND_BRIGHTNESS, batch_command ? (void *)&batch_command->brightness : NULL},
+ {CAMERA_COMMAND_CONTRAST, batch_command ? (void *)&batch_command->contrast : NULL},
+ {CAMERA_COMMAND_SATURATION, batch_command ? (void *)&batch_command->saturation : NULL},
+ {CAMERA_COMMAND_SHARPNESS, batch_command ? (void *)&batch_command->sharpness : NULL},
+ {CAMERA_COMMAND_PTZ_TYPE, batch_command ? (void *)&batch_command->ptz_type : NULL},
+ {CAMERA_COMMAND_PAN, batch_command ? (void *)&batch_command->pan : NULL},
+ {CAMERA_COMMAND_TILT, batch_command ? (void *)&batch_command->tilt : NULL},
+ {CAMERA_COMMAND_FLIP, batch_command ? (void *)&batch_command->flip : NULL},
+ {CAMERA_COMMAND_CAPTURE_COUNT, batch_command ? (void *)&batch_command->capture_count : NULL},
+ {CAMERA_COMMAND_CAPTURE_INTERVAL, batch_command ? (void *)&batch_command->capture_interval : NULL},
+ {CAMERA_COMMAND_FOCUS_MODE, batch_command ? (void *)&batch_command->focus_mode : NULL},
+ {CAMERA_COMMAND_FOCUS_RANGE, batch_command ? (void *)&batch_command->focus_range : NULL},
+ {CAMERA_COMMAND_FOCUS_LEVEL, batch_command ? (void *)&batch_command->focus_level : NULL}
+ };
if (!handle || !batch_command) {
LOGE("NULL param %p %p", handle, batch_command);
g_mutex_lock(&handle->lock);
- LOGD("set batch command - flag %"PRIx64", state %d",
- batch_command->command_set_flag, handle->state);
+ support_count = sizeof(set_table) / sizeof(set_batch_table_s);
+
+ LOGD("set batch command - support count %d", support_count);
+
+ __dump_batch_command(batch_command);
+
+ for (i = 0 ; i < support_count ; i++) {
+ if (!(batch_command->command_set_flag & set_table[i].command))
+ continue;
- /* TODO: to be implemented */
+ ret = __set_command(handle, set_table[i].command, set_table[i].value);
+ if (ret != CAMERA_ERROR_NONE) {
+ LOGE("failed command %"PRIx64", ret 0x%x", set_table[i].command, ret);
+ break;
+ }
+ }
g_mutex_unlock(&handle->lock);
- return CAMERA_ERROR_NONE;
+ return ret;
}