From 99f3ea02d08d5263214ad3667d7929daa7c6ce27 Mon Sep 17 00:00:00 2001 From: Ari Hausman-Cohen Date: Tue, 2 Aug 2016 10:47:07 -0700 Subject: [PATCH] Change v4l2_wrapper set control to accept null. User does not need to pass a result pointer if they don't care about the result. BUG: 30140438 Change-Id: Ia98870f24df82464a3f00aad63a599063b98f03a --- modules/camera/3_4/v4l2_wrapper.cpp | 9 ++++++++- modules/camera/3_4/v4l2_wrapper.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/camera/3_4/v4l2_wrapper.cpp b/modules/camera/3_4/v4l2_wrapper.cpp index bce3200a..d331a777 100644 --- a/modules/camera/3_4/v4l2_wrapper.cpp +++ b/modules/camera/3_4/v4l2_wrapper.cpp @@ -231,12 +231,19 @@ int V4L2Wrapper::SetControl(uint32_t control_id, int32_t desired, int32_t* result) { HAL_LOG_ENTER(); + // TODO(b/29334616): When async, this may need to check if the stream + // is on, and if so, lock it off while setting format. Need to look + // into if V4L2 supports adjusting controls while the stream is on. + v4l2_control control{control_id, desired}; if (IoctlLocked(VIDIOC_S_CTRL, &control) < 0) { HAL_LOGE("S_CTRL fails: %s", strerror(errno)); return -ENODEV; } - *result = control.value; + // If the caller wants to know the result, pass it back. + if (result != nullptr) { + *result = control.value; + } return 0; } diff --git a/modules/camera/3_4/v4l2_wrapper.h b/modules/camera/3_4/v4l2_wrapper.h index d67b36ef..113499a8 100644 --- a/modules/camera/3_4/v4l2_wrapper.h +++ b/modules/camera/3_4/v4l2_wrapper.h @@ -45,7 +45,8 @@ class V4L2Wrapper { // Manage controls. int QueryControl(uint32_t control_id, v4l2_query_ext_ctrl* result); int GetControl(uint32_t control_id, int32_t* value); - int SetControl(uint32_t control_id, int32_t desired, int32_t* result); + int SetControl(uint32_t control_id, int32_t desired, + int32_t* result = nullptr); // Manage format. int SetFormat(const default_camera_hal::Stream& stream, uint32_t* result_max_buffers);