From 2ad591f9ea58c9810c9904e15e3e98af84e3c6c6 Mon Sep 17 00:00:00 2001 From: Sergii Piatakov Date: Fri, 3 Aug 2018 11:41:06 +0300 Subject: [PATCH 01/11] camera: fix `-Wmacro-redefined` compiler warnings Test: add `USE_CAMERA_V4L2_HAL := true` to hardware/libhardware/modules/camera/3_4/Android.mk and build mmm hardware/libhardware/modules/camera/3_4 Change-Id: Ida00d842007e2a589907bc4fd1887076fd8b5b2a Signed-off-by: Sergii Piatakov --- modules/camera/3_4/camera.cpp | 5 +++-- modules/camera/3_4/common.h | 10 ---------- modules/camera/3_4/format_metadata_factory.cpp | 3 +++ .../camera/3_4/metadata/boottime_state_delegate.cpp | 3 +++ modules/camera/3_4/metadata/control.h | 2 +- modules/camera/3_4/metadata/enum_converter.cpp | 3 +++ modules/camera/3_4/metadata/enum_converter.h | 3 ++- modules/camera/3_4/metadata/map_converter.h | 3 ++- modules/camera/3_4/metadata/metadata.cpp | 3 +++ modules/camera/3_4/metadata/metadata.h | 2 +- modules/camera/3_4/metadata/metadata_reader.cpp | 5 +++-- modules/camera/3_4/metadata/metadata_reader.h | 2 +- modules/camera/3_4/metadata/ranged_converter.h | 3 ++- modules/camera/3_4/request_tracker.cpp | 5 +++-- modules/camera/3_4/request_tracker.h | 2 +- modules/camera/3_4/static_properties.cpp | 5 +++-- modules/camera/3_4/stream_format.cpp | 3 +++ modules/camera/3_4/v4l2_camera.cpp | 3 +++ modules/camera/3_4/v4l2_camera_hal.cpp | 3 +++ modules/camera/3_4/v4l2_metadata_factory.cpp | 3 +++ modules/camera/3_4/v4l2_wrapper.cpp | 3 +++ 21 files changed, 49 insertions(+), 25 deletions(-) diff --git a/modules/camera/3_4/camera.cpp b/modules/camera/3_4/camera.cpp index 79dca0b8..01236f3c 100644 --- a/modules/camera/3_4/camera.cpp +++ b/modules/camera/3_4/camera.cpp @@ -16,6 +16,9 @@ // Modified from hardware/libhardware/modules/camera/Camera.cpp +//#define LOG_NDEBUG 0 +#define LOG_TAG "Camera" + #include #include #include @@ -28,8 +31,6 @@ #include "metadata/metadata_common.h" -//#define LOG_NDEBUG 0 -#define LOG_TAG "Camera" #include #define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL) diff --git a/modules/camera/3_4/common.h b/modules/camera/3_4/common.h index ca5151d5..48cf2bd4 100644 --- a/modules/camera/3_4/common.h +++ b/modules/camera/3_4/common.h @@ -17,11 +17,8 @@ #ifndef V4L2_CAMERA_HAL_COMMON_H_ #define V4L2_CAMERA_HAL_COMMON_H_ -// #define LOG_NDEBUG 0 #include -#define LOG_TAG "V4L2CameraHAL" - // Helpers of logging (showing function name and line number). #define HAL_LOGE(fmt, args...) do { \ ALOGE("%s:%d: " fmt, __func__, __LINE__, ##args); \ @@ -59,11 +56,4 @@ #define HAL_LOG_ENTER() HAL_LOGV("enter") #define HAL_LOG_EXIT() HAL_LOGV("exit") -// Fix confliction in case it's defined elsewhere. -#ifndef DISALLOW_COPY_AND_ASSIGN -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&); \ - void operator=(const TypeName&); -#endif - #endif // V4L2_CAMERA_HAL_COMMON_H_ diff --git a/modules/camera/3_4/format_metadata_factory.cpp b/modules/camera/3_4/format_metadata_factory.cpp index db03678d..c6e739d2 100644 --- a/modules/camera/3_4/format_metadata_factory.cpp +++ b/modules/camera/3_4/format_metadata_factory.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "FormatMetadataFactory" + #include "format_metadata_factory.h" #include "arc/image_processor.h" diff --git a/modules/camera/3_4/metadata/boottime_state_delegate.cpp b/modules/camera/3_4/metadata/boottime_state_delegate.cpp index 5024cb2e..3508e852 100644 --- a/modules/camera/3_4/metadata/boottime_state_delegate.cpp +++ b/modules/camera/3_4/metadata/boottime_state_delegate.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "BoottimeStateDelegate" + #include #include diff --git a/modules/camera/3_4/metadata/control.h b/modules/camera/3_4/metadata/control.h index ad3f87b6..902a60c0 100644 --- a/modules/camera/3_4/metadata/control.h +++ b/modules/camera/3_4/metadata/control.h @@ -19,9 +19,9 @@ #include +#include #include -#include "../common.h" #include "metadata_common.h" #include "partial_metadata_interface.h" #include "tagged_control_delegate.h" diff --git a/modules/camera/3_4/metadata/enum_converter.cpp b/modules/camera/3_4/metadata/enum_converter.cpp index d5e0a876..14da006d 100644 --- a/modules/camera/3_4/metadata/enum_converter.cpp +++ b/modules/camera/3_4/metadata/enum_converter.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "EnumConverter" + #include "enum_converter.h" #include diff --git a/modules/camera/3_4/metadata/enum_converter.h b/modules/camera/3_4/metadata/enum_converter.h index df5cabb1..83f4daae 100644 --- a/modules/camera/3_4/metadata/enum_converter.h +++ b/modules/camera/3_4/metadata/enum_converter.h @@ -19,7 +19,8 @@ #include -#include "../common.h" +#include + #include "converter_interface.h" namespace v4l2_camera_hal { diff --git a/modules/camera/3_4/metadata/map_converter.h b/modules/camera/3_4/metadata/map_converter.h index b1734b5b..2324d744 100644 --- a/modules/camera/3_4/metadata/map_converter.h +++ b/modules/camera/3_4/metadata/map_converter.h @@ -22,7 +22,8 @@ #include #include -#include "../common.h" +#include + #include "converter_interface.h" namespace v4l2_camera_hal { diff --git a/modules/camera/3_4/metadata/metadata.cpp b/modules/camera/3_4/metadata/metadata.cpp index efc99592..c5106c71 100644 --- a/modules/camera/3_4/metadata/metadata.cpp +++ b/modules/camera/3_4/metadata/metadata.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "Metadata" + #include "metadata.h" #include diff --git a/modules/camera/3_4/metadata/metadata.h b/modules/camera/3_4/metadata/metadata.h index e2232b5f..615b5899 100644 --- a/modules/camera/3_4/metadata/metadata.h +++ b/modules/camera/3_4/metadata/metadata.h @@ -19,10 +19,10 @@ #include +#include #include #include -#include "../common.h" #include "metadata_common.h" namespace v4l2_camera_hal { diff --git a/modules/camera/3_4/metadata/metadata_reader.cpp b/modules/camera/3_4/metadata/metadata_reader.cpp index fe2ff859..dfb3adee 100644 --- a/modules/camera/3_4/metadata/metadata_reader.cpp +++ b/modules/camera/3_4/metadata/metadata_reader.cpp @@ -14,10 +14,11 @@ * limitations under the License. */ -#include "metadata_reader.h" - // #define LOG_NDEBUG 0 #define LOG_TAG "MetadataReader" + +#include "metadata_reader.h" + #include #include diff --git a/modules/camera/3_4/metadata/metadata_reader.h b/modules/camera/3_4/metadata/metadata_reader.h index 996bf8b4..8e05079e 100644 --- a/modules/camera/3_4/metadata/metadata_reader.h +++ b/modules/camera/3_4/metadata/metadata_reader.h @@ -22,9 +22,9 @@ #include #include +#include #include -#include "../common.h" #include "types.h" namespace default_camera_hal { diff --git a/modules/camera/3_4/metadata/ranged_converter.h b/modules/camera/3_4/metadata/ranged_converter.h index 115ac2a7..bc48767f 100644 --- a/modules/camera/3_4/metadata/ranged_converter.h +++ b/modules/camera/3_4/metadata/ranged_converter.h @@ -19,7 +19,8 @@ #include -#include "../common.h" +#include + #include "converter_interface.h" namespace v4l2_camera_hal { diff --git a/modules/camera/3_4/request_tracker.cpp b/modules/camera/3_4/request_tracker.cpp index 09f634d1..d4cbe47c 100644 --- a/modules/camera/3_4/request_tracker.cpp +++ b/modules/camera/3_4/request_tracker.cpp @@ -14,10 +14,11 @@ * limitations under the License. */ -#include "request_tracker.h" - // #define LOG_NDEBUG 0 #define LOG_TAG "RequestTracker" + +#include "request_tracker.h" + #include namespace default_camera_hal { diff --git a/modules/camera/3_4/request_tracker.h b/modules/camera/3_4/request_tracker.h index a632a614..e0bb4b52 100644 --- a/modules/camera/3_4/request_tracker.h +++ b/modules/camera/3_4/request_tracker.h @@ -22,9 +22,9 @@ #include #include +#include #include "capture_request.h" -#include "common.h" namespace default_camera_hal { diff --git a/modules/camera/3_4/static_properties.cpp b/modules/camera/3_4/static_properties.cpp index 5be9dcdd..e914567e 100644 --- a/modules/camera/3_4/static_properties.cpp +++ b/modules/camera/3_4/static_properties.cpp @@ -14,10 +14,11 @@ * limitations under the License. */ -#include "static_properties.h" - // #define LOG_NDEBUG 0 #define LOG_TAG "StaticProperties" + +#include "static_properties.h" + #include #include #include diff --git a/modules/camera/3_4/stream_format.cpp b/modules/camera/3_4/stream_format.cpp index 5f35e425..89b58bd3 100644 --- a/modules/camera/3_4/stream_format.cpp +++ b/modules/camera/3_4/stream_format.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "StreamFormat" + #include "stream_format.h" #include diff --git a/modules/camera/3_4/v4l2_camera.cpp b/modules/camera/3_4/v4l2_camera.cpp index 98b80622..62d790e5 100644 --- a/modules/camera/3_4/v4l2_camera.cpp +++ b/modules/camera/3_4/v4l2_camera.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "V4L2Camera" + #include "v4l2_camera.h" #include diff --git a/modules/camera/3_4/v4l2_camera_hal.cpp b/modules/camera/3_4/v4l2_camera_hal.cpp index 83746ceb..7ab96ac2 100644 --- a/modules/camera/3_4/v4l2_camera_hal.cpp +++ b/modules/camera/3_4/v4l2_camera_hal.cpp @@ -16,6 +16,9 @@ // Modified from hardware/libhardware/modules/camera/CameraHAL.cpp +//#define LOG_NDEBUG 0 +#define LOG_TAG "V4L2CameraHAL" + #include "v4l2_camera_hal.h" #include diff --git a/modules/camera/3_4/v4l2_metadata_factory.cpp b/modules/camera/3_4/v4l2_metadata_factory.cpp index bc8806f7..535f5629 100644 --- a/modules/camera/3_4/v4l2_metadata_factory.cpp +++ b/modules/camera/3_4/v4l2_metadata_factory.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "V4L2MetadataFactory" + #include "v4l2_metadata_factory.h" #include diff --git a/modules/camera/3_4/v4l2_wrapper.cpp b/modules/camera/3_4/v4l2_wrapper.cpp index d715e7ec..085683d6 100644 --- a/modules/camera/3_4/v4l2_wrapper.cpp +++ b/modules/camera/3_4/v4l2_wrapper.cpp @@ -14,6 +14,9 @@ * limitations under the License. */ +//#define LOG_NDEBUG 0 +#define LOG_TAG "V4L2Wrapper" + #include "v4l2_wrapper.h" #include From a01d1f82332389737d9f1f77e9705c9bdde17ef7 Mon Sep 17 00:00:00 2001 From: Sergii Piatakov Date: Fri, 3 Aug 2018 17:37:05 +0300 Subject: [PATCH 02/11] camera: fix `-Wformat` compiler warnings Test: add `USE_CAMERA_V4L2_HAL := true` to hardware/libhardware/modules/camera/3_4/Android.mk and build mmm hardware/libhardware/modules/camera/3_4 Change-Id: Ib1d1fc2de98436dd7e9d15ab324789725bb2002e Signed-off-by: Sergii Piatakov --- modules/camera/3_4/camera.cpp | 4 ++-- modules/camera/3_4/format_metadata_factory.cpp | 2 +- modules/camera/3_4/metadata/metadata_common.h | 6 +++--- modules/camera/3_4/metadata/metadata_reader.cpp | 4 ++-- modules/camera/3_4/static_properties.cpp | 12 ++++++------ modules/camera/3_4/v4l2_camera_hal.cpp | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/camera/3_4/camera.cpp b/modules/camera/3_4/camera.cpp index 01236f3c..35054a03 100644 --- a/modules/camera/3_4/camera.cpp +++ b/modules/camera/3_4/camera.cpp @@ -344,7 +344,7 @@ int Camera::processCaptureRequest(camera3_capture_request_t *temp_request) // Pre-process output buffers. if (request->output_buffers.size() <= 0) { - ALOGE("%s:%d: Invalid number of output buffers: %d", __func__, mId, + ALOGE("%s:%d: Invalid number of output buffers: %zu", __func__, mId, request->output_buffers.size()); return -EINVAL; } @@ -434,7 +434,7 @@ int Camera::flush() completeRequestWithError(request); } - ALOGV("%s:%d: Flushed %u requests.", __func__, mId, requests.size()); + ALOGV("%s:%d: Flushed %zu requests.", __func__, mId, requests.size()); // Call down into the device flushing. return flushBuffers(); diff --git a/modules/camera/3_4/format_metadata_factory.cpp b/modules/camera/3_4/format_metadata_factory.cpp index c6e739d2..5eed134e 100644 --- a/modules/camera/3_4/format_metadata_factory.cpp +++ b/modules/camera/3_4/format_metadata_factory.cpp @@ -104,7 +104,7 @@ int AddFormatComponents( return res; } - HAL_LOGI("Supports %d qualified formats.", qualified_formats.size()); + HAL_LOGI("Supports %zu qualified formats.", qualified_formats.size()); // Find sizes and frame/stall durations for all formats. // We also want to find the smallest max frame duration amongst all formats, diff --git a/modules/camera/3_4/metadata/metadata_common.h b/modules/camera/3_4/metadata/metadata_common.h index 34b77777..d98bd4d4 100644 --- a/modules/camera/3_4/metadata/metadata_common.h +++ b/modules/camera/3_4/metadata/metadata_common.h @@ -180,7 +180,7 @@ static int SingleTagValue(const android::CameraMetadata& metadata, } else if (entry.count != 1) { HAL_LOGE( "Error: expected metadata tag %d to contain exactly 1 value " - "(had %d).", + "(had %zu).", tag, entry.count); return -EINVAL; @@ -211,7 +211,7 @@ static int SingleTagValue(const android::CameraMetadata& metadata, } else if (entry.count != N) { HAL_LOGE( "Error: expected metadata tag %d to contain a single array of " - "exactly %d values (had %d).", + "exactly %zu values (had %zu).", tag, N, entry.count); @@ -284,7 +284,7 @@ static int VectorTagValue(const android::CameraMetadata& metadata, if (entry.count % N != 0) { HAL_LOGE( "Error: expected metadata tag %d to contain a vector of arrays of " - "length %d (had %d entries, which is not divisible by %d).", + "length %zu (had %zu entries, which is not divisible by %zu).", tag, N, entry.count, diff --git a/modules/camera/3_4/metadata/metadata_reader.cpp b/modules/camera/3_4/metadata/metadata_reader.cpp index dfb3adee..6a25127c 100644 --- a/modules/camera/3_4/metadata/metadata_reader.cpp +++ b/modules/camera/3_4/metadata/metadata_reader.cpp @@ -201,9 +201,9 @@ int MetadataReader::StreamStallDurations( } // Must have a non-negative stall. if (stall.duration < 0) { - ALOGE("%s: Invalid stall duration: negative stall %d.", + ALOGE("%s: Invalid stall duration: negative stall %lld.", __func__, - stall.duration); + static_cast(stall.duration)); return -EINVAL; } // TODO(b/31384253): YUV_420_888, RAW10, RAW12, RAW_OPAQUE, diff --git a/modules/camera/3_4/static_properties.cpp b/modules/camera/3_4/static_properties.cpp index e914567e..d41ac925 100644 --- a/modules/camera/3_4/static_properties.cpp +++ b/modules/camera/3_4/static_properties.cpp @@ -277,11 +277,11 @@ bool StaticProperties::SanityCheckStreamConfiguration( for (size_t i = 0; i < stream_config->num_streams; ++i) { const camera3_stream_t* stream = stream_config->streams[i]; if (stream == nullptr) { - ALOGE("%s: Stream %d is null", __func__, i); + ALOGE("%s: Stream %zu is null", __func__, i); return false; } else if (!IsInputType(stream->stream_type) && !IsOutputType(stream->stream_type)) { - ALOGE("%s: Stream %d type %d is neither an input nor an output type", + ALOGE("%s: Stream %zu type %d is neither an input nor an output type", __func__, i, stream->stream_type); @@ -321,7 +321,7 @@ bool StaticProperties::InputStreamsSupported( // Check the count. if (num_input_streams > max_input_streams_) { ALOGE( - "%s: Requested number of input streams %d is greater than " + "%s: Requested number of input streams %zu is greater than " "the maximum number supported by the device (%d).", __func__, num_input_streams, @@ -406,7 +406,7 @@ bool StaticProperties::OutputStreamsSupported( if (num_raw > max_raw_output_streams_) { ALOGE( "%s: Requested stream configuration exceeds maximum supported " - "raw output streams %d (requested %d).", + "raw output streams %d (requested %zu).", __func__, max_raw_output_streams_, num_raw); @@ -414,7 +414,7 @@ bool StaticProperties::OutputStreamsSupported( } else if (num_stalling > max_stalling_output_streams_) { ALOGE( "%s: Requested stream configuration exceeds maximum supported " - "stalling output streams %d (requested %d).", + "stalling output streams %d (requested %zu).", __func__, max_stalling_output_streams_, num_stalling); @@ -422,7 +422,7 @@ bool StaticProperties::OutputStreamsSupported( } else if (num_non_stalling > max_non_stalling_output_streams_) { ALOGE( "%s: Requested stream configuration exceeds maximum supported " - "non-stalling output streams %d (requested %d).", + "non-stalling output streams %d (requested %zu).", __func__, max_non_stalling_output_streams_, num_non_stalling); diff --git a/modules/camera/3_4/v4l2_camera_hal.cpp b/modules/camera/3_4/v4l2_camera_hal.cpp index 7ab96ac2..8ff8e5d2 100644 --- a/modules/camera/3_4/v4l2_camera_hal.cpp +++ b/modules/camera/3_4/v4l2_camera_hal.cpp @@ -115,7 +115,7 @@ V4L2CameraHAL::~V4L2CameraHAL() { } int V4L2CameraHAL::getNumberOfCameras() { - HAL_LOGV("returns %d", mCameras.size()); + HAL_LOGV("returns %zu", mCameras.size()); return mCameras.size(); } From 4d3eb7a33f64473e432b38a34dfc8921cb1a8d21 Mon Sep 17 00:00:00 2001 From: Sergii Piatakov Date: Fri, 3 Aug 2018 18:03:44 +0300 Subject: [PATCH 03/11] camera: fix `-Wunused-parameter` compiler warnings Test: add `USE_CAMERA_V4L2_HAL := true` to hardware/libhardware/modules/camera/3_4/Android.mk and build mmm hardware/libhardware/modules/camera/3_4 Change-Id: I1bfd688902c78fe69bfbee3bacc73c25a5ef6c5c Signed-off-by: Sergii Piatakov --- .../camera/3_4/metadata/ignored_control_delegate.h | 2 +- modules/camera/3_4/metadata/property.h | 8 ++++---- modules/camera/3_4/metadata/state.h | 10 +++++----- modules/camera/3_4/v4l2_camera_hal.cpp | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/camera/3_4/metadata/ignored_control_delegate.h b/modules/camera/3_4/metadata/ignored_control_delegate.h index f1d5da1b..dce457b1 100644 --- a/modules/camera/3_4/metadata/ignored_control_delegate.h +++ b/modules/camera/3_4/metadata/ignored_control_delegate.h @@ -32,7 +32,7 @@ class IgnoredControlDelegate : public ControlDelegateInterface { *value = value_; return 0; }; - int SetValue(const T& value) override { return 0; }; + int SetValue(const T& /*value*/) override { return 0; }; private: const T value_; diff --git a/modules/camera/3_4/metadata/property.h b/modules/camera/3_4/metadata/property.h index 6884c7dd..6a542b28 100644 --- a/modules/camera/3_4/metadata/property.h +++ b/modules/camera/3_4/metadata/property.h @@ -41,22 +41,22 @@ class Property : public PartialMetadataInterface { }; virtual int PopulateDynamicFields( - android::CameraMetadata* metadata) const override { + android::CameraMetadata* /*metadata*/) const override { return 0; }; virtual int PopulateTemplateRequest( - int template_type, android::CameraMetadata* metadata) const override { + int /*template_type*/, android::CameraMetadata* /*metadata*/) const override { return 0; }; virtual bool SupportsRequestValues( - const android::CameraMetadata& metadata) const override { + const android::CameraMetadata& /*metadata*/) const override { return true; }; virtual int SetRequestValues( - const android::CameraMetadata& metadata) override { + const android::CameraMetadata& /*metadata*/) override { return 0; }; diff --git a/modules/camera/3_4/metadata/state.h b/modules/camera/3_4/metadata/state.h index 54f66e47..13f2ea5f 100644 --- a/modules/camera/3_4/metadata/state.h +++ b/modules/camera/3_4/metadata/state.h @@ -54,7 +54,7 @@ class State : public PartialMetadataInterface { // ----------------------------------------------------------------------------- template -int State::PopulateStaticFields(android::CameraMetadata* metadata) const { +int State::PopulateStaticFields(android::CameraMetadata* /*metadata*/) const { HAL_LOG_ENTER(); return 0; } @@ -72,21 +72,21 @@ int State::PopulateDynamicFields(android::CameraMetadata* metadata) const { }; template -int State::PopulateTemplateRequest(int template_type, - android::CameraMetadata* metadata) const { +int State::PopulateTemplateRequest(int /*template_type*/, + android::CameraMetadata* /*metadata*/) const { HAL_LOG_ENTER(); return 0; }; template bool State::SupportsRequestValues( - const android::CameraMetadata& metadata) const { + const android::CameraMetadata& /*metadata*/) const { HAL_LOG_ENTER(); return true; }; template -int State::SetRequestValues(const android::CameraMetadata& metadata) { +int State::SetRequestValues(const android::CameraMetadata& /*metadata*/) { HAL_LOG_ENTER(); return 0; }; diff --git a/modules/camera/3_4/v4l2_camera_hal.cpp b/modules/camera/3_4/v4l2_camera_hal.cpp index 8ff8e5d2..d53b5d75 100644 --- a/modules/camera/3_4/v4l2_camera_hal.cpp +++ b/modules/camera/3_4/v4l2_camera_hal.cpp @@ -134,22 +134,22 @@ int V4L2CameraHAL::setCallbacks(const camera_module_callbacks_t* callbacks) { return 0; } -void V4L2CameraHAL::getVendorTagOps(vendor_tag_ops_t* ops) { +void V4L2CameraHAL::getVendorTagOps(vendor_tag_ops_t* /*ops*/) { HAL_LOG_ENTER(); // No vendor ops for this HAL. From : // "leave ops unchanged if no vendor tags are defined." } -int V4L2CameraHAL::openLegacy(const hw_module_t* module, - const char* id, - uint32_t halVersion, - hw_device_t** device) { +int V4L2CameraHAL::openLegacy(const hw_module_t* /*module*/, + const char* /*id*/, + uint32_t /*halVersion*/, + hw_device_t** /*device*/) { HAL_LOG_ENTER(); // Not supported. return -ENOSYS; } -int V4L2CameraHAL::setTorchMode(const char* camera_id, bool enabled) { +int V4L2CameraHAL::setTorchMode(const char* /*camera_id*/, bool /*enabled*/) { HAL_LOG_ENTER(); // TODO(b/29158098): HAL is required to respond appropriately if // the desired camera actually does support flash. From 1bd0addfc982bc978e0d075c754a715f8c22bb9d Mon Sep 17 00:00:00 2001 From: Sergii Piatakov Date: Mon, 6 Aug 2018 09:23:22 +0300 Subject: [PATCH 04/11] camera: fix `-Wreorder` compiler warnings Test: add `USE_CAMERA_V4L2_HAL := true` to hardware/libhardware/modules/camera/3_4/Android.mk and build mmm hardware/libhardware/modules/camera/3_4 Change-Id: I02cbe738fb7484e3a1d55712b0f0a55037e181e1 Signed-off-by: Sergii Piatakov --- modules/camera/3_4/v4l2_camera.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/camera/3_4/v4l2_camera.cpp b/modules/camera/3_4/v4l2_camera.cpp index 62d790e5..4ec68b78 100644 --- a/modules/camera/3_4/v4l2_camera.cpp +++ b/modules/camera/3_4/v4l2_camera.cpp @@ -76,12 +76,12 @@ V4L2Camera::V4L2Camera(int id, : default_camera_hal::Camera(id), device_(std::move(v4l2_wrapper)), metadata_(std::move(metadata)), - max_input_streams_(0), - max_output_streams_({{0, 0, 0}}), buffer_enqueuer_(new FunctionThread( std::bind(&V4L2Camera::enqueueRequestBuffers, this))), buffer_dequeuer_(new FunctionThread( - std::bind(&V4L2Camera::dequeueRequestBuffers, this))) { + std::bind(&V4L2Camera::dequeueRequestBuffers, this))), + max_input_streams_(0), + max_output_streams_({{0, 0, 0}}) { HAL_LOG_ENTER(); } From 752836d7a6e1b364068662099342190c43301288 Mon Sep 17 00:00:00 2001 From: Sergii Piatakov Date: Mon, 6 Aug 2018 09:32:25 +0300 Subject: [PATCH 05/11] camera: fix `-Wunused-private-field` compiler warnings Test: add `USE_CAMERA_V4L2_HAL := true` to hardware/libhardware/modules/camera/3_4/Android.mk and build mmm hardware/libhardware/modules/camera/3_4 Change-Id: I113e14a4296e098a6a04068262186aa8cb81fba7 Signed-off-by: Sergii Piatakov --- modules/camera/3_4/stream_format.cpp | 9 +++------ modules/camera/3_4/stream_format.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/camera/3_4/stream_format.cpp b/modules/camera/3_4/stream_format.cpp index 89b58bd3..401a2f09 100644 --- a/modules/camera/3_4/stream_format.cpp +++ b/modules/camera/3_4/stream_format.cpp @@ -44,8 +44,7 @@ StreamFormat::StreamFormat(int format, uint32_t width, uint32_t height) v4l2_pixel_format_(StreamFormat::HalToV4L2PixelFormat(format)), width_(width), height_(height), - bytes_per_line_(0), - min_buffer_size_(0) {} + bytes_per_line_(0) {} StreamFormat::StreamFormat(const v4l2_format& format) : type_(format.type), @@ -53,16 +52,14 @@ StreamFormat::StreamFormat(const v4l2_format& format) v4l2_pixel_format_(format.fmt.pix.pixelformat), width_(format.fmt.pix.width), height_(format.fmt.pix.height), - bytes_per_line_(format.fmt.pix.bytesperline), - min_buffer_size_(format.fmt.pix.sizeimage) {} + bytes_per_line_(format.fmt.pix.bytesperline) {} StreamFormat::StreamFormat(const arc::SupportedFormat& format) : type_(V4L2_BUF_TYPE_VIDEO_CAPTURE), v4l2_pixel_format_(format.fourcc), width_(format.width), height_(format.height), - bytes_per_line_(0), - min_buffer_size_(0) {} + bytes_per_line_(0) {} void StreamFormat::FillFormatRequest(v4l2_format* format) const { memset(format, 0, sizeof(*format)); diff --git a/modules/camera/3_4/stream_format.h b/modules/camera/3_4/stream_format.h index 720e3800..82ec440d 100644 --- a/modules/camera/3_4/stream_format.h +++ b/modules/camera/3_4/stream_format.h @@ -78,7 +78,6 @@ class StreamFormat { uint32_t width_; uint32_t height_; uint32_t bytes_per_line_; - uint32_t min_buffer_size_; }; } // namespace v4l2_camera_hal From 416b6d263fb67b98c06d9575eec03d451e84f12e Mon Sep 17 00:00:00 2001 From: Sergii Piatakov Date: Mon, 6 Aug 2018 09:38:44 +0300 Subject: [PATCH 06/11] camera: fix `-Wunused-variable` compiler warnings Test: add `USE_CAMERA_V4L2_HAL := true` to hardware/libhardware/modules/camera/3_4/Android.mk and build mmm hardware/libhardware/modules/camera/3_4 Change-Id: I2755278b739db0bb746a78d0b66e1f644a44ff19 Signed-off-by: Sergii Piatakov --- modules/camera/3_4/request_tracker.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/camera/3_4/request_tracker.cpp b/modules/camera/3_4/request_tracker.cpp index d4cbe47c..4168c3ba 100644 --- a/modules/camera/3_4/request_tracker.cpp +++ b/modules/camera/3_4/request_tracker.cpp @@ -128,7 +128,6 @@ bool RequestTracker::CanAddRequest(const CaptureRequest& request) const { // Check that each stream has space // (which implicitly checks if it is configured). - bool result = true; for (const auto stream : RequestStreams(request)) { if (StreamFull(stream)) { ALOGE("%s: Stream %p is full.", __func__, stream); From 64e7f2013b0e7ef7a57b5095ec36cd4d402279e5 Mon Sep 17 00:00:00 2001 From: Sergii Piatakov Date: Mon, 6 Aug 2018 10:13:05 +0300 Subject: [PATCH 07/11] camera: fix `-Wsign-compare` compiler warnings Test: add `USE_CAMERA_V4L2_HAL := true` to hardware/libhardware/modules/camera/3_4/Android.mk and build mmm hardware/libhardware/modules/camera/3_4 Change-Id: I47ee9e39c3bfee7927f4e57dfec459714c959e14 Signed-off-by: Sergii Piatakov --- modules/camera/3_4/static_properties.cpp | 18 +++++++++--------- modules/camera/3_4/v4l2_camera_hal.cpp | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/camera/3_4/static_properties.cpp b/modules/camera/3_4/static_properties.cpp index d41ac925..0e8ba230 100644 --- a/modules/camera/3_4/static_properties.cpp +++ b/modules/camera/3_4/static_properties.cpp @@ -295,7 +295,7 @@ bool StaticProperties::SanityCheckStreamConfiguration( bool StaticProperties::InputStreamsSupported( const camera3_stream_configuration_t* stream_config) { // Find the input stream(s). - size_t num_input_streams = 0; + int32_t num_input_streams = 0; int input_format = -1; for (size_t i = 0; i < stream_config->num_streams; ++i) { const camera3_stream_t* stream = stream_config->streams[i]; @@ -321,7 +321,7 @@ bool StaticProperties::InputStreamsSupported( // Check the count. if (num_input_streams > max_input_streams_) { ALOGE( - "%s: Requested number of input streams %zu is greater than " + "%s: Requested number of input streams %d is greater than " "the maximum number supported by the device (%d).", __func__, num_input_streams, @@ -371,10 +371,10 @@ bool StaticProperties::InputStreamsSupported( bool StaticProperties::OutputStreamsSupported( const camera3_stream_configuration_t* stream_config) { // Find and count output streams. - size_t num_raw = 0; - size_t num_stalling = 0; - size_t num_non_stalling = 0; - for (int i = 0; i < stream_config->num_streams; ++i) { + int32_t num_raw = 0; + int32_t num_stalling = 0; + int32_t num_non_stalling = 0; + for (size_t i = 0; i < stream_config->num_streams; ++i) { const camera3_stream_t* stream = stream_config->streams[i]; if (IsOutputType(stream->stream_type)) { // Check that this stream is valid as an output. @@ -406,7 +406,7 @@ bool StaticProperties::OutputStreamsSupported( if (num_raw > max_raw_output_streams_) { ALOGE( "%s: Requested stream configuration exceeds maximum supported " - "raw output streams %d (requested %zu).", + "raw output streams %d (requested %d).", __func__, max_raw_output_streams_, num_raw); @@ -414,7 +414,7 @@ bool StaticProperties::OutputStreamsSupported( } else if (num_stalling > max_stalling_output_streams_) { ALOGE( "%s: Requested stream configuration exceeds maximum supported " - "stalling output streams %d (requested %zu).", + "stalling output streams %d (requested %u).", __func__, max_stalling_output_streams_, num_stalling); @@ -422,7 +422,7 @@ bool StaticProperties::OutputStreamsSupported( } else if (num_non_stalling > max_non_stalling_output_streams_) { ALOGE( "%s: Requested stream configuration exceeds maximum supported " - "non-stalling output streams %d (requested %zu).", + "non-stalling output streams %d (requested %d).", __func__, max_non_stalling_output_streams_, num_non_stalling); diff --git a/modules/camera/3_4/v4l2_camera_hal.cpp b/modules/camera/3_4/v4l2_camera_hal.cpp index d53b5d75..386160f4 100644 --- a/modules/camera/3_4/v4l2_camera_hal.cpp +++ b/modules/camera/3_4/v4l2_camera_hal.cpp @@ -121,7 +121,7 @@ int V4L2CameraHAL::getNumberOfCameras() { int V4L2CameraHAL::getCameraInfo(int id, camera_info_t* info) { HAL_LOG_ENTER(); - if (id < 0 || id >= mCameras.size()) { + if (id < 0 || static_cast(id) >= mCameras.size()) { return -EINVAL; } // TODO(b/29185945): Hotplugging: return -EINVAL if unplugged. From 6a4d4d59bcbaf9e3a841a054980b0869a6be02a6 Mon Sep 17 00:00:00 2001 From: Sergii Piatakov Date: Mon, 6 Aug 2018 10:30:58 +0300 Subject: [PATCH 08/11] camera: fix `-Wmissing-field-initializers` compiler warnings Test: add `USE_CAMERA_V4L2_HAL := true` to hardware/libhardware/modules/camera/3_4/Android.mk and build mmm hardware/libhardware/modules/camera/3_4 Change-Id: I2c17b1e40b29ac400e0a950a9cd96d7f9404ea32 Signed-off-by: Sergii Piatakov --- modules/camera/3_4/camera.cpp | 5 +++- modules/camera/3_4/request_tracker_test.cpp | 6 ++++- modules/camera/3_4/static_properties_test.cpp | 25 ++++++++++++------- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/modules/camera/3_4/camera.cpp b/modules/camera/3_4/camera.cpp index 35054a03..387134f9 100644 --- a/modules/camera/3_4/camera.cpp +++ b/modules/camera/3_4/camera.cpp @@ -504,7 +504,10 @@ void Camera::sendResult(std::shared_ptr request) { static_cast(request->output_buffers.size()), request->output_buffers.data(), request->input_buffer.get(), - 1 // Total result; only 1 part. + 1, // Total result; only 1 part. + 0, // Number of physical camera metadata. + nullptr, + nullptr }; // Make the framework callback. mCallbackOps->process_capture_result(mCallbackOps, &result); diff --git a/modules/camera/3_4/request_tracker_test.cpp b/modules/camera/3_4/request_tracker_test.cpp index 8b73bd89..001ba78b 100644 --- a/modules/camera/3_4/request_tracker_test.cpp +++ b/modules/camera/3_4/request_tracker_test.cpp @@ -35,7 +35,11 @@ class RequestTrackerTest : public Test { stream2_.max_buffers = 3; dut_.reset(new RequestTracker()); streams_ = {&stream1_, &stream2_}; - camera3_stream_configuration_t config{static_cast(streams_.size()), streams_.data(), 0}; + camera3_stream_configuration_t config{ + static_cast(streams_.size()), + streams_.data(), + 0, + nullptr}; dut_->SetStreamConfiguration(config); } diff --git a/modules/camera/3_4/static_properties_test.cpp b/modules/camera/3_4/static_properties_test.cpp index 2cdb9d4d..13b9e964 100644 --- a/modules/camera/3_4/static_properties_test.cpp +++ b/modules/camera/3_4/static_properties_test.cpp @@ -94,10 +94,12 @@ class StaticPropertiesTest : public Test { } else if (input) { type = CAMERA3_STREAM_INPUT; } - return {static_cast(type), - static_cast(width), - static_cast(height), - static_cast(format)}; + camera3_stream_t stream; + stream.stream_type = type; + stream.width = width; + stream.height = height; + stream.format = format; + return stream; } void ExpectConfigurationSupported(std::vector& streams, @@ -109,7 +111,8 @@ class StaticPropertiesTest : public Test { camera3_stream_configuration_t config = { static_cast(stream_addresses.size()), stream_addresses.data(), - CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE}; + CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE, + nullptr}; PrepareDefaultDUT(); EXPECT_EQ(dut_->StreamConfigurationSupported(&config), expected); } @@ -435,7 +438,7 @@ TEST_F(StaticPropertiesTest, ConfigureNull) { TEST_F(StaticPropertiesTest, ConfigureEmptyStreams) { std::vector streams(1); camera3_stream_configuration_t config = { - 0, streams.data(), CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE}; + 0, streams.data(), CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE, nullptr}; PrepareDefaultDUT(); EXPECT_FALSE(dut_->StreamConfigurationSupported(&config)); } @@ -443,7 +446,10 @@ TEST_F(StaticPropertiesTest, ConfigureEmptyStreams) { TEST_F(StaticPropertiesTest, ConfigureNullStreams) { std::vector streams(2, nullptr); camera3_stream_configuration_t config = { - static_cast(streams.size()), streams.data(), CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE}; + static_cast(streams.size()), + streams.data(), + CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE, + nullptr}; PrepareDefaultDUT(); EXPECT_FALSE(dut_->StreamConfigurationSupported(&config)); } @@ -451,7 +457,7 @@ TEST_F(StaticPropertiesTest, ConfigureNullStreams) { TEST_F(StaticPropertiesTest, ConfigureNullStreamVector) { // Even if the camera claims to have multiple streams, check for null. camera3_stream_configuration_t config = { - 3, nullptr, CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE}; + 3, nullptr, CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE, nullptr}; PrepareDefaultDUT(); EXPECT_FALSE(dut_->StreamConfigurationSupported(&config)); } @@ -616,7 +622,8 @@ TEST_F(StaticPropertiesTest, ConfigureBadOperationMode) { camera3_stream_configuration_t config = { 1, &stream_address, - 99 // Not a valid operation mode. + 99, // Not a valid operation mode. + nullptr }; PrepareDefaultDUT(); EXPECT_FALSE(dut_->StreamConfigurationSupported(&config)); From 21583568a8acf94147f48a840bd5ffefc70c45a7 Mon Sep 17 00:00:00 2001 From: Sergii Piatakov Date: Mon, 6 Aug 2018 10:42:22 +0300 Subject: [PATCH 09/11] camera: fix `-Wpessimizing-move` compiler warnings Test: add `USE_CAMERA_V4L2_HAL := true` to hardware/libhardware/modules/camera/3_4/Android.mk and build mmm hardware/libhardware/modules/camera/3_4 Change-Id: I464761128a09d90415ee6ac1ef1244391edb0b54 Signed-off-by: Sergii Piatakov --- modules/camera/3_4/request_tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/camera/3_4/request_tracker.cpp b/modules/camera/3_4/request_tracker.cpp index 4168c3ba..f92d2544 100644 --- a/modules/camera/3_4/request_tracker.cpp +++ b/modules/camera/3_4/request_tracker.cpp @@ -51,7 +51,7 @@ std::set RequestStreams(const CaptureRequest& request) { for (const auto& output_buffer : request.output_buffers) { result.insert(output_buffer.stream); } - return std::move(result); + return result; } bool RequestTracker::Add(std::shared_ptr request) { From de617f0677a544d12e44615651d2d22f4c11e715 Mon Sep 17 00:00:00 2001 From: Sergii Piatakov Date: Mon, 6 Aug 2018 11:38:54 +0300 Subject: [PATCH 10/11] camera: fix `-Wunused-function` compiler warnings Test: add `USE_CAMERA_V4L2_HAL := true` to hardware/libhardware/modules/camera/3_4/Android.mk and build mmm hardware/libhardware/modules/camera/3_4 Change-Id: I96926932e7b11230d6c22fb081a89946f670511e Signed-off-by: Sergii Piatakov --- modules/camera/3_4/metadata/metadata_common.h | 21 +++++++++++++------ modules/camera/3_4/v4l2_camera.cpp | 12 ----------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/modules/camera/3_4/metadata/metadata_common.h b/modules/camera/3_4/metadata/metadata_common.h index d98bd4d4..52fb3ea5 100644 --- a/modules/camera/3_4/metadata/metadata_common.h +++ b/modules/camera/3_4/metadata/metadata_common.h @@ -120,32 +120,41 @@ static int UpdateMetadata(android::CameraMetadata* metadata, // A helper for other methods in this file. // Gets the data pointer of a given metadata entry into |*val|. -static void GetDataPointer(camera_metadata_ro_entry_t& entry, +template +inline void GetDataPointer(camera_metadata_ro_entry_t&, const T**); + +template <> +inline void GetDataPointer(camera_metadata_ro_entry_t& entry, const uint8_t** val) { *val = entry.data.u8; } -static void GetDataPointer(camera_metadata_ro_entry_t& entry, +template <> +inline void GetDataPointer(camera_metadata_ro_entry_t& entry, const int32_t** val) { *val = entry.data.i32; } -static void GetDataPointer(camera_metadata_ro_entry_t& entry, +template <> +inline void GetDataPointer(camera_metadata_ro_entry_t& entry, const float** val) { *val = entry.data.f; } -static void GetDataPointer(camera_metadata_ro_entry_t& entry, +template <> +inline void GetDataPointer(camera_metadata_ro_entry_t& entry, const int64_t** val) { *val = entry.data.i64; } -static void GetDataPointer(camera_metadata_ro_entry_t& entry, +template <> +inline void GetDataPointer(camera_metadata_ro_entry_t& entry, const double** val) { *val = entry.data.d; } -static void GetDataPointer(camera_metadata_ro_entry_t& entry, +template <> +inline void GetDataPointer(camera_metadata_ro_entry_t& entry, const camera_metadata_rational_t** val) { *val = entry.data.r; } diff --git a/modules/camera/3_4/v4l2_camera.cpp b/modules/camera/3_4/v4l2_camera.cpp index 4ec68b78..558b4535 100644 --- a/modules/camera/3_4/v4l2_camera.cpp +++ b/modules/camera/3_4/v4l2_camera.cpp @@ -39,18 +39,6 @@ namespace v4l2_camera_hal { -// Helper function for managing metadata. -static std::vector getMetadataKeys(const camera_metadata_t* metadata) { - std::vector keys; - size_t num_entries = get_camera_metadata_entry_count(metadata); - for (size_t i = 0; i < num_entries; ++i) { - camera_metadata_ro_entry_t entry; - get_camera_metadata_ro_entry(metadata, i, &entry); - keys.push_back(entry.tag); - } - return keys; -} - V4L2Camera* V4L2Camera::NewV4L2Camera(int id, const std::string path) { HAL_LOG_ENTER(); From 628e9d98e7989ac6270714deb0d3b1b555d54323 Mon Sep 17 00:00:00 2001 From: Sergii Piatakov Date: Mon, 6 Aug 2018 11:51:04 +0300 Subject: [PATCH 11/11] camera: replace `-Wno-error` flag with `-Werror` Test: add `USE_CAMERA_V4L2_HAL := true` to hardware/libhardware/modules/camera/3_4/Android.mk and build mmm hardware/libhardware/modules/camera/3_4 Change-Id: Ib7227f189cdcd52698ef1a70b1ad03b2351cb55f Signed-off-by: Sergii Piatakov --- modules/camera/3_4/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/camera/3_4/Android.mk b/modules/camera/3_4/Android.mk index 6ecedaca..3395b5bd 100644 --- a/modules/camera/3_4/Android.mk +++ b/modules/camera/3_4/Android.mk @@ -36,7 +36,7 @@ v4l2_static_libs := \ libyuv_static \ libjpeg_static_ndk \ -v4l2_cflags := -fno-short-enums -Wall -Wno-error -Wextra -fvisibility=hidden -DHAVE_JPEG +v4l2_cflags := -fno-short-enums -Wall -Wextra -Werror -fvisibility=hidden -DHAVE_JPEG v4l2_c_includes := $(call include-path-for, camera) \ external/libyuv/files/include \