├── Android.bp ├── CleanSpec.mk ├── METADATA ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── OWNERS ├── hardware.c ├── include └── hardware │ ├── audio.h │ ├── audio_amplifier.h │ ├── audio_effect.h │ ├── audio_policy.h │ ├── bluetooth.h │ ├── boot_control.h │ ├── camera.h │ ├── camera2.h │ ├── camera3.h │ ├── camera_common.h │ ├── context_hub.h │ ├── display_defs.h │ ├── fb.h │ ├── fingerprint.h │ ├── gatekeeper.h │ ├── gnss-base.h │ ├── gps.h │ ├── gps_internal.h │ ├── gralloc.h │ ├── gralloc1.h │ ├── hardware.h │ ├── hdmi_cec.h │ ├── hw_auth_token.h │ ├── hwcomposer.h │ ├── hwcomposer2.h │ ├── hwcomposer_defs.h │ ├── input.h │ ├── keymaster1.h │ ├── keymaster2.h │ ├── keymaster_common.h │ ├── keymaster_defs.h │ ├── memtrack.h │ ├── nfc-base.h │ ├── nfc.h │ ├── nfc_tag.h │ ├── nvram.h │ ├── nvram_defs.h │ ├── power.h │ ├── sensors-base.h │ ├── sensors.h │ ├── sound_trigger.h │ ├── tv_input.h │ └── vibrator.h ├── include_all └── hardware │ ├── audio.h │ ├── audio_amplifier.h │ ├── audio_effect.h │ ├── audio_policy.h │ ├── bluetooth.h │ ├── boot_control.h │ ├── camera.h │ ├── camera2.h │ ├── camera3.h │ ├── camera_common.h │ ├── context_hub.h │ ├── display_defs.h │ ├── fb.h │ ├── fingerprint.h │ ├── gatekeeper.h │ ├── gnss-base.h │ ├── gps.h │ ├── gps_internal.h │ ├── gralloc.h │ ├── gralloc1.h │ ├── hardware.h │ ├── hdmi_cec.h │ ├── hw_auth_token.h │ ├── hwcomposer.h │ ├── hwcomposer2.h │ ├── hwcomposer_defs.h │ ├── input.h │ ├── keymaster1.h │ ├── keymaster2.h │ ├── keymaster_common.h │ ├── keymaster_defs.h │ ├── memtrack.h │ ├── nfc-base.h │ ├── nfc.h │ ├── nfc_tag.h │ ├── nvram.h │ ├── nvram_defs.h │ ├── power.h │ ├── sensors-base.h │ ├── sensors.h │ ├── sound_trigger.h │ ├── tv_input.h │ └── vibrator.h ├── include_vendor └── hardware │ ├── activity_recognition.h │ ├── audio_alsaops.h │ ├── consumerir.h │ ├── fused_location.h │ ├── lights.h │ ├── local_time_hal.h │ ├── radio.h │ ├── thermal.h │ └── vr.h ├── modules ├── README.android ├── audio │ ├── Android.bp │ ├── audio_amplifier.c │ ├── audio_hw.c │ └── audio_policy.c ├── audio_remote_submix │ ├── Android.bp │ ├── OWNERS │ ├── audio_hw.cpp │ └── tests │ │ ├── Android.bp │ │ └── remote_submix_tests.cpp ├── camera │ ├── 3_0 │ │ ├── Android.bp │ │ ├── Camera.cpp │ │ ├── Camera.h │ │ ├── CameraHAL.cpp │ │ ├── CameraHAL.h │ │ ├── ExampleCamera.cpp │ │ ├── ExampleCamera.h │ │ ├── Metadata.cpp │ │ ├── Metadata.h │ │ ├── Stream.cpp │ │ ├── Stream.h │ │ ├── VendorTags.cpp │ │ └── VendorTags.h │ └── 3_4 │ │ ├── Android.bp │ │ ├── README.md │ │ ├── arc │ │ ├── cached_frame.cpp │ │ ├── cached_frame.h │ │ ├── common.h │ │ ├── common_types.h │ │ ├── exif_utils.cpp │ │ ├── exif_utils.h │ │ ├── frame_buffer.cpp │ │ ├── frame_buffer.h │ │ ├── image_processor.cpp │ │ ├── image_processor.h │ │ ├── jpeg_compressor.cpp │ │ └── jpeg_compressor.h │ │ ├── camera.cpp │ │ ├── camera.h │ │ ├── capture_request.cpp │ │ ├── capture_request.h │ │ ├── common.h │ │ ├── format_metadata_factory.cpp │ │ ├── format_metadata_factory.h │ │ ├── format_metadata_factory_test.cpp │ │ ├── function_thread.h │ │ ├── metadata │ │ ├── array_vector.h │ │ ├── boottime_state_delegate.cpp │ │ ├── boottime_state_delegate.h │ │ ├── control.h │ │ ├── control_delegate_interface.h │ │ ├── control_delegate_interface_mock.h │ │ ├── control_options_interface.h │ │ ├── control_options_interface_mock.h │ │ ├── control_test.cpp │ │ ├── converter_interface.h │ │ ├── converter_interface_mock.h │ │ ├── default_option_delegate.h │ │ ├── default_option_delegate_mock.h │ │ ├── default_option_delegate_test.cpp │ │ ├── enum_converter.cpp │ │ ├── enum_converter.h │ │ ├── enum_converter_test.cpp │ │ ├── ignored_control_delegate.h │ │ ├── ignored_control_delegate_test.cpp │ │ ├── map_converter.h │ │ ├── map_converter_test.cpp │ │ ├── menu_control_options.h │ │ ├── menu_control_options_test.cpp │ │ ├── metadata.cpp │ │ ├── metadata.h │ │ ├── metadata_common.h │ │ ├── metadata_reader.cpp │ │ ├── metadata_reader.h │ │ ├── metadata_reader_mock.h │ │ ├── metadata_reader_test.cpp │ │ ├── metadata_test.cpp │ │ ├── no_effect_control_delegate.h │ │ ├── no_effect_control_delegate_test.cpp │ │ ├── partial_metadata_factory.h │ │ ├── partial_metadata_factory_test.cpp │ │ ├── partial_metadata_interface.h │ │ ├── partial_metadata_interface_mock.h │ │ ├── property.h │ │ ├── property_test.cpp │ │ ├── ranged_converter.h │ │ ├── ranged_converter_test.cpp │ │ ├── scaling_converter.h │ │ ├── slider_control_options.h │ │ ├── slider_control_options_test.cpp │ │ ├── state.h │ │ ├── state_delegate_interface.h │ │ ├── state_delegate_interface_mock.h │ │ ├── state_test.cpp │ │ ├── tagged_control_delegate.h │ │ ├── tagged_control_delegate_test.cpp │ │ ├── tagged_control_options.h │ │ ├── tagged_control_options_test.cpp │ │ ├── test_common.h │ │ ├── types.h │ │ ├── v4l2_control_delegate.h │ │ └── v4l2_control_delegate_test.cpp │ │ ├── request_tracker.cpp │ │ ├── request_tracker.h │ │ ├── request_tracker_test.cpp │ │ ├── static_properties.cpp │ │ ├── static_properties.h │ │ ├── static_properties_test.cpp │ │ ├── stream_format.cpp │ │ ├── stream_format.h │ │ ├── v4l2_camera.cpp │ │ ├── v4l2_camera.h │ │ ├── v4l2_camera_hal.cpp │ │ ├── v4l2_camera_hal.h │ │ ├── v4l2_metadata_factory.cpp │ │ ├── v4l2_metadata_factory.h │ │ ├── v4l2_wrapper.cpp │ │ ├── v4l2_wrapper.h │ │ └── v4l2_wrapper_mock.h ├── consumerir │ ├── Android.bp │ └── consumerir.c ├── fingerprint │ ├── Android.bp │ └── fingerprint.c ├── gralloc │ ├── Android.bp │ ├── framebuffer.cpp │ ├── gr.h │ ├── gralloc.cpp │ ├── gralloc_priv.h │ └── mapper.cpp ├── hwcomposer │ ├── Android.bp │ ├── README.android │ └── hwcomposer.cpp ├── input │ └── evdev │ │ ├── Android.bp │ │ ├── BitUtils.cpp │ │ ├── BitUtils.h │ │ ├── EvdevModule.cpp │ │ ├── InputDevice.cpp │ │ ├── InputDevice.h │ │ ├── InputDeviceManager.cpp │ │ ├── InputDeviceManager.h │ │ ├── InputHost.cpp │ │ ├── InputHost.h │ │ ├── InputHub.cpp │ │ ├── InputHub.h │ │ ├── InputMapper.cpp │ │ ├── InputMapper.h │ │ ├── MouseInputMapper.cpp │ │ ├── MouseInputMapper.h │ │ ├── SwitchInputMapper.cpp │ │ └── SwitchInputMapper.h ├── local_time │ ├── Android.bp │ └── local_time_hw.c ├── nfc-nci │ ├── Android.bp │ └── nfc_nci_example.cpp ├── nfc │ ├── Android.bp │ └── nfc_pn544_example.c ├── power │ ├── Android.bp │ └── power.c ├── radio │ ├── Android.bp │ ├── radio_hal_tool.c │ └── radio_hw.c ├── sensors │ ├── Android.bp │ ├── OWNERS │ ├── SensorEventQueue.cpp │ ├── SensorEventQueue.h │ ├── dynamic_sensor │ │ ├── Android.bp │ │ ├── BaseDynamicSensorDaemon.cpp │ │ ├── BaseDynamicSensorDaemon.h │ │ ├── BaseSensorObject.cpp │ │ ├── BaseSensorObject.h │ │ ├── ConnectionDetector.cpp │ │ ├── ConnectionDetector.h │ │ ├── DummyDynamicAccelDaemon.cpp │ │ ├── DummyDynamicAccelDaemon.h │ │ ├── DynamicSensorManager.cpp │ │ ├── DynamicSensorManager.h │ │ ├── DynamicSensorsSubHal.cpp │ │ ├── DynamicSensorsSubHal.h │ │ ├── HidDevice.h │ │ ├── HidRawDevice.cpp │ │ ├── HidRawDevice.h │ │ ├── HidRawSensor.cpp │ │ ├── HidRawSensor.h │ │ ├── HidRawSensorDaemon.cpp │ │ ├── HidRawSensorDaemon.h │ │ ├── HidRawSensorDevice.cpp │ │ ├── HidRawSensorDevice.h │ │ ├── HidSensorDef.h │ │ ├── HidUtils │ │ │ ├── Android.bp │ │ │ ├── HidDefs.h │ │ │ ├── HidGlobal.cpp │ │ │ ├── HidGlobal.h │ │ │ ├── HidItem.cpp │ │ │ ├── HidItem.h │ │ │ ├── HidLocal.cpp │ │ │ ├── HidLocal.h │ │ │ ├── HidLog.h │ │ │ ├── HidParser.cpp │ │ │ ├── HidParser.h │ │ │ ├── HidReport.cpp │ │ │ ├── HidReport.h │ │ │ ├── HidTree.cpp │ │ │ ├── HidTree.h │ │ │ ├── HidUtils.cpp │ │ │ ├── HidUtils.h │ │ │ ├── StreamIoUtil.h │ │ │ ├── TriState.h │ │ │ └── test │ │ │ │ ├── CopyBitsTest.cpp │ │ │ │ ├── HidParserExample.cpp │ │ │ │ ├── HidParserExample2.cpp │ │ │ │ ├── TestHidDescriptor.cpp │ │ │ │ ├── TestHidDescriptor.h │ │ │ │ ├── TestHidSensorSpec.h │ │ │ │ └── TriStateTest.cpp │ │ ├── README.md │ │ ├── RingBuffer.cpp │ │ ├── RingBuffer.h │ │ ├── SensorEventCallback.h │ │ ├── Utils.h │ │ ├── dynamic_sensors.aconfig │ │ ├── sensors.cpp │ │ ├── sensors.h │ │ └── test │ │ │ ├── HidRawDeviceTest.cpp │ │ │ └── HidRawSensorTest.cpp │ ├── multihal.cpp │ ├── multihal.h │ └── tests │ │ └── SensorEventQueue_test.cpp ├── soundtrigger │ ├── Android.bp │ └── sound_trigger_hw.c ├── thermal │ ├── Android.bp │ └── thermal.c ├── tv_input │ ├── Android.bp │ └── tv_input.cpp ├── usbaudio │ ├── Android.bp │ └── audio_hal.c ├── usbcamera │ ├── Android.bp │ ├── Camera.cpp │ ├── Camera.h │ ├── CameraHAL.cpp │ ├── CameraHAL.h │ ├── HotplugThread.cpp │ ├── HotplugThread.h │ ├── Metadata.cpp │ ├── Metadata.h │ ├── Stream.cpp │ ├── Stream.h │ ├── UsbCamera.cpp │ └── UsbCamera.h ├── vibrator │ ├── Android.bp │ └── vibrator.c └── vr │ ├── Android.bp │ └── vr.c ├── tests ├── camera2 │ └── AndroidTest.xml ├── camera3 │ ├── Android.bp │ ├── camera3test_fixtures.h │ └── camera3tests.cpp ├── fingerprint │ ├── Android.bp │ ├── fingerprint_test_fixtures.h │ └── fingerprint_tests.cpp ├── hardware │ ├── Android.bp │ ├── struct-last.cpp │ ├── struct-offset.cpp │ └── struct-size.cpp ├── hwc │ ├── Android.bp │ ├── cnativewindow.c │ ├── test-arrows.c │ ├── util.c │ └── util.h ├── input │ └── evdev │ │ ├── Android.bp │ │ ├── BitUtils_test.cpp │ │ ├── InputDevice_test.cpp │ │ ├── InputHub_test.cpp │ │ ├── InputMocks.cpp │ │ ├── InputMocks.h │ │ ├── MockInputHost.h │ │ ├── MouseInputMapper_test.cpp │ │ ├── SwitchInputMapper_test.cpp │ │ ├── TestHelpers.cpp │ │ └── TestHelpers.h └── nusensors │ ├── Android.bp │ └── nusensors.cpp └── update-includes.sh /METADATA: -------------------------------------------------------------------------------- 1 | third_party { 2 | license_type: NOTICE 3 | } 4 | -------------------------------------------------------------------------------- /MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LineageOS/android_hardware_libhardware/9a53e28cbdc3a9aa2106ca596fbb17dada6f53f4/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | zachoverflow@google.com 2 | elaurent@google.com 3 | jpawlowski@google.com 4 | malchev@google.com 5 | smoreland@google.com 6 | swillden@google.com 7 | per-file include/hardware/camera*=etalvala@google.com 8 | per-file include/hardware/sensors*=bduddie@google.com 9 | -------------------------------------------------------------------------------- /include/hardware/audio.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/audio.h -------------------------------------------------------------------------------- /include/hardware/audio_amplifier.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/audio_amplifier.h -------------------------------------------------------------------------------- /include/hardware/audio_effect.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/audio_effect.h -------------------------------------------------------------------------------- /include/hardware/audio_policy.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/audio_policy.h -------------------------------------------------------------------------------- /include/hardware/bluetooth.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/bluetooth.h -------------------------------------------------------------------------------- /include/hardware/boot_control.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/boot_control.h -------------------------------------------------------------------------------- /include/hardware/camera.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/camera.h -------------------------------------------------------------------------------- /include/hardware/camera2.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/camera2.h -------------------------------------------------------------------------------- /include/hardware/camera3.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/camera3.h -------------------------------------------------------------------------------- /include/hardware/camera_common.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/camera_common.h -------------------------------------------------------------------------------- /include/hardware/context_hub.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/context_hub.h -------------------------------------------------------------------------------- /include/hardware/display_defs.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/display_defs.h -------------------------------------------------------------------------------- /include/hardware/fb.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/fb.h -------------------------------------------------------------------------------- /include/hardware/fingerprint.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/fingerprint.h -------------------------------------------------------------------------------- /include/hardware/gatekeeper.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/gatekeeper.h -------------------------------------------------------------------------------- /include/hardware/gnss-base.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/gnss-base.h -------------------------------------------------------------------------------- /include/hardware/gps.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/gps.h -------------------------------------------------------------------------------- /include/hardware/gps_internal.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/gps_internal.h -------------------------------------------------------------------------------- /include/hardware/gralloc.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/gralloc.h -------------------------------------------------------------------------------- /include/hardware/gralloc1.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/gralloc1.h -------------------------------------------------------------------------------- /include/hardware/hardware.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/hardware.h -------------------------------------------------------------------------------- /include/hardware/hdmi_cec.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/hdmi_cec.h -------------------------------------------------------------------------------- /include/hardware/hw_auth_token.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/hw_auth_token.h -------------------------------------------------------------------------------- /include/hardware/hwcomposer.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/hwcomposer.h -------------------------------------------------------------------------------- /include/hardware/hwcomposer2.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/hwcomposer2.h -------------------------------------------------------------------------------- /include/hardware/hwcomposer_defs.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/hwcomposer_defs.h -------------------------------------------------------------------------------- /include/hardware/input.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/input.h -------------------------------------------------------------------------------- /include/hardware/keymaster1.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/keymaster1.h -------------------------------------------------------------------------------- /include/hardware/keymaster2.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/keymaster2.h -------------------------------------------------------------------------------- /include/hardware/keymaster_common.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/keymaster_common.h -------------------------------------------------------------------------------- /include/hardware/keymaster_defs.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/keymaster_defs.h -------------------------------------------------------------------------------- /include/hardware/memtrack.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/memtrack.h -------------------------------------------------------------------------------- /include/hardware/nfc-base.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/nfc-base.h -------------------------------------------------------------------------------- /include/hardware/nfc.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/nfc.h -------------------------------------------------------------------------------- /include/hardware/nfc_tag.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/nfc_tag.h -------------------------------------------------------------------------------- /include/hardware/nvram.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/nvram.h -------------------------------------------------------------------------------- /include/hardware/nvram_defs.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/nvram_defs.h -------------------------------------------------------------------------------- /include/hardware/power.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/power.h -------------------------------------------------------------------------------- /include/hardware/sensors-base.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/sensors-base.h -------------------------------------------------------------------------------- /include/hardware/sensors.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/sensors.h -------------------------------------------------------------------------------- /include/hardware/sound_trigger.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/sound_trigger.h -------------------------------------------------------------------------------- /include/hardware/tv_input.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/tv_input.h -------------------------------------------------------------------------------- /include/hardware/vibrator.h: -------------------------------------------------------------------------------- 1 | ../../include_all/hardware/vibrator.h -------------------------------------------------------------------------------- /include_all/hardware/hw_auth_token.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #ifndef ANDROID_HARDWARE_HW_AUTH_TOKEN_H 20 | #define ANDROID_HARDWARE_HW_AUTH_TOKEN_H 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif // __cplusplus 25 | 26 | #define HW_AUTH_TOKEN_VERSION 0 27 | 28 | typedef enum { 29 | HW_AUTH_NONE = 0, 30 | HW_AUTH_PASSWORD = 1 << 0, 31 | HW_AUTH_FINGERPRINT = 1 << 1, 32 | // Additional entries should be powers of 2. 33 | HW_AUTH_ANY = UINT32_MAX, 34 | } hw_authenticator_type_t; 35 | 36 | /** 37 | * Data format for an authentication record used to prove successful authentication. 38 | */ 39 | typedef struct __attribute__((__packed__)) { 40 | uint8_t version; // Current version is 0 41 | uint64_t challenge; 42 | uint64_t user_id; // secure user ID, not Android user ID 43 | uint64_t authenticator_id; // secure authenticator ID 44 | uint32_t authenticator_type; // hw_authenticator_type_t, in network order 45 | uint64_t timestamp; // in network order 46 | uint8_t hmac[32]; 47 | } hw_auth_token_t; 48 | 49 | #ifdef __cplusplus 50 | } // extern "C" 51 | #endif // __cplusplus 52 | 53 | #endif // ANDROID_HARDWARE_HW_AUTH_TOKEN_H 54 | -------------------------------------------------------------------------------- /include_all/hardware/nfc-base.h: -------------------------------------------------------------------------------- 1 | // This file is autogenerated by hidl-gen. Do not edit manually. 2 | // Source: android.hardware.nfc@1.0 3 | // Location: hardware/interfaces/nfc/1.0/ 4 | 5 | #ifndef HIDL_GENERATED_ANDROID_HARDWARE_NFC_V1_0_EXPORTED_CONSTANTS_H_ 6 | #define HIDL_GENERATED_ANDROID_HARDWARE_NFC_V1_0_EXPORTED_CONSTANTS_H_ 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | enum { 13 | HAL_NFC_OPEN_CPLT_EVT = 0u, 14 | HAL_NFC_CLOSE_CPLT_EVT = 1u, 15 | HAL_NFC_POST_INIT_CPLT_EVT = 2u, 16 | HAL_NFC_PRE_DISCOVER_CPLT_EVT = 3u, 17 | HAL_NFC_REQUEST_CONTROL_EVT = 4u, 18 | HAL_NFC_RELEASE_CONTROL_EVT = 5u, 19 | HAL_NFC_ERROR_EVT = 6u, 20 | }; 21 | 22 | enum { 23 | HAL_NFC_STATUS_OK = 0u, 24 | HAL_NFC_STATUS_FAILED = 1u, 25 | HAL_NFC_STATUS_ERR_TRANSPORT = 2u, 26 | HAL_NFC_STATUS_ERR_CMD_TIMEOUT = 3u, 27 | HAL_NFC_STATUS_REFUSED = 4u, 28 | }; 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // HIDL_GENERATED_ANDROID_HARDWARE_NFC_V1_0_EXPORTED_CONSTANTS_H_ 35 | -------------------------------------------------------------------------------- /include_all/hardware/nvram_defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /* 18 | * This file contains data type definitions and constants that are useful to 19 | * code interacting with and implementing the NVRAM HAL, even though it doesn't 20 | * use the actual NVRAM HAL module interface. Keeping this in a separate file 21 | * simplifies inclusion in low-level code which can't easily include the heavier 22 | * hardware.h due to lacking standard headers. 23 | */ 24 | 25 | #ifndef ANDROID_HARDWARE_NVRAM_DEFS_H 26 | #define ANDROID_HARDWARE_NVRAM_DEFS_H 27 | 28 | #include 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif // __cplusplus 33 | 34 | /* Values returned by nvram_device methods. */ 35 | typedef uint32_t nvram_result_t; 36 | 37 | const nvram_result_t NV_RESULT_SUCCESS = 0; 38 | const nvram_result_t NV_RESULT_INTERNAL_ERROR = 1; 39 | const nvram_result_t NV_RESULT_ACCESS_DENIED = 2; 40 | const nvram_result_t NV_RESULT_INVALID_PARAMETER = 3; 41 | const nvram_result_t NV_RESULT_SPACE_DOES_NOT_EXIST = 4; 42 | const nvram_result_t NV_RESULT_SPACE_ALREADY_EXISTS = 5; 43 | const nvram_result_t NV_RESULT_OPERATION_DISABLED = 6; 44 | 45 | /* Values describing available access controls. */ 46 | typedef uint32_t nvram_control_t; 47 | 48 | const nvram_control_t NV_CONTROL_PERSISTENT_WRITE_LOCK = 1; 49 | const nvram_control_t NV_CONTROL_BOOT_WRITE_LOCK = 2; 50 | const nvram_control_t NV_CONTROL_BOOT_READ_LOCK = 3; 51 | const nvram_control_t NV_CONTROL_WRITE_AUTHORIZATION = 4; 52 | const nvram_control_t NV_CONTROL_READ_AUTHORIZATION = 5; 53 | const nvram_control_t NV_CONTROL_WRITE_EXTEND = 6; 54 | 55 | const uint32_t NV_UNLIMITED_SPACES = 0xFFFFFFFF; 56 | 57 | #ifdef __cplusplus 58 | } // extern "C" 59 | #endif // __cplusplus 60 | 61 | #endif // ANDROID_HARDWARE_NVRAM_DEFS_H 62 | -------------------------------------------------------------------------------- /include_all/hardware/vibrator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _HARDWARE_VIBRATOR_H 18 | #define _HARDWARE_VIBRATOR_H 19 | 20 | #include 21 | 22 | __BEGIN_DECLS 23 | 24 | #define VIBRATOR_API_VERSION HARDWARE_MODULE_API_VERSION(1,0) 25 | 26 | /** 27 | * The id of this module 28 | */ 29 | #define VIBRATOR_HARDWARE_MODULE_ID "vibrator" 30 | 31 | /** 32 | * The id of the main vibrator device 33 | */ 34 | #define VIBRATOR_DEVICE_ID_MAIN "main_vibrator" 35 | 36 | struct vibrator_device; 37 | typedef struct vibrator_device { 38 | /** 39 | * Common methods of the vibrator device. This *must* be the first member of 40 | * vibrator_device as users of this structure will cast a hw_device_t to 41 | * vibrator_device pointer in contexts where it's known the hw_device_t references a 42 | * vibrator_device. 43 | */ 44 | struct hw_device_t common; 45 | 46 | /** Turn on vibrator 47 | * 48 | * This function must only be called after the previous timeout has expired or 49 | * was canceled (through vibrator_off()). 50 | * 51 | * @param timeout_ms number of milliseconds to vibrate 52 | * 53 | * @return 0 in case of success, negative errno code else 54 | */ 55 | int (*vibrator_on)(struct vibrator_device* vibradev, unsigned int timeout_ms); 56 | 57 | /** Turn off vibrator 58 | * 59 | * Cancel a previously-started vibration, if any. 60 | * 61 | * @return 0 in case of success, negative errno code else 62 | */ 63 | int (*vibrator_off)(struct vibrator_device* vibradev); 64 | } vibrator_device_t; 65 | 66 | static inline int vibrator_open(const struct hw_module_t* module, vibrator_device_t** device) 67 | { 68 | return module->methods->open(module, VIBRATOR_DEVICE_ID_MAIN, TO_HW_DEVICE_T_OPEN(device)); 69 | } 70 | 71 | __END_DECLS 72 | 73 | #endif // _HARDWARE_VIBRATOR_H 74 | -------------------------------------------------------------------------------- /modules/README.android: -------------------------------------------------------------------------------- 1 | Default (and possibly architecture dependents) HAL modules go here. 2 | 3 | 4 | libhardware.so eventually should contain *just* the HAL hub 5 | (hardware.c), everything in it should be rewritten as modules. 6 | 7 | Modules are .so in /vendor/lib/hw/ and have a well defined naming 8 | convention: 9 | 10 | /vendor/lib/hw/<*_HARDWARE_MODULE_ID>..so 11 | /vendor/lib/hw/<*_HARDWARE_MODULE_ID>..so 12 | /vendor/lib/hw/<*_HARDWARE_MODULE_ID>..so 13 | /vendor/lib/hw/<*_HARDWARE_MODULE_ID>.default.so 14 | 15 | They also have a well defined interface which lives in include/hardware/. 16 | 17 | A module can have several variants: "default", "arch" and "board", and they're 18 | loaded in the "board", "arch" and "default" order. 19 | The source code for the "board" variant, usually lives under partners/... 20 | 21 | The source code for "default" and "arch" would usually 22 | live under hardware/modules/. 23 | 24 | -------------------------------------------------------------------------------- /modules/audio_remote_submix/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "audio.r_submix.default", 26 | relative_install_path: "hw", 27 | vendor: true, 28 | srcs: ["audio_hw.cpp"], 29 | shared_libs: [ 30 | "liblog", 31 | "libcutils", 32 | "libmedia_helper", 33 | "libnbaio_mono", 34 | "libutils", 35 | ], 36 | 37 | cflags: ["-Wno-unused-parameter"], 38 | 39 | header_libs: ["libhardware_headers"], 40 | } 41 | -------------------------------------------------------------------------------- /modules/audio_remote_submix/OWNERS: -------------------------------------------------------------------------------- 1 | elaurent@google.com 2 | mnaganov@google.com 3 | jmtrivi@google.com 4 | -------------------------------------------------------------------------------- /modules/audio_remote_submix/tests/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_test { 25 | name: "r_submix_tests", 26 | 27 | srcs: ["remote_submix_tests.cpp"], 28 | 29 | shared_libs: [ 30 | "libhardware", 31 | "liblog", 32 | "libutils", 33 | ], 34 | 35 | cflags: ["-Wall", "-Werror", "-O0", "-g",], 36 | 37 | header_libs: ["libaudiohal_headers"], 38 | } 39 | -------------------------------------------------------------------------------- /modules/camera/3_0/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "camera.default", 26 | relative_install_path: "hw", 27 | 28 | include_dirs: [ 29 | "system/core/include", 30 | "system/media/camera/include", 31 | ], 32 | 33 | srcs: [ 34 | "CameraHAL.cpp", 35 | "Camera.cpp", 36 | "ExampleCamera.cpp", 37 | "Metadata.cpp", 38 | "Stream.cpp", 39 | "VendorTags.cpp", 40 | ], 41 | 42 | shared_libs: [ 43 | "libcamera_metadata", 44 | "libcutils", 45 | "liblog", 46 | "libsync", 47 | "libutils", 48 | ], 49 | 50 | cflags: [ 51 | "-Wall", 52 | "-Wextra", 53 | "-Werror", 54 | "-fvisibility=hidden", 55 | ], 56 | } 57 | -------------------------------------------------------------------------------- /modules/camera/3_0/CameraHAL.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CAMERA_HAL_H_ 18 | #define CAMERA_HAL_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "Camera.h" 25 | #include "VendorTags.h" 26 | 27 | namespace default_camera_hal { 28 | // CameraHAL contains all module state that isn't specific to an individual 29 | // camera device. 30 | class CameraHAL { 31 | public: 32 | explicit CameraHAL(int num_cameras); 33 | ~CameraHAL(); 34 | 35 | // Camera Module Interface (see ) 36 | int getNumberOfCameras(); 37 | int getCameraInfo(int camera_id, struct camera_info *info); 38 | int setCallbacks(const camera_module_callbacks_t *callbacks); 39 | void getVendorTagOps(vendor_tag_ops_t* ops); 40 | 41 | // Hardware Module Interface (see ) 42 | int open(const hw_module_t* mod, const char* name, hw_device_t** dev); 43 | 44 | private: 45 | // Number of cameras 46 | const int mNumberOfCameras; 47 | // Callback handle 48 | const camera_module_callbacks_t *mCallbacks; 49 | // Array of camera devices, contains mNumberOfCameras device pointers 50 | Camera **mCameras; 51 | }; 52 | } // namespace default_camera_hal 53 | 54 | #endif // CAMERA_HAL_H_ 55 | -------------------------------------------------------------------------------- /modules/camera/3_0/ExampleCamera.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef EXAMPLE_CAMERA_H_ 18 | #define EXAMPLE_CAMERA_H_ 19 | 20 | #include 21 | #include "Camera.h" 22 | 23 | namespace default_camera_hal { 24 | // ExampleCamera is an example for a specific camera device. The Camera object 25 | // contains all logic common between all cameras (e.g. front and back cameras), 26 | // while a specific camera device (e.g. ExampleCamera) holds all specific 27 | // metadata and logic about that device. 28 | class ExampleCamera : public Camera { 29 | public: 30 | explicit ExampleCamera(int id); 31 | ~ExampleCamera(); 32 | 33 | private: 34 | // Initialize static camera characteristics for individual device 35 | camera_metadata_t *initStaticInfo(); 36 | // Initialize whole device (templates/etc) when opened 37 | int initDevice(); 38 | // Initialize each template metadata controls 39 | int setPreviewTemplate(Metadata m); 40 | int setStillTemplate(Metadata m); 41 | int setRecordTemplate(Metadata m); 42 | int setSnapshotTemplate(Metadata m); 43 | int setZslTemplate(Metadata m); 44 | // Verify settings are valid for a capture with this device 45 | bool isValidCaptureSettings(const camera_metadata_t* settings); 46 | }; 47 | } // namespace default_camera_hal 48 | 49 | #endif // CAMERA_H_ 50 | -------------------------------------------------------------------------------- /modules/camera/3_0/Metadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef METADATA_H_ 18 | #define METADATA_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace default_camera_hal { 25 | // Metadata is a convenience class for dealing with libcamera_metadata 26 | class Metadata { 27 | public: 28 | Metadata(); 29 | ~Metadata(); 30 | // Initialize with framework metadata 31 | int init(const camera_metadata_t *metadata); 32 | 33 | // Parse and add an entry. Allocates and copies new storage for *data. 34 | int addUInt8(uint32_t tag, int count, const uint8_t *data); 35 | int add1UInt8(uint32_t tag, const uint8_t data); 36 | int addInt32(uint32_t tag, int count, const int32_t *data); 37 | int addFloat(uint32_t tag, int count, const float *data); 38 | int addInt64(uint32_t tag, int count, const int64_t *data); 39 | int addDouble(uint32_t tag, int count, const double *data); 40 | int addRational(uint32_t tag, int count, 41 | const camera_metadata_rational_t *data); 42 | 43 | // Get a handle to the current metadata 44 | // This is not a durable handle, and may be destroyed by add*/init 45 | camera_metadata_t* get(); 46 | 47 | private: 48 | // Actual internal storage 49 | camera_metadata_t* mData; 50 | // Destroy old metadata and replace with new 51 | void replace(camera_metadata_t *m); 52 | // Validate the tag, type and count for a metadata entry 53 | bool validate(uint32_t tag, int tag_type, int count); 54 | // Add a verified tag with data 55 | int add(uint32_t tag, int count, const void *tag_data); 56 | }; 57 | } // namespace default_camera_hal 58 | 59 | #endif // METADATA_H_ 60 | -------------------------------------------------------------------------------- /modules/camera/3_4/arc/common.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2016 The Chromium OS Authors. All rights reserved. 2 | * Use of this source code is governed by a BSD-style license that can be 3 | * found in the LICENSE file. 4 | */ 5 | 6 | #ifndef INCLUDE_ARC_COMMON_H_ 7 | #define INCLUDE_ARC_COMMON_H_ 8 | 9 | #include 10 | 11 | #include 12 | 13 | #define LOGF(level) LOG(level) << __FUNCTION__ << "(): " 14 | #define LOGFID(level, id) LOG(level) << __FUNCTION__ << "(): id: " << id << ": " 15 | #define LOGF_IF(level, res) LOG_IF(level, res) << __FUNCTION__ << "(): " 16 | 17 | #define VLOGF(level) VLOG(level) << __FUNCTION__ << "(): " 18 | #define VLOGFID(level, id) \ 19 | VLOG(level) << __FUNCTION__ << "(): id: " << id << ": " 20 | 21 | #define VLOGF_ENTER() VLOGF(1) << "enter" 22 | #define VLOGF_EXIT() VLOGF(1) << "exit" 23 | 24 | inline std::string FormatToString(int32_t format) { 25 | return std::string(reinterpret_cast(&format), 4); 26 | } 27 | 28 | #endif // INCLUDE_ARC_COMMON_H_ 29 | -------------------------------------------------------------------------------- /modules/camera/3_4/arc/common_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The Chromium OS Authors. All rights reserved. 3 | * Use of this source code is governed by a BSD-style license that can be 4 | * found in the LICENSE file. 5 | */ 6 | 7 | #ifndef HAL_USB_COMMON_TYPES_H_ 8 | #define HAL_USB_COMMON_TYPES_H_ 9 | 10 | #include 11 | #include 12 | 13 | namespace arc { 14 | 15 | struct DeviceInfo { 16 | // ex: /dev/video0 17 | std::string device_path; 18 | // USB vender id 19 | std::string usb_vid; 20 | // USB product id 21 | std::string usb_pid; 22 | // Some cameras need to wait several frames to output correct images. 23 | uint32_t frames_to_skip_after_streamon; 24 | 25 | // Member definitions can be found in https://developer.android.com/ 26 | // reference/android/hardware/camera2/CameraCharacteristics.html 27 | uint32_t lens_facing; 28 | int32_t sensor_orientation; 29 | float horizontal_view_angle_16_9; 30 | float horizontal_view_angle_4_3; 31 | std::vector lens_info_available_focal_lengths; 32 | float lens_info_minimum_focus_distance; 33 | float lens_info_optimal_focus_distance; 34 | float vertical_view_angle_16_9; 35 | float vertical_view_angle_4_3; 36 | }; 37 | 38 | typedef std::vector DeviceInfos; 39 | 40 | struct SupportedFormat { 41 | uint32_t width; 42 | uint32_t height; 43 | uint32_t fourcc; 44 | // All the supported frame rates in fps with given width, height, and 45 | // pixelformat. This is not sorted. For example, suppose width, height, and 46 | // fourcc are 640x480 YUYV. If frameRates are 15.0 and 30.0, the camera 47 | // supports outputting 640X480 YUYV in 15fps or 30fps. 48 | std::vector frameRates; 49 | }; 50 | 51 | typedef std::vector SupportedFormats; 52 | 53 | } // namespace arc 54 | 55 | #endif // HAL_USB_COMMON_TYPES_H_ 56 | -------------------------------------------------------------------------------- /modules/camera/3_4/arc/image_processor.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 The Chromium OS Authors. All rights reserved. 2 | * Use of this source code is governed by a BSD-style license that can be 3 | * found in the LICENSE file. 4 | */ 5 | 6 | #ifndef HAL_USB_IMAGE_PROCESSOR_H_ 7 | #define HAL_USB_IMAGE_PROCESSOR_H_ 8 | 9 | #include 10 | // FourCC pixel formats (defined as V4L2_PIX_FMT_*). 11 | #include 12 | // Declarations of HAL_PIXEL_FORMAT_XXX. 13 | #include 14 | 15 | #include "frame_buffer.h" 16 | 17 | namespace arc { 18 | 19 | // V4L2_PIX_FMT_YVU420(YV12) in ImageProcessor has alignment requirement. 20 | // The stride of Y, U, and V planes should a multiple of 16 pixels. 21 | struct ImageProcessor { 22 | // Calculate the output buffer size when converting to the specified pixel 23 | // format. |fourcc| is defined as V4L2_PIX_FMT_* in linux/videodev2.h. 24 | // Return 0 on error. 25 | static size_t GetConvertedSize(int fourcc, uint32_t width, uint32_t height); 26 | 27 | // Return whether this class supports the provided conversion. 28 | static bool SupportsConversion(uint32_t from_fourcc, uint32_t to_fourcc); 29 | 30 | // Convert format from |in_frame.fourcc| to |out_frame->fourcc|. Caller should 31 | // fill |data|, |buffer_size|, |width|, and |height| of |out_frame|. The 32 | // function will fill |out_frame->data_size|. Return non-zero error code on 33 | // failure; return 0 on success. 34 | static int ConvertFormat(const android::CameraMetadata& metadata, 35 | const FrameBuffer& in_frame, FrameBuffer* out_frame); 36 | 37 | // Scale image size according to |in_frame| and |out_frame|. Only support 38 | // V4L2_PIX_FMT_YUV420 format. Caller should fill |data|, |width|, |height|, 39 | // and |buffer_size| of |out_frame|. The function will fill |data_size| and 40 | // |fourcc| of |out_frame|. 41 | static int Scale(const FrameBuffer& in_frame, FrameBuffer* out_frame); 42 | }; 43 | 44 | } // namespace arc 45 | 46 | #endif // HAL_USB_IMAGE_PROCESSOR_H_ 47 | -------------------------------------------------------------------------------- /modules/camera/3_4/capture_request.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "capture_request.h" 18 | 19 | namespace default_camera_hal { 20 | 21 | CaptureRequest::CaptureRequest() : CaptureRequest(nullptr) {} 22 | 23 | CaptureRequest::CaptureRequest(const camera3_capture_request_t* request) { 24 | if (!request) { 25 | return; 26 | } 27 | 28 | frame_number = request->frame_number; 29 | 30 | // CameraMetadata makes copies of camera_metadata_t through the 31 | // assignment operator (the constructor taking a camera_metadata_t* 32 | // takes ownership instead). 33 | settings = request->settings; 34 | 35 | // camera3_stream_buffer_t can be default copy constructed, 36 | // as its pointer values are handles, not ownerships. 37 | 38 | // Copy the input buffer. 39 | if (request->input_buffer) { 40 | input_buffer = 41 | std::make_unique(*request->input_buffer); 42 | } 43 | 44 | // Safely copy all the output buffers. 45 | uint32_t num_output_buffers = request->num_output_buffers; 46 | if (num_output_buffers < 0 || !request->output_buffers) { 47 | num_output_buffers = 0; 48 | } 49 | output_buffers.insert(output_buffers.end(), 50 | request->output_buffers, 51 | request->output_buffers + num_output_buffers); 52 | } 53 | 54 | } // namespace default_camera_hal 55 | -------------------------------------------------------------------------------- /modules/camera/3_4/capture_request.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef DEFAULT_CAMERA_HAL_CAPTURE_REQUEST_H_ 18 | #define DEFAULT_CAMERA_HAL_CAPTURE_REQUEST_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | namespace default_camera_hal { 27 | 28 | // A simple wrapper for camera3_capture_request_t, 29 | // with a constructor that makes a deep copy from the original struct. 30 | struct CaptureRequest { 31 | uint32_t frame_number; 32 | android::CameraMetadata settings; 33 | std::unique_ptr input_buffer; 34 | std::vector output_buffers; 35 | 36 | CaptureRequest(); 37 | // Create a deep copy of |request|. 38 | CaptureRequest(const camera3_capture_request_t* request); 39 | }; 40 | 41 | } // namespace default_camera_hal 42 | 43 | #endif // DEFAULT_CAMERA_HAL_CAPTURE_REQUEST_H_ 44 | -------------------------------------------------------------------------------- /modules/camera/3_4/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_COMMON_H_ 18 | #define V4L2_CAMERA_HAL_COMMON_H_ 19 | 20 | #include 21 | 22 | // Helpers of logging (showing function name and line number). 23 | #define HAL_LOGE(fmt, args...) do { \ 24 | ALOGE("%s:%d: " fmt, __func__, __LINE__, ##args); \ 25 | } while(0) 26 | 27 | #define HAL_LOGE_IF(cond, fmt, args...) do { \ 28 | ALOGE_IF(cond, "%s:%d: " fmt, __func__, __LINE__, ##args); \ 29 | } while(0) 30 | 31 | #define HAL_LOGW(fmt, args...) do { \ 32 | ALOGW("%s:%d: " fmt, __func__, __LINE__, ##args); \ 33 | } while(0) 34 | 35 | #define HAL_LOGW_IF(cond, fmt, args...) do { \ 36 | ALOGW_IF(cond, "%s:%d: " fmt, __func__, __LINE__, ##args); \ 37 | } while(0) 38 | 39 | #define HAL_LOGI(fmt, args...) do { \ 40 | ALOGI("%s:%d: " fmt, __func__, __LINE__, ##args); \ 41 | } while(0) 42 | 43 | #define HAL_LOGI_IF(cond, fmt, args...) do { \ 44 | ALOGI_IF(cond, "%s:%d: " fmt, __func__, __LINE__, ##args); \ 45 | } while(0) 46 | 47 | #define HAL_LOGD(fmt, args...) do { \ 48 | ALOGD("%s:%d: " fmt, __func__, __LINE__, ##args); \ 49 | } while(0) 50 | 51 | #define HAL_LOGV(fmt, args...) do { \ 52 | ALOGV("%s:%d: " fmt, __func__, __LINE__, ##args); \ 53 | } while(0) 54 | 55 | // Log enter/exit of methods. 56 | #define HAL_LOG_ENTER() HAL_LOGV("enter") 57 | #define HAL_LOG_EXIT() HAL_LOGV("exit") 58 | 59 | #endif // V4L2_CAMERA_HAL_COMMON_H_ 60 | -------------------------------------------------------------------------------- /modules/camera/3_4/format_metadata_factory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_FORMAT_METADATA_FACTORY_H_ 18 | #define V4L2_CAMERA_HAL_FORMAT_METADATA_FACTORY_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include "metadata/metadata_common.h" 24 | #include "v4l2_wrapper.h" 25 | 26 | namespace v4l2_camera_hal { 27 | 28 | // A factory method to construct all the format-related 29 | // partial metadata for a V4L2 device. 30 | int AddFormatComponents( 31 | std::shared_ptr device, 32 | std::insert_iterator insertion_point); 33 | 34 | } // namespace v4l2_camera_hal 35 | 36 | #endif // V4L2_CAMERA_HAL_FORMAT_METADATA_FACTORY_H_ 37 | -------------------------------------------------------------------------------- /modules/camera/3_4/function_thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_FUNCTION_THREAD_H_ 18 | #define V4L2_CAMERA_HAL_FUNCTION_THREAD_H_ 19 | 20 | #include 21 | 22 | #include 23 | 24 | namespace v4l2_camera_hal { 25 | 26 | class FunctionThread : public android::Thread { 27 | public: 28 | FunctionThread(std::function function) : function_(function){}; 29 | 30 | private: 31 | bool threadLoop() override { 32 | bool result = function_(); 33 | return result; 34 | }; 35 | 36 | std::function function_; 37 | }; 38 | 39 | } // namespace v4l2_camera_hal 40 | 41 | #endif // V4L2_CAMERA_HAL_FUNCTION_THREAD_H_ 42 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/array_vector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_ARRAY_VECTOR_H_ 18 | #define V4L2_CAMERA_HAL_ARRAY_VECTOR_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace v4l2_camera_hal { 24 | // ArrayVector behaves like a std::vector of fixed length C arrays, 25 | // with push_back accepting std::arrays to standardize length. 26 | // Specific methods to get number of arrays/number of elements 27 | // are provided and an ambiguous "size" is not, to avoid accidental 28 | // incorrect use. 29 | template 30 | class ArrayVector { 31 | public: 32 | const T* data() const { return mItems.data(); } 33 | // The number of arrays. 34 | size_t num_arrays() const { return mItems.size() / N; } 35 | // The number of elements amongst all arrays. 36 | size_t total_num_elements() const { return mItems.size(); } 37 | 38 | // Access the ith array. 39 | const T* operator[](int i) const { return mItems.data() + (i * N); } 40 | T* operator[](int i) { return mItems.data() + (i * N); } 41 | 42 | void push_back(const std::array& values) { 43 | mItems.insert(mItems.end(), values.begin(), values.end()); 44 | } 45 | 46 | private: 47 | std::vector mItems; 48 | }; 49 | 50 | } // namespace v4l2_camera_hal 51 | 52 | #endif // V4L2_CAMERA_HAL_ARRAY_VECTOR_H_ 53 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/boottime_state_delegate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | //#define LOG_NDEBUG 0 18 | #define LOG_TAG "BoottimeStateDelegate" 19 | 20 | #include "boottime_state_delegate.h" 21 | 22 | #include 23 | #include 24 | 25 | #include "common.h" 26 | 27 | namespace v4l2_camera_hal { 28 | 29 | int BoottimeStateDelegate::GetValue(int64_t* value) { 30 | struct timespec ts; 31 | 32 | int res = clock_gettime(CLOCK_BOOTTIME, &ts); 33 | if (res) { 34 | HAL_LOGE("Failed to get BOOTTIME for state delegate: %d (%s)", 35 | errno, 36 | strerror(errno)); 37 | return -errno; 38 | } 39 | *value = ts.tv_sec * 1000000000ULL + ts.tv_nsec; 40 | 41 | return 0; 42 | } 43 | 44 | } // namespace v4l2_camera_hal 45 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/boottime_state_delegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_BOOTTIME_STATE_DELEGATE_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_BOOTTIME_STATE_DELEGATE_H_ 19 | 20 | #include 21 | 22 | #include "state_delegate_interface.h" 23 | 24 | namespace v4l2_camera_hal { 25 | 26 | // A StateDelegate is simply a dynamic value that can be queried. 27 | // The value may change between queries. 28 | class BoottimeStateDelegate : public StateDelegateInterface { 29 | public: 30 | BoottimeStateDelegate(){}; 31 | ~BoottimeStateDelegate(){}; 32 | 33 | int GetValue(int64_t* value) override; 34 | }; 35 | 36 | } // namespace v4l2_camera_hal 37 | 38 | #endif // V4L2_CAMERA_HAL_METADATA_BOOTTIME_STATE_DELEGATE_H_ 39 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/control_delegate_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_CONTROL_DELEGATE_INTERFACE_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_CONTROL_DELEGATE_INTERFACE_H_ 19 | 20 | #include "state_delegate_interface.h" 21 | 22 | namespace v4l2_camera_hal { 23 | 24 | // A ControlDelegate extends StateDelegate with a setter method. 25 | template 26 | class ControlDelegateInterface : public StateDelegateInterface { 27 | public: 28 | virtual ~ControlDelegateInterface(){}; 29 | 30 | // ControlDelegates are allowed to be unreliable, so SetValue is best-effort; 31 | // GetValue immediately after may not match (SetValue may, for example, 32 | // automatically replace invalid values with valid ones, 33 | // or have a delay before setting the requested value). 34 | // Returns 0 on success, error code on failure. 35 | virtual int SetValue(const T& value) = 0; 36 | // Children must also override GetValue from StateDelegateInterface. 37 | }; 38 | 39 | } // namespace v4l2_camera_hal 40 | 41 | #endif // V4L2_CAMERA_HAL_METADATA_CONTROL_DELEGATE_INTERFACE_H_ 42 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/control_delegate_interface_mock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Mock for control delegate interfaces. 18 | 19 | #ifndef V4L2_CAMERA_HAL_METADATA_CONTROL_DELEGATE_INTERFACE_MOCK_H_ 20 | #define V4L2_CAMERA_HAL_METADATA_CONTROL_DELEGATE_INTERFACE_MOCK_H_ 21 | 22 | #include "control_delegate_interface.h" 23 | 24 | #include 25 | 26 | namespace v4l2_camera_hal { 27 | 28 | template 29 | class ControlDelegateInterfaceMock : public ControlDelegateInterface { 30 | public: 31 | ControlDelegateInterfaceMock(){}; 32 | MOCK_METHOD1_T(GetValue, int(T*)); 33 | MOCK_METHOD1_T(SetValue, int(const T&)); 34 | }; 35 | 36 | } // namespace v4l2_camera_hal 37 | 38 | #endif // V4L2_CAMERA_HAL_METADATA_CONTROL_DELEGATE_INTERFACE_MOCK_H_ 39 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/control_options_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_CONTROL_OPTIONS_INTERFACE_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_CONTROL_OPTIONS_INTERFACE_H_ 19 | 20 | #include 21 | 22 | namespace v4l2_camera_hal { 23 | 24 | // A ControlOptions defines acceptable values for a control. 25 | template 26 | class ControlOptionsInterface { 27 | public: 28 | virtual ~ControlOptionsInterface(){}; 29 | 30 | // Get a metadata-acceptable representation of the options. 31 | // For enums this will be a list of values, for ranges this 32 | // will be min and max, etc. 33 | virtual std::vector MetadataRepresentation() = 0; 34 | // Get whether or not a given value is acceptable. 35 | virtual bool IsSupported(const T& option); 36 | // Get a default option for a given template type, from the available options. 37 | // Because a default must be available, any ControlOptions should have at 38 | // least one supported value. 39 | virtual int DefaultValueForTemplate(int template_type, T* default_value); 40 | }; 41 | 42 | } // namespace v4l2_camera_hal 43 | 44 | #endif // V4L2_CAMERA_HAL_METADATA_CONTROL_OPTIONS_INTERFACE_H_ 45 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/control_options_interface_mock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Mock for control options interfaces. 18 | 19 | #ifndef V4L2_CAMERA_HAL_METADATA_CONTROL_OPTIONS_INTERFACE_MOCK_H_ 20 | #define V4L2_CAMERA_HAL_METADATA_CONTROL_OPTIONS_INTERFACE_MOCK_H_ 21 | 22 | #include "control_options_interface.h" 23 | 24 | #include 25 | 26 | namespace v4l2_camera_hal { 27 | 28 | template 29 | class ControlOptionsInterfaceMock : public ControlOptionsInterface { 30 | public: 31 | ControlOptionsInterfaceMock(){}; 32 | MOCK_METHOD0_T(MetadataRepresentation, std::vector()); 33 | MOCK_METHOD1_T(IsSupported, bool(const T&)); 34 | MOCK_METHOD2_T(DefaultValueForTemplate, int(int, T*)); 35 | }; 36 | 37 | } // namespace v4l2_camera_hal 38 | 39 | #endif // V4L2_CAMERA_HAL_METADATA_CONTROL_OPTIONS_INTERFACE_MOCK_H_ 40 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/converter_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_CONVERTER_INTERFACE_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_CONVERTER_INTERFACE_H_ 19 | 20 | namespace v4l2_camera_hal { 21 | 22 | // A ConverterInterface converts metadata values to V4L2 values vice-versa. 23 | template 24 | class ConverterInterface { 25 | public: 26 | virtual ~ConverterInterface(){}; 27 | 28 | // Convert. 29 | virtual int MetadataToV4L2(TMetadata value, TV4L2* conversion) = 0; 30 | virtual int V4L2ToMetadata(TV4L2 value, TMetadata* conversion) = 0; 31 | }; 32 | 33 | } // namespace v4l2_camera_hal 34 | 35 | #endif // V4L2_CAMERA_HAL_METADATA_CONVERTER_INTERFACE_H_ 36 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/converter_interface_mock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Mock for converter interfaces. 18 | 19 | #ifndef V4L2_CAMERA_HAL_METADATA_CONVERTER_INTERFACE_MOCK_H_ 20 | #define V4L2_CAMERA_HAL_METADATA_CONVERTER_INTERFACE_MOCK_H_ 21 | 22 | #include "converter_interface.h" 23 | 24 | #include 25 | 26 | namespace v4l2_camera_hal { 27 | 28 | template 29 | class ConverterInterfaceMock : public ConverterInterface { 30 | public: 31 | ConverterInterfaceMock(){}; 32 | MOCK_METHOD2_T(MetadataToV4L2, int(TMetadata, TV4L2*)); 33 | MOCK_METHOD2_T(V4L2ToMetadata, int(TV4L2, TMetadata*)); 34 | }; 35 | 36 | } // namespace v4l2_camera_hal 37 | 38 | #endif // V4L2_CAMERA_HAL_METADATA_CONVERTER_INTERFACE_MOCK_H_ 39 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/default_option_delegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_DEFAULT_OPTION_DELEGATE_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_DEFAULT_OPTION_DELEGATE_H_ 19 | 20 | #include 21 | 22 | #include 23 | 24 | namespace v4l2_camera_hal { 25 | 26 | // A constant that can be used to identify an overall default. 27 | static constexpr int OTHER_TEMPLATES = CAMERA3_TEMPLATE_COUNT; 28 | 29 | // DefaultingOptionDelegate provides an interface to get default options from. 30 | template 31 | class DefaultOptionDelegate { 32 | public: 33 | // |defaults| maps template types to default values 34 | DefaultOptionDelegate(std::map defaults) 35 | : defaults_(std::move(defaults)){}; 36 | virtual ~DefaultOptionDelegate(){}; 37 | 38 | // Get a default value for a template type. Returns false if no default 39 | // provided. 40 | virtual bool DefaultValueForTemplate(int template_type, T* default_value) { 41 | if (defaults_.count(template_type) > 0) { 42 | // Best option is template-specific. 43 | *default_value = defaults_[template_type]; 44 | return true; 45 | } else if (defaults_.count(OTHER_TEMPLATES)) { 46 | // Fall back to a general default. 47 | *default_value = defaults_[OTHER_TEMPLATES]; 48 | return true; 49 | } 50 | 51 | return false; 52 | }; 53 | 54 | private: 55 | std::map defaults_; 56 | }; 57 | 58 | } // namespace v4l2_camera_hal 59 | 60 | #endif // V4L2_CAMERA_HAL_METADATA_DEFAULT_OPTION_DELEGATE_H_ 61 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/default_option_delegate_mock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Mock for default option delegates. 18 | 19 | #ifndef V4L2_CAMERA_HAL_METADATA_DEFAULT_OPTION_DELEGATE_MOCK_H_ 20 | #define V4L2_CAMERA_HAL_METADATA_DEFAULT_OPTION_DELEGATE_MOCK_H_ 21 | 22 | #include "default_option_delegate.h" 23 | 24 | #include 25 | 26 | namespace v4l2_camera_hal { 27 | 28 | template 29 | class DefaultOptionDelegateMock : public DefaultOptionDelegate { 30 | public: 31 | DefaultOptionDelegateMock() : DefaultOptionDelegate({}){}; 32 | MOCK_METHOD2_T(DefaultValueForTemplate, bool(int, T*)); 33 | }; 34 | 35 | } // namespace v4l2_camera_hal 36 | 37 | #endif // V4L2_CAMERA_HAL_METADATA_DEFAULT_OPTION_DELEGATE_MOCK_H_ 38 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/default_option_delegate_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "default_option_delegate.h" 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | using testing::Test; 25 | 26 | namespace v4l2_camera_hal { 27 | 28 | class DefaultOptionDelegateTest : public Test { 29 | protected: 30 | virtual void SetUp() { 31 | dut_.reset(new DefaultOptionDelegate(defaults_)); 32 | } 33 | 34 | std::unique_ptr> dut_; 35 | std::map defaults_{{CAMERA3_TEMPLATE_STILL_CAPTURE, 10}, 36 | {OTHER_TEMPLATES, 20}, 37 | {CAMERA3_TEMPLATE_VIDEO_SNAPSHOT, 30}}; 38 | }; 39 | 40 | TEST_F(DefaultOptionDelegateTest, SpecificDefault) { 41 | int actual = 0; 42 | EXPECT_TRUE( 43 | dut_->DefaultValueForTemplate(CAMERA3_TEMPLATE_STILL_CAPTURE, &actual)); 44 | EXPECT_EQ(actual, defaults_[CAMERA3_TEMPLATE_STILL_CAPTURE]); 45 | } 46 | 47 | TEST_F(DefaultOptionDelegateTest, GeneralDefault) { 48 | int actual = 0; 49 | // No ZSL default; should fall back to the OTHER_TEMPLATES default. 50 | EXPECT_TRUE(dut_->DefaultValueForTemplate(CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG, 51 | &actual)); 52 | EXPECT_EQ(actual, defaults_[OTHER_TEMPLATES]); 53 | } 54 | 55 | TEST_F(DefaultOptionDelegateTest, NoDefaults) { 56 | dut_.reset(new DefaultOptionDelegate({})); 57 | int actual = 0; 58 | EXPECT_FALSE(dut_->DefaultValueForTemplate(CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG, 59 | &actual)); 60 | } 61 | 62 | } // namespace v4l2_camera_hal 63 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/enum_converter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | //#define LOG_NDEBUG 0 18 | #define LOG_TAG "EnumConverter" 19 | 20 | #include "enum_converter.h" 21 | 22 | #include 23 | 24 | #include "common.h" 25 | 26 | namespace v4l2_camera_hal { 27 | 28 | EnumConverter::EnumConverter( 29 | const std::multimap& v4l2_to_metadata) 30 | : v4l2_to_metadata_(v4l2_to_metadata) { 31 | HAL_LOG_ENTER(); 32 | } 33 | 34 | int EnumConverter::MetadataToV4L2(uint8_t value, int32_t* conversion) { 35 | // Unfortunately no bi-directional map lookup in C++. 36 | // Breaking on second, not first found so that a warning 37 | // can be given if there are multiple values. 38 | size_t count = 0; 39 | for (auto kv : v4l2_to_metadata_) { 40 | if (kv.second == value) { 41 | ++count; 42 | if (count == 1) { 43 | // First match. 44 | *conversion = kv.first; 45 | } else { 46 | // second match. 47 | break; 48 | } 49 | } 50 | } 51 | 52 | if (count == 0) { 53 | HAL_LOGV("Couldn't find V4L2 conversion of metadata value %d.", value); 54 | return -EINVAL; 55 | } else if (count > 1) { 56 | HAL_LOGV( 57 | "Multiple V4L2 conversions found for metadata value %d, using first.", 58 | value); 59 | } 60 | return 0; 61 | } 62 | 63 | int EnumConverter::V4L2ToMetadata(int32_t value, uint8_t* conversion) { 64 | auto element_range = v4l2_to_metadata_.equal_range(value); 65 | if (element_range.first == element_range.second) { 66 | HAL_LOGV("Couldn't find metadata conversion of V4L2 value %d.", value); 67 | return -EINVAL; 68 | } 69 | 70 | auto element = element_range.first; 71 | *conversion = element->second; 72 | 73 | if (++element != element_range.second) { 74 | HAL_LOGV( 75 | "Multiple metadata conversions found for V4L2 value %d, using first.", 76 | value); 77 | } 78 | return 0; 79 | } 80 | 81 | } // namespace v4l2_camera_hal 82 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/enum_converter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_ENUM_CONVERTER_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_ENUM_CONVERTER_H_ 19 | 20 | #include 21 | 22 | #include 23 | #include "converter_interface.h" 24 | 25 | namespace v4l2_camera_hal { 26 | 27 | // An EnumConverter converts between enum values. 28 | class EnumConverter : public ConverterInterface { 29 | public: 30 | EnumConverter(const std::multimap& v4l2_to_metadata); 31 | 32 | virtual int MetadataToV4L2(uint8_t value, int32_t* conversion) override; 33 | virtual int V4L2ToMetadata(int32_t value, uint8_t* conversion) override; 34 | 35 | private: 36 | const std::multimap v4l2_to_metadata_; 37 | 38 | DISALLOW_COPY_AND_ASSIGN(EnumConverter); 39 | }; 40 | 41 | } // namespace v4l2_camera_hal 42 | 43 | #endif // V4L2_CAMERA_HAL_METADATA_ENUM_CONVERTER_H_ 44 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/ignored_control_delegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_IGNORED_CONTROL_DELEGATE_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_IGNORED_CONTROL_DELEGATE_H_ 19 | 20 | #include "control_delegate_interface.h" 21 | 22 | namespace v4l2_camera_hal { 23 | 24 | // An IgnoredControlDelegate, as the name implies, 25 | // has a fixed value and ignores all requests to set it. 26 | template 27 | class IgnoredControlDelegate : public ControlDelegateInterface { 28 | public: 29 | IgnoredControlDelegate(T value) : value_(value){}; 30 | 31 | int GetValue(T* value) override { 32 | *value = value_; 33 | return 0; 34 | }; 35 | int SetValue(const T& /*value*/) override { return 0; }; 36 | 37 | private: 38 | const T value_; 39 | }; 40 | 41 | } // namespace v4l2_camera_hal 42 | 43 | #endif // V4L2_CAMERA_HAL_METADATA_IGNORED_CONTROL_DELEGATE_H_ 44 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/ignored_control_delegate_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "ignored_control_delegate.h" 18 | 19 | #include 20 | 21 | using testing::Test; 22 | 23 | namespace v4l2_camera_hal { 24 | 25 | TEST(IgnoredControlDelegateTest, DefaultGet) { 26 | int32_t value = 12; 27 | IgnoredControlDelegate control(value); 28 | int32_t actual = 0; 29 | ASSERT_EQ(control.GetValue(&actual), 0); 30 | EXPECT_EQ(actual, value); 31 | } 32 | 33 | TEST(IgnoredControlDelegateTest, GetAndSet) { 34 | int32_t value = 12; 35 | IgnoredControlDelegate control(value); 36 | int32_t new_value = 13; 37 | ASSERT_EQ(control.SetValue(new_value), 0); 38 | int32_t actual = 0; 39 | ASSERT_EQ(control.GetValue(&actual), 0); 40 | // Should still be the default. 41 | EXPECT_EQ(actual, value); 42 | } 43 | 44 | } // namespace v4l2_camera_hal 45 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/menu_control_options.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_MENU_CONTROL_OPTIONS_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_MENU_CONTROL_OPTIONS_H_ 19 | 20 | #include 21 | 22 | #include "common.h" 23 | #include "control_options_interface.h" 24 | #include "default_option_delegate.h" 25 | 26 | namespace v4l2_camera_hal { 27 | 28 | // MenuControlOptions offer a fixed list of acceptable values. 29 | template 30 | class MenuControlOptions : public ControlOptionsInterface { 31 | public: 32 | // |options| must be non-empty. 33 | MenuControlOptions(std::vector options, 34 | std::shared_ptr> defaults) 35 | : options_(options), defaults_(defaults){}; 36 | MenuControlOptions(std::vector options, std::map defaults) 37 | : options_(options), 38 | defaults_(std::make_shared>(defaults)){}; 39 | 40 | virtual std::vector MetadataRepresentation() override { return options_; }; 41 | virtual bool IsSupported(const T& option) override { 42 | return (std::find(options_.begin(), options_.end(), option) != 43 | options_.end()); 44 | }; 45 | virtual int DefaultValueForTemplate(int template_type, 46 | T* default_value) override { 47 | // Default to the first option. 48 | if (options_.empty()) { 49 | HAL_LOGE("Can't get default value, options are empty."); 50 | return -ENODEV; 51 | } 52 | 53 | // Try to get it from the defaults delegate. 54 | if (defaults_->DefaultValueForTemplate(template_type, default_value) && 55 | IsSupported(*default_value)) { 56 | return 0; 57 | } 58 | 59 | // Fall back to the first available. 60 | *default_value = options_[0]; 61 | return 0; 62 | }; 63 | 64 | private: 65 | std::vector options_; 66 | std::shared_ptr> defaults_; 67 | }; 68 | 69 | } // namespace v4l2_camera_hal 70 | 71 | #endif // V4L2_CAMERA_HAL_METADATA_MENU_CONTROL_OPTIONS_H_ 72 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/metadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include "metadata_common.h" 24 | 25 | namespace v4l2_camera_hal { 26 | class Metadata { 27 | public: 28 | Metadata(PartialMetadataSet components); 29 | virtual ~Metadata(); 30 | 31 | int FillStaticMetadata(android::CameraMetadata* metadata); 32 | bool IsValidRequest(const android::CameraMetadata& metadata); 33 | int GetRequestTemplate(int template_type, 34 | android::CameraMetadata* template_metadata); 35 | int SetRequestSettings(const android::CameraMetadata& metadata); 36 | int FillResultMetadata(android::CameraMetadata* metadata); 37 | 38 | private: 39 | // The overall metadata is broken down into several distinct pieces. 40 | // Note: it is undefined behavior if multiple components share tags. 41 | PartialMetadataSet components_; 42 | 43 | DISALLOW_COPY_AND_ASSIGN(Metadata); 44 | }; 45 | 46 | } // namespace v4l2_camera_hal 47 | 48 | #endif // V4L2_CAMERA_HAL_V4L2_METADATA_H_ 49 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/metadata_reader_mock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Mock for metadata readers. 18 | 19 | #ifndef DEFAULT_CAMERA_HAL_METADATA_METADATA_READER_MOCK_H_ 20 | #define DEFAULT_CAMERA_HAL_METADATA_METADATA_READER_MOCK_H_ 21 | 22 | #include "metadata_reader.h" 23 | 24 | #include 25 | 26 | namespace default_camera_hal { 27 | 28 | class MetadataReaderMock : public MetadataReader { 29 | public: 30 | MetadataReaderMock() : MetadataReader(nullptr){}; 31 | MOCK_CONST_METHOD0(raw_metadata, const camera_metadata_t*()); 32 | MOCK_CONST_METHOD1(Facing, int(int*)); 33 | MOCK_CONST_METHOD1(Orientation, int(int*)); 34 | MOCK_CONST_METHOD1(MaxInputStreams, int(int32_t*)); 35 | MOCK_CONST_METHOD3(MaxOutputStreams, int(int32_t*, int32_t*, int32_t*)); 36 | MOCK_CONST_METHOD1(RequestCapabilities, int(std::set*)); 37 | MOCK_CONST_METHOD1(StreamConfigurations, 38 | int(std::vector*)); 39 | MOCK_CONST_METHOD1(StreamStallDurations, 40 | int(std::vector*)); 41 | MOCK_CONST_METHOD1(ReprocessFormats, int(ReprocessFormatMap*)); 42 | }; 43 | 44 | } // namespace default_camera_hal 45 | 46 | #endif // DEFAULT_CAMERA_HAL_METADATA_METADATA_READER_MOCK_H_ 47 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/no_effect_control_delegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_NO_EFFECT_CONTROL_DELEGATE_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_NO_EFFECT_CONTROL_DELEGATE_H_ 19 | 20 | #include "control_delegate_interface.h" 21 | 22 | namespace v4l2_camera_hal { 23 | 24 | // A NoEffectControlDelegate, as the name implies, has no effect. 25 | // The value can be gotten and set, but it does nothing. 26 | template 27 | class NoEffectControlDelegate : public ControlDelegateInterface { 28 | public: 29 | NoEffectControlDelegate(T default_value) : value_(default_value){}; 30 | 31 | int GetValue(T* value) override { 32 | *value = value_; 33 | return 0; 34 | }; 35 | int SetValue(const T& value) override { 36 | value_ = value; 37 | return 0; 38 | }; 39 | 40 | private: 41 | T value_; 42 | }; 43 | 44 | } // namespace v4l2_camera_hal 45 | 46 | #endif // V4L2_CAMERA_HAL_METADATA_NO_EFFECT_CONTROL_DELEGATE_H_ 47 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/no_effect_control_delegate_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "no_effect_control_delegate.h" 18 | 19 | #include 20 | 21 | using testing::Test; 22 | 23 | namespace v4l2_camera_hal { 24 | 25 | TEST(NoEffectControlDelegateTest, DefaultGet) { 26 | int32_t value = 12; 27 | NoEffectControlDelegate control(value); 28 | int32_t actual = 0; 29 | ASSERT_EQ(control.GetValue(&actual), 0); 30 | EXPECT_EQ(actual, value); 31 | } 32 | 33 | TEST(NoEffectControlDelegateTest, GetAndSet) { 34 | int32_t value = 12; 35 | NoEffectControlDelegate control(value); 36 | int32_t new_value = 13; 37 | ASSERT_EQ(control.SetValue(new_value), 0); 38 | int32_t actual = 0; 39 | ASSERT_EQ(control.GetValue(&actual), 0); 40 | EXPECT_EQ(actual, new_value); 41 | } 42 | 43 | } // namespace v4l2_camera_hal 44 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/partial_metadata_interface_mock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Mock for partial metadata interfaces. 18 | 19 | #ifndef V4L2_CAMERA_HAL_PARTIAL_METADATA_INTERFACE_MOCK_H_ 20 | #define V4L2_CAMERA_HAL_PARTIAL_METADATA_INTERFACE_MOCK_H_ 21 | 22 | #include "partial_metadata_interface.h" 23 | 24 | #include 25 | 26 | namespace v4l2_camera_hal { 27 | 28 | class PartialMetadataInterfaceMock : public PartialMetadataInterface { 29 | public: 30 | PartialMetadataInterfaceMock() : PartialMetadataInterface(){}; 31 | MOCK_CONST_METHOD0(StaticTags, std::vector()); 32 | MOCK_CONST_METHOD0(ControlTags, std::vector()); 33 | MOCK_CONST_METHOD0(DynamicTags, std::vector()); 34 | MOCK_CONST_METHOD1(PopulateStaticFields, int(android::CameraMetadata*)); 35 | MOCK_CONST_METHOD1(PopulateDynamicFields, int(android::CameraMetadata*)); 36 | MOCK_CONST_METHOD2(PopulateTemplateRequest, 37 | int(int, android::CameraMetadata*)); 38 | MOCK_CONST_METHOD1(SupportsRequestValues, 39 | bool(const android::CameraMetadata&)); 40 | MOCK_METHOD1(SetRequestValues, int(const android::CameraMetadata&)); 41 | }; 42 | 43 | } // namespace v4l2_camera_hal 44 | 45 | #endif // V4L2_CAMERA_HAL_PARTIAL_METADATA_INTERFACE_MOCK_H_ 46 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/property.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_PROPERTY_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_PROPERTY_H_ 19 | 20 | #include "metadata_common.h" 21 | #include "partial_metadata_interface.h" 22 | 23 | namespace v4l2_camera_hal { 24 | 25 | // A Property is a PartialMetadata that only has a single static tag. 26 | template 27 | class Property : public PartialMetadataInterface { 28 | public: 29 | Property(int32_t tag, T value) : tag_(tag), value_(std::move(value)){}; 30 | 31 | virtual std::vector StaticTags() const override { return {tag_}; }; 32 | 33 | virtual std::vector ControlTags() const override { return {}; }; 34 | 35 | virtual std::vector DynamicTags() const override { return {}; }; 36 | 37 | virtual int PopulateStaticFields( 38 | android::CameraMetadata* metadata) const override { 39 | return UpdateMetadata(metadata, tag_, value_); 40 | }; 41 | 42 | virtual int PopulateDynamicFields( 43 | android::CameraMetadata* /*metadata*/) const override { 44 | return 0; 45 | }; 46 | 47 | virtual int PopulateTemplateRequest( 48 | int /*template_type*/, android::CameraMetadata* /*metadata*/) const override { 49 | return 0; 50 | }; 51 | 52 | virtual bool SupportsRequestValues( 53 | const android::CameraMetadata& /*metadata*/) const override { 54 | return true; 55 | }; 56 | 57 | virtual int SetRequestValues( 58 | const android::CameraMetadata& /*metadata*/) override { 59 | return 0; 60 | }; 61 | 62 | private: 63 | int32_t tag_; 64 | T value_; 65 | }; 66 | 67 | } // namespace v4l2_camera_hal 68 | 69 | #endif // V4L2_CAMERA_HAL_METADATA_PROPERTY_H_ 70 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/state_delegate_interface.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_STATE_DELEGATE_INTERFACE_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_STATE_DELEGATE_INTERFACE_H_ 19 | 20 | namespace v4l2_camera_hal { 21 | 22 | // A StateDelegate is simply a dynamic value that can be queried. 23 | // The value may change between queries. 24 | template 25 | class StateDelegateInterface { 26 | public: 27 | virtual ~StateDelegateInterface(){}; 28 | // Returns 0 on success, error code on failure. 29 | virtual int GetValue(T* value) = 0; 30 | }; 31 | 32 | } // namespace v4l2_camera_hal 33 | 34 | #endif // V4L2_CAMERA_HAL_METADATA_STATE_DELEGATE_INTERFACE_H_ 35 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/state_delegate_interface_mock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Mock for state delegate interfaces. 18 | 19 | #ifndef V4L2_CAMERA_HAL_METADATA_STATE_DELEGATE_INTERFACE_MOCK_H_ 20 | #define V4L2_CAMERA_HAL_METADATA_STATE_DELEGATE_INTERFACE_MOCK_H_ 21 | 22 | #include "state_delegate_interface.h" 23 | 24 | #include 25 | 26 | namespace v4l2_camera_hal { 27 | 28 | template 29 | class StateDelegateInterfaceMock : public StateDelegateInterface { 30 | public: 31 | StateDelegateInterfaceMock(){}; 32 | MOCK_METHOD1_T(GetValue, int(T*)); 33 | }; 34 | 35 | } // namespace v4l2_camera_hal 36 | 37 | #endif // V4L2_CAMERA_HAL_METADATA_CONTROL_DELEGATE_INTERFACE_MOCK_H_ 38 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/tagged_control_delegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_TAGGED_CONTROL_DELEGATE_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_TAGGED_CONTROL_DELEGATE_H_ 19 | 20 | #include 21 | 22 | #include "control_delegate_interface.h" 23 | 24 | namespace v4l2_camera_hal { 25 | 26 | // A TaggedControlDelegate wraps a ControlDelegate and adds a tag. 27 | template 28 | class TaggedControlDelegate : public ControlDelegateInterface { 29 | public: 30 | TaggedControlDelegate(int32_t tag, 31 | std::unique_ptr> delegate) 32 | : tag_(tag), delegate_(std::move(delegate)){}; 33 | 34 | int32_t tag() { return tag_; }; 35 | 36 | virtual int GetValue(T* value) override { 37 | return delegate_->GetValue(value); 38 | }; 39 | virtual int SetValue(const T& value) override { 40 | return delegate_->SetValue(value); 41 | }; 42 | 43 | private: 44 | const int32_t tag_; 45 | std::unique_ptr> delegate_; 46 | }; 47 | 48 | } // namespace v4l2_camera_hal 49 | 50 | #endif // V4L2_CAMERA_HAL_METADATA_CONTROL_DELEGATE_INTERFACE_H_ 51 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/tagged_control_options.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_TAGGED_CONTROL_OPTIONS_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_TAGGED_CONTROL_OPTIONS_H_ 19 | 20 | #include 21 | 22 | #include "control_options_interface.h" 23 | 24 | namespace v4l2_camera_hal { 25 | 26 | // A constant tag with a value not used as a real tag 27 | // (since all real tags are unsigned), to indicate options 28 | // that should not be reported. 29 | // Any class working with TaggedControlOptions should check 30 | // the tag against this value before using it. 31 | static int32_t DO_NOT_REPORT_OPTIONS = -1; 32 | 33 | // A TaggedControlOptions wraps a ControlOptions and adds a tag. 34 | template 35 | class TaggedControlOptions : public ControlOptionsInterface { 36 | public: 37 | TaggedControlOptions(int32_t tag, 38 | std::unique_ptr> options) 39 | : tag_(tag), options_(std::move(options)){}; 40 | 41 | int32_t tag() { return tag_; }; 42 | 43 | virtual std::vector MetadataRepresentation() override { 44 | return options_->MetadataRepresentation(); 45 | }; 46 | virtual bool IsSupported(const T& value) override { 47 | return options_->IsSupported(value); 48 | }; 49 | virtual int DefaultValueForTemplate(int template_type, 50 | T* default_value) override { 51 | return options_->DefaultValueForTemplate(template_type, default_value); 52 | } 53 | 54 | private: 55 | const int32_t tag_; 56 | std::unique_ptr> options_; 57 | }; 58 | 59 | } // namespace v4l2_camera_hal 60 | 61 | #endif // V4L2_CAMERA_HAL_METADATA_CONTROL_OPTIONS_INTERFACE_H_ 62 | -------------------------------------------------------------------------------- /modules/camera/3_4/metadata/v4l2_control_delegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_METADATA_V4L2_CONTROL_DELEGATE_H_ 18 | #define V4L2_CAMERA_HAL_METADATA_V4L2_CONTROL_DELEGATE_H_ 19 | 20 | #include "control_delegate_interface.h" 21 | #include "converter_interface.h" 22 | #include "v4l2_wrapper.h" 23 | 24 | namespace v4l2_camera_hal { 25 | 26 | // A V4L2ControlDelegate routes getting and setting through V4L2 27 | template 28 | class V4L2ControlDelegate : public ControlDelegateInterface { 29 | public: 30 | V4L2ControlDelegate( 31 | std::shared_ptr device, 32 | int control_id, 33 | std::shared_ptr> converter) 34 | : device_(std::move(device)), 35 | control_id_(control_id), 36 | converter_(std::move(converter)){}; 37 | 38 | int GetValue(TMetadata* value) override { 39 | TV4L2 v4l2_value; 40 | int res = device_->GetControl(control_id_, &v4l2_value); 41 | if (res) { 42 | HAL_LOGE("Failed to get device value for control %d.", control_id_); 43 | return res; 44 | } 45 | return converter_->V4L2ToMetadata(v4l2_value, value); 46 | }; 47 | 48 | int SetValue(const TMetadata& value) override { 49 | TV4L2 v4l2_value; 50 | int res = converter_->MetadataToV4L2(value, &v4l2_value); 51 | if (res) { 52 | HAL_LOGE("Failed to convert metadata value to V4L2."); 53 | return res; 54 | } 55 | return device_->SetControl(control_id_, v4l2_value); 56 | }; 57 | 58 | private: 59 | std::shared_ptr device_; 60 | int control_id_; 61 | std::shared_ptr> converter_; 62 | }; 63 | 64 | } // namespace v4l2_camera_hal 65 | 66 | #endif // V4L2_CAMERA_HAL_METADATA_V4L2_CONTROL_DELEGATE_H_ 67 | -------------------------------------------------------------------------------- /modules/camera/3_4/v4l2_camera_hal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Modified from hardware/libhardware/modules/camera/CameraHAL.h 18 | 19 | #ifndef V4L2_CAMERA_HAL_V4L2_CAMERA_HAL_H_ 20 | #define V4L2_CAMERA_HAL_V4L2_CAMERA_HAL_H_ 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #include "camera.h" 28 | #include "common.h" 29 | 30 | namespace v4l2_camera_hal { 31 | /* 32 | * V4L2CameraHAL contains all module state that isn't specific to an 33 | * individual camera device. This class is based off of the sample 34 | * default CameraHAL from /hardware/libhardware/modules/camera. 35 | */ 36 | class V4L2CameraHAL { 37 | public: 38 | V4L2CameraHAL(); 39 | ~V4L2CameraHAL(); 40 | 41 | // Camera Module Interface (see ). 42 | int getNumberOfCameras(); 43 | int getCameraInfo(int camera_id, camera_info_t* info); 44 | int setCallbacks(const camera_module_callbacks_t* callbacks); 45 | void getVendorTagOps(vendor_tag_ops_t* ops); 46 | int openLegacy(const hw_module_t* module, 47 | const char* id, 48 | uint32_t halVersion, 49 | hw_device_t** device); 50 | int setTorchMode(const char* camera_id, bool enabled); 51 | 52 | // Hardware Module Interface (see ). 53 | int openDevice(const hw_module_t* mod, const char* name, hw_device_t** dev); 54 | 55 | private: 56 | // Vector of cameras. 57 | std::vector> mCameras; 58 | // Callback handle. 59 | const camera_module_callbacks_t* mCallbacks; 60 | 61 | DISALLOW_COPY_AND_ASSIGN(V4L2CameraHAL); 62 | }; 63 | 64 | } // namespace v4l2_camera_hal 65 | 66 | extern camera_module_t HAL_MODULE_INFO_SYM; 67 | 68 | #endif // V4L2_CAMERA_HAL_V4L2_CAMERA_HAL_H_ 69 | -------------------------------------------------------------------------------- /modules/camera/3_4/v4l2_metadata_factory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef V4L2_CAMERA_HAL_V4L2_METADATA_FACTORY_H_ 18 | #define V4L2_CAMERA_HAL_V4L2_METADATA_FACTORY_H_ 19 | 20 | #include 21 | 22 | #include "metadata/metadata.h" 23 | #include "v4l2_wrapper.h" 24 | 25 | namespace v4l2_camera_hal { 26 | 27 | // A static function to get a Metadata object populated with V4L2 or other 28 | // controls as appropriate. 29 | int GetV4L2Metadata(std::shared_ptr device, 30 | std::unique_ptr* result); 31 | 32 | } // namespace v4l2_camera_hal 33 | 34 | #endif // V4L2_CAMERA_HAL_V4L2_METADATA_FACTORY_H_ 35 | -------------------------------------------------------------------------------- /modules/camera/3_4/v4l2_wrapper_mock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Mock for wrapper class used to communicate with V4L2 devices. 18 | 19 | #ifndef V4L2_CAMERA_HAL_V4L2_WRAPPER_MOCK_H_ 20 | #define V4L2_CAMERA_HAL_V4L2_WRAPPER_MOCK_H_ 21 | 22 | #include "v4l2_wrapper.h" 23 | 24 | #include 25 | 26 | namespace v4l2_camera_hal { 27 | 28 | class V4L2WrapperMock : public V4L2Wrapper { 29 | public: 30 | V4L2WrapperMock() : V4L2Wrapper(""){}; 31 | MOCK_METHOD0(StreamOn, int()); 32 | MOCK_METHOD0(StreamOff, int()); 33 | MOCK_METHOD2(QueryControl, 34 | int(uint32_t control_id, v4l2_query_ext_ctrl* result)); 35 | MOCK_METHOD2(GetControl, int(uint32_t control_id, int32_t* value)); 36 | MOCK_METHOD3(SetControl, 37 | int(uint32_t control_id, int32_t desired, int32_t* result)); 38 | MOCK_METHOD1(GetFormats, int(std::set*)); 39 | MOCK_METHOD1(GetQualifiedFormats, int(std::vector*)); 40 | MOCK_METHOD2(GetFormatFrameSizes, 41 | int(uint32_t, std::set>*)); 42 | MOCK_METHOD3(GetFormatFrameDurationRange, 43 | int(uint32_t, 44 | const std::array&, 45 | std::array*)); 46 | MOCK_METHOD2(SetFormat, int(const StreamFormat& desired_format, 47 | uint32_t* result_max_buffers)); 48 | MOCK_METHOD2(EnqueueBuffer, 49 | int(const camera3_stream_buffer_t* camera_buffer, 50 | uint32_t* enqueued_index)); 51 | MOCK_METHOD1(DequeueBuffer, int(uint32_t* dequeued_index)); 52 | }; 53 | 54 | } // namespace v4l2_camera_hal 55 | 56 | #endif // V4L2_CAMERA_HAL_V4L2_WRAPPER_MOCK_H_ 57 | -------------------------------------------------------------------------------- /modules/consumerir/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "consumerir.default", 26 | relative_install_path: "hw", 27 | proprietary: true, 28 | srcs: ["consumerir.c"], 29 | cflags: ["-Wall", "-Werror"], 30 | header_libs: ["libhardware_headers"], 31 | shared_libs: [ 32 | "liblog", 33 | ], 34 | } 35 | -------------------------------------------------------------------------------- /modules/fingerprint/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "fingerprint.default", 26 | relative_install_path: "hw", 27 | proprietary: true, 28 | srcs: ["fingerprint.c"], 29 | cflags: ["-Wall", "-Werror"], 30 | header_libs: ["libhardware_headers"], 31 | shared_libs: ["liblog"], 32 | } 33 | -------------------------------------------------------------------------------- /modules/gralloc/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // HAL module implementation stored in 16 | // hw/..so 17 | package { 18 | // See: http://go/android-license-faq 19 | default_applicable_licenses: [ 20 | "hardware_libhardware_license", 21 | ], 22 | } 23 | 24 | cc_library_shared { 25 | name: "gralloc.default", 26 | relative_install_path: "hw", 27 | proprietary: true, 28 | shared_libs: [ 29 | "liblog", 30 | "libcutils", 31 | ], 32 | srcs: [ 33 | "gralloc.cpp", 34 | "framebuffer.cpp", 35 | "mapper.cpp", 36 | ], 37 | header_libs: ["libhardware_headers"], 38 | cflags: [ 39 | "-DLOG_TAG=\"gralloc\"", 40 | "-Wno-missing-field-initializers", 41 | ] + select(soong_config_variable("gralloc", "target_use_pan_display"), { 42 | true: ["-DUSE_PAN_DISPLAY=1"], 43 | default: [], 44 | }), 45 | } 46 | -------------------------------------------------------------------------------- /modules/gralloc/gr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef GR_H_ 18 | #define GR_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | /*****************************************************************************/ 32 | 33 | struct private_module_t; 34 | struct private_handle_t; 35 | 36 | static const size_t kPageSize = getpagesize(); 37 | 38 | inline size_t roundUpToPageSize(size_t x) { 39 | return (x + (kPageSize-1)) & ~(kPageSize-1); 40 | } 41 | 42 | int mapFrameBufferLocked(struct private_module_t* module, int format); 43 | int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd); 44 | int mapBuffer(gralloc_module_t const* module, private_handle_t* hnd); 45 | 46 | /*****************************************************************************/ 47 | 48 | class Locker { 49 | pthread_mutex_t mutex; 50 | public: 51 | class Autolock { 52 | Locker& locker; 53 | public: 54 | inline explicit Autolock(Locker& locker) : locker(locker) { locker.lock(); } 55 | inline ~Autolock() { locker.unlock(); } 56 | }; 57 | inline Locker() { pthread_mutex_init(&mutex, 0); } 58 | inline ~Locker() { pthread_mutex_destroy(&mutex); } 59 | inline void lock() { pthread_mutex_lock(&mutex); } 60 | inline void unlock() { pthread_mutex_unlock(&mutex); } 61 | }; 62 | 63 | #endif /* GR_H_ */ 64 | -------------------------------------------------------------------------------- /modules/hwcomposer/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // HAL module implemenation stored in 16 | // hw/..so 17 | package { 18 | // See: http://go/android-license-faq 19 | // A large-scale-change added 'default_applicable_licenses' to import 20 | // all of the 'license_kinds' from "hardware_libhardware_license" 21 | // to get the below license kinds: 22 | // SPDX-license-identifier-Apache-2.0 23 | default_applicable_licenses: ["hardware_libhardware_license"], 24 | } 25 | 26 | cc_library_shared { 27 | name: "hwcomposer.default", 28 | relative_install_path: "hw", 29 | vendor: true, 30 | shared_libs: [ 31 | "liblog", 32 | "libEGL", 33 | ], 34 | srcs: ["hwcomposer.cpp"], 35 | header_libs: ["libhardware_headers"], 36 | cflags: [ 37 | "-DLOG_TAG=\"hwcomposer\"", 38 | "-Wall", 39 | "-Werror", 40 | ], 41 | } 42 | -------------------------------------------------------------------------------- /modules/hwcomposer/README.android: -------------------------------------------------------------------------------- 1 | 2 | Skeleton for the "hwcomposer" HAL module. 3 | 4 | -------------------------------------------------------------------------------- /modules/input/evdev/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Evdev module implementation 16 | package { 17 | // See: http://go/android-license-faq 18 | // A large-scale-change added 'default_applicable_licenses' to import 19 | // all of the 'license_kinds' from "hardware_libhardware_license" 20 | // to get the below license kinds: 21 | // SPDX-license-identifier-Apache-2.0 22 | default_applicable_licenses: ["hardware_libhardware_license"], 23 | } 24 | 25 | cc_library_shared { 26 | name: "libinput_evdev", 27 | 28 | srcs: [ 29 | "BitUtils.cpp", 30 | "InputHub.cpp", 31 | "InputDevice.cpp", 32 | "InputDeviceManager.cpp", 33 | "InputHost.cpp", 34 | "InputMapper.cpp", 35 | "MouseInputMapper.cpp", 36 | "SwitchInputMapper.cpp", 37 | ], 38 | 39 | header_libs: ["jni_headers"], 40 | shared_libs: [ 41 | "libhardware_legacy", 42 | "liblog", 43 | "libutils", 44 | ], 45 | 46 | export_include_dirs: ["."], 47 | 48 | cppflags: [ 49 | "-Wno-unused-parameter", 50 | ], 51 | } 52 | 53 | // HAL module 54 | cc_library_shared { 55 | name: "input.evdev.default", 56 | relative_install_path: "hw", 57 | 58 | srcs: ["EvdevModule.cpp"], 59 | 60 | shared_libs: [ 61 | "libinput_evdev", 62 | "liblog", 63 | ], 64 | 65 | cppflags: [ 66 | "-Wall", 67 | "-Werror", 68 | "-Wno-unused-parameter", 69 | ], 70 | } 71 | -------------------------------------------------------------------------------- /modules/input/evdev/BitUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "BitUtils" 18 | //#define LOG_NDEBUG 0 19 | 20 | #include "BitUtils.h" 21 | 22 | #include 23 | 24 | // Enables debug output for hasKeyInRange 25 | #define DEBUG_KEY_RANGE 0 26 | 27 | namespace android { 28 | 29 | #if DEBUG_KEY_RANGE 30 | static const char* bitstrings[16] = { 31 | "0000", "0001", "0010", "0011", 32 | "0100", "0101", "0110", "0111", 33 | "1000", "1001", "1010", "1011", 34 | "1100", "1101", "1110", "1111", 35 | }; 36 | #endif 37 | 38 | bool testBitInRange(const uint8_t arr[], size_t start, size_t end) { 39 | #if DEBUG_KEY_RANGE 40 | ALOGD("testBitInRange(%d, %d)", start, end); 41 | #endif 42 | // Invalid range! This is nonsense; just say no. 43 | if (end <= start) return false; 44 | 45 | // Find byte array indices. The end is not included in the range, nor is 46 | // endIndex. Round up for endIndex. 47 | size_t startIndex = start / 8; 48 | size_t endIndex = (end + 7) / 8; 49 | #if DEBUG_KEY_RANGE 50 | ALOGD("startIndex=%d, endIndex=%d", startIndex, endIndex); 51 | #endif 52 | for (size_t i = startIndex; i < endIndex; ++i) { 53 | uint8_t bits = arr[i]; 54 | uint8_t mask = 0xff; 55 | #if DEBUG_KEY_RANGE 56 | ALOGD("block %04d: %s%s", i, bitstrings[bits >> 4], bitstrings[bits & 0x0f]); 57 | #endif 58 | if (bits) { 59 | // Mask off bits before our start bit 60 | if (i == startIndex) { 61 | mask &= 0xff << (start % 8); 62 | } 63 | // Mask off bits after our end bit 64 | if (i == endIndex - 1 && (end % 8)) { 65 | mask &= 0xff >> (8 - (end % 8)); 66 | } 67 | #if DEBUG_KEY_RANGE 68 | ALOGD("mask: %s%s", bitstrings[mask >> 4], bitstrings[mask & 0x0f]); 69 | #endif 70 | // Test the index against the mask 71 | if (bits & mask) return true; 72 | } 73 | } 74 | return false; 75 | } 76 | } // namespace android 77 | -------------------------------------------------------------------------------- /modules/input/evdev/BitUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_BIT_UTILS_H_ 18 | #define ANDROID_BIT_UTILS_H_ 19 | 20 | #include 21 | 22 | namespace android { 23 | 24 | /** Test whether any bits in the interval [start, end) are set in the array. */ 25 | bool testBitInRange(const uint8_t arr[], size_t start, size_t end); 26 | 27 | } // namespace android 28 | 29 | #endif // ANDROID_BIT_UTILS_H_ 30 | -------------------------------------------------------------------------------- /modules/input/evdev/InputDeviceManager.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define LOG_TAG "InputDeviceManager" 18 | //#define LOG_NDEBUG 0 19 | 20 | #include "InputDeviceManager.h" 21 | 22 | #include 23 | 24 | #include "InputDevice.h" 25 | 26 | namespace android { 27 | 28 | void InputDeviceManager::onInputEvent(const std::shared_ptr& node, InputEvent& event, 29 | nsecs_t event_time) { 30 | if (mDevices[node] == nullptr) { 31 | ALOGE("got input event for unknown node %s", node->getPath().c_str()); 32 | return; 33 | } 34 | mDevices[node]->processInput(event, event_time); 35 | } 36 | 37 | void InputDeviceManager::onDeviceAdded(const std::shared_ptr& node) { 38 | mDevices[node] = std::make_shared(mHost, node); 39 | } 40 | 41 | void InputDeviceManager::onDeviceRemoved(const std::shared_ptr& node) { 42 | if (mDevices[node] == nullptr) { 43 | ALOGE("could not remove unknown node %s", node->getPath().c_str()); 44 | return; 45 | } 46 | // TODO: tell the InputDevice and InputDeviceNode that they are being 47 | // removed so they can run any cleanup, including unregistering from the 48 | // host. 49 | mDevices.erase(node); 50 | } 51 | 52 | } // namespace android 53 | -------------------------------------------------------------------------------- /modules/input/evdev/InputDeviceManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_INPUT_DEVICE_MANAGER_H_ 18 | #define ANDROID_INPUT_DEVICE_MANAGER_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "InputHub.h" 26 | 27 | namespace android { 28 | 29 | class InputDeviceInterface; 30 | class InputHostInterface; 31 | 32 | /** 33 | * InputDeviceManager keeps the mapping of InputDeviceNodes to 34 | * InputDeviceInterfaces and handles the callbacks from the InputHub, delegating 35 | * them to the appropriate InputDeviceInterface. 36 | */ 37 | class InputDeviceManager : public InputCallbackInterface { 38 | public: 39 | explicit InputDeviceManager(InputHostInterface* host) : 40 | mHost(host) {} 41 | virtual ~InputDeviceManager() override = default; 42 | 43 | virtual void onInputEvent(const std::shared_ptr& node, InputEvent& event, 44 | nsecs_t event_time) override; 45 | virtual void onDeviceAdded(const std::shared_ptr& node) override; 46 | virtual void onDeviceRemoved(const std::shared_ptr& node) override; 47 | 48 | private: 49 | InputHostInterface* mHost; 50 | 51 | template 52 | using DeviceMap = std::unordered_map, std::shared_ptr>; 53 | 54 | DeviceMap mDevices; 55 | }; 56 | 57 | } // namespace android 58 | 59 | #endif // ANDROID_INPUT_DEVICE_MANAGER_H_ 60 | -------------------------------------------------------------------------------- /modules/input/evdev/InputMapper.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "InputMapper.h" 18 | 19 | #include "InputHost.h" 20 | 21 | namespace android { 22 | 23 | InputReport* InputMapper::getInputReport() { 24 | if (mReport) return mReport; 25 | if (mInputReportDef == nullptr) return nullptr; 26 | mReport = mInputReportDef->allocateReport(); 27 | return mReport; 28 | } 29 | 30 | } // namespace android 31 | -------------------------------------------------------------------------------- /modules/input/evdev/MouseInputMapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_MOUSE_INPUT_MAPPER_H_ 18 | #define ANDROID_MOUSE_INPUT_MAPPER_H_ 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include "InputMapper.h" 26 | 27 | namespace android { 28 | 29 | class MouseInputMapper : public InputMapper { 30 | public: 31 | virtual ~MouseInputMapper() = default; 32 | 33 | virtual bool configureInputReport(InputDeviceNode* devNode, 34 | InputReportDefinition* report) override; 35 | virtual void process(const InputEvent& event) override; 36 | 37 | private: 38 | void processMotion(int32_t code, int32_t value); 39 | void processButton(int32_t code, int32_t value); 40 | void sync(nsecs_t when); 41 | 42 | BitSet32 mButtonValues; 43 | BitSet32 mUpdatedButtonMask; 44 | 45 | int32_t mRelX = 0; 46 | int32_t mRelY = 0; 47 | 48 | int32_t mRelWheel = 0; 49 | int32_t mRelHWheel = 0; 50 | }; 51 | 52 | } // namespace android 53 | 54 | #endif // ANDROID_MOUSE_INPUT_MAPPER_H_ 55 | -------------------------------------------------------------------------------- /modules/input/evdev/SwitchInputMapper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SWITCH_INPUT_MAPPER_H_ 18 | #define ANDROID_SWITCH_INPUT_MAPPER_H_ 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include "InputMapper.h" 26 | 27 | namespace android { 28 | 29 | class SwitchInputMapper : public InputMapper { 30 | public: 31 | SwitchInputMapper(); 32 | virtual ~SwitchInputMapper() = default; 33 | 34 | virtual bool configureInputReport(InputDeviceNode* devNode, 35 | InputReportDefinition* report) override; 36 | virtual void process(const InputEvent& event) override; 37 | 38 | private: 39 | void processSwitch(int32_t switchCode, int32_t switchValue); 40 | void sync(nsecs_t when); 41 | 42 | BitSet64 mSwitchValues; 43 | BitSet64 mUpdatedSwitchMask; 44 | }; 45 | 46 | } // namespace android 47 | 48 | #endif // ANDROID_SWITCH_INPUT_MAPPER_H_ 49 | -------------------------------------------------------------------------------- /modules/local_time/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // The default local time HAL module. The default module simply uses the 16 | // system's clock_gettime(CLOCK_MONOTONIC) and does not support HW slewing. 17 | // Devices which use the default implementation should take care to ensure that 18 | // the oscillator backing the CLOCK_MONOTONIC implementation is phase locked to 19 | // the audio and video output hardware. This default implementation is loaded 20 | // if no other device specific modules are present. The exact load order can be 21 | // seen in libhardware/hardware.c 22 | // 23 | // The format of the name is local_time..so 24 | package { 25 | // See: http://go/android-license-faq 26 | // A large-scale-change added 'default_applicable_licenses' to import 27 | // all of the 'license_kinds' from "hardware_libhardware_license" 28 | // to get the below license kinds: 29 | // SPDX-license-identifier-Apache-2.0 30 | default_applicable_licenses: ["hardware_libhardware_license"], 31 | } 32 | 33 | cc_library_shared { 34 | name: "local_time.default", 35 | relative_install_path: "hw", 36 | proprietary: true, 37 | srcs: ["local_time_hw.c"], 38 | cflags: ["-Wall", "-Werror"], 39 | header_libs: ["libhardware_headers"], 40 | shared_libs: [ 41 | "liblog", 42 | "libcutils", 43 | ], 44 | } 45 | -------------------------------------------------------------------------------- /modules/nfc-nci/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "nfc_nci.default", 26 | relative_install_path: "hw", 27 | proprietary: true, 28 | srcs: ["nfc_nci_example.cpp"], 29 | header_libs: ["libhardware_headers"], 30 | shared_libs: [ 31 | "liblog", 32 | "libcutils", 33 | ], 34 | cflags: ["-Wall", "-Werror"], 35 | } 36 | -------------------------------------------------------------------------------- /modules/nfc/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "nfc.default", 26 | relative_install_path: "hw", 27 | proprietary: true, 28 | srcs: ["nfc_pn544_example.c"], 29 | cflags: ["-Wall", "-Werror"], 30 | header_libs: ["libhardware_headers"], 31 | shared_libs: [ 32 | "liblog", 33 | ], 34 | } 35 | -------------------------------------------------------------------------------- /modules/nfc/nfc_pn544_example.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | /* Close an opened pn544 device instance */ 24 | static int pn544_close(hw_device_t *dev) { 25 | free(dev); 26 | return 0; 27 | } 28 | 29 | /* 30 | * Generic device handling 31 | */ 32 | static int nfc_open(const hw_module_t* module, const char* name, 33 | hw_device_t** device) { 34 | if (strcmp(name, NFC_PN544_CONTROLLER) == 0) { 35 | nfc_pn544_device_t *dev = calloc(1, sizeof(nfc_pn544_device_t)); 36 | 37 | dev->common.tag = HARDWARE_DEVICE_TAG; 38 | dev->common.version = 0; 39 | dev->common.module = (struct hw_module_t*) module; 40 | dev->common.close = pn544_close; 41 | 42 | /* Example settings */ 43 | dev->num_eeprom_settings = 0; 44 | dev->eeprom_settings = NULL; 45 | dev->linktype = PN544_LINK_TYPE_INVALID; 46 | dev->device_node = NULL; 47 | dev->enable_i2c_workaround = 0; 48 | dev->i2c_device_address = 0; 49 | 50 | *device = (hw_device_t*) dev; 51 | return 0; 52 | } else { 53 | return -EINVAL; 54 | } 55 | } 56 | 57 | 58 | static struct hw_module_methods_t nfc_module_methods = { 59 | .open = nfc_open, 60 | }; 61 | 62 | struct nfc_module_t HAL_MODULE_INFO_SYM = { 63 | .common = { 64 | .tag = HARDWARE_MODULE_TAG, 65 | .version_major = 1, 66 | .version_minor = 0, 67 | .id = NFC_HARDWARE_MODULE_ID, 68 | .name = "Default NFC HW HAL", 69 | .author = "The Android Open Source Project", 70 | .methods = &nfc_module_methods, 71 | }, 72 | }; 73 | -------------------------------------------------------------------------------- /modules/power/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "power.default", 26 | relative_install_path: "hw", 27 | proprietary: true, 28 | srcs: ["power.c"], 29 | cflags: ["-Wall", "-Werror"], 30 | header_libs: [ 31 | "libhardware_headers", 32 | "libutils_headers", 33 | ], 34 | shared_libs: ["liblog"], 35 | } 36 | -------------------------------------------------------------------------------- /modules/power/power.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #define LOG_TAG "Legacy PowerHAL" 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | // We only support clang and g++. 29 | #define UNUSED_ARGUMENT __attribute((unused)) 30 | 31 | static void power_init(struct power_module *module UNUSED_ARGUMENT) 32 | { 33 | } 34 | 35 | static void power_set_interactive(struct power_module *module UNUSED_ARGUMENT, 36 | int on UNUSED_ARGUMENT) 37 | { 38 | } 39 | 40 | static void power_hint(struct power_module *module UNUSED_ARGUMENT, 41 | power_hint_t hint, 42 | void *data UNUSED_ARGUMENT) { 43 | switch (hint) { 44 | default: 45 | break; 46 | } 47 | } 48 | 49 | static struct hw_module_methods_t power_module_methods = { 50 | .open = NULL, 51 | }; 52 | 53 | struct power_module HAL_MODULE_INFO_SYM = { 54 | .common = { 55 | .tag = HARDWARE_MODULE_TAG, 56 | .module_api_version = POWER_MODULE_API_VERSION_0_2, 57 | .hal_api_version = HARDWARE_HAL_API_VERSION, 58 | .id = POWER_HARDWARE_MODULE_ID, 59 | .name = "Default Power HAL", 60 | .author = "The Android Open Source Project", 61 | .methods = &power_module_methods, 62 | }, 63 | 64 | .init = power_init, 65 | .setInteractive = power_set_interactive, 66 | .powerHint = power_hint, 67 | }; 68 | -------------------------------------------------------------------------------- /modules/radio/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2017 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Stub radio HAL module, used for tests 16 | package { 17 | // See: http://go/android-license-faq 18 | // A large-scale-change added 'default_applicable_licenses' to import 19 | // all of the 'license_kinds' from "hardware_libhardware_license" 20 | // to get the below license kinds: 21 | // SPDX-license-identifier-Apache-2.0 22 | default_applicable_licenses: ["hardware_libhardware_license"], 23 | } 24 | 25 | cc_library_shared { 26 | name: "radio.fm.default", 27 | relative_install_path: "hw", 28 | vendor: true, 29 | srcs: ["radio_hw.c"], 30 | cflags: [ 31 | "-Wall", 32 | "-Wno-unused-parameter", 33 | "-Werror", 34 | ], 35 | header_libs: ["libhardware_headers"], 36 | shared_libs: [ 37 | "liblog", 38 | "libcutils", 39 | "libradio_metadata", 40 | ], 41 | } 42 | 43 | // Stub radio tool that can be run in native. 44 | cc_binary { 45 | name: "radio_hal_tool", 46 | vendor: true, 47 | srcs: ["radio_hal_tool.c"], 48 | cflags: [ 49 | "-Wall", 50 | "-Wno-unused-parameter", 51 | "-Werror", 52 | ], 53 | shared_libs: [ 54 | "libcutils", 55 | "libhardware", 56 | "liblog", 57 | "libradio_metadata", 58 | ], 59 | } 60 | -------------------------------------------------------------------------------- /modules/sensors/Android.bp: -------------------------------------------------------------------------------- 1 | package { 2 | // See: http://go/android-license-faq 3 | // A large-scale-change added 'default_applicable_licenses' to import 4 | // all of the 'license_kinds' from "hardware_libhardware_license" 5 | // to get the below license kinds: 6 | // SPDX-license-identifier-Apache-2.0 7 | default_applicable_licenses: ["hardware_libhardware_license"], 8 | } 9 | 10 | cc_library_static { 11 | name: "multihal", 12 | vendor: true, 13 | srcs: [ 14 | "multihal.cpp", 15 | "SensorEventQueue.cpp", 16 | ], 17 | header_libs: [ 18 | "libhardware_headers", 19 | ], 20 | shared_libs: [ 21 | "liblog", 22 | "libcutils", 23 | "libutils", 24 | "libdl", 25 | ], 26 | export_include_dirs: ["."], 27 | cflags: [ 28 | "-Wall", 29 | "-Werror", 30 | ], 31 | } 32 | 33 | cc_test_host { 34 | name: "sensorstests", 35 | gtest: false, 36 | srcs: [ 37 | "SensorEventQueue.cpp", 38 | "tests/SensorEventQueue_test.cpp", 39 | ], 40 | static_libs: [ 41 | "libcutils", 42 | "libutils", 43 | ], 44 | cflags: [ 45 | "-Wall", 46 | "-Werror", 47 | ], 48 | } 49 | -------------------------------------------------------------------------------- /modules/sensors/OWNERS: -------------------------------------------------------------------------------- 1 | bduddie@google.com 2 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/BaseDynamicSensorDaemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SENSORHAL_EXT_BASE_DYNAMIC_SENSOR_DAEMON_H 18 | #define ANDROID_SENSORHAL_EXT_BASE_DYNAMIC_SENSOR_DAEMON_H 19 | 20 | #include "BaseSensorObject.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace android { 27 | namespace SensorHalExt { 28 | 29 | class DynamicSensorManager; 30 | 31 | typedef std::vector> BaseSensorVector; 32 | 33 | class BaseDynamicSensorDaemon : public RefBase { 34 | public: 35 | BaseDynamicSensorDaemon(DynamicSensorManager& manager) : mManager(manager) {} 36 | virtual ~BaseDynamicSensorDaemon() = default; 37 | 38 | virtual bool onConnectionChange(const std::string &deviceKey, bool connected); 39 | protected: 40 | virtual BaseSensorVector createSensor(const std::string &deviceKey) = 0; 41 | virtual void removeSensor(const std::string &/*deviceKey*/) {}; 42 | 43 | DynamicSensorManager &mManager; 44 | std::unordered_map mDeviceKeySensorMap; 45 | }; 46 | 47 | } // namespace SensorHalExt 48 | } // namespace android 49 | 50 | #endif // ANDROID_SENSORHAL_EXT_BASE_DYNAMIC_SENSOR_DAEMON_H 51 | 52 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/BaseSensorObject.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "BaseSensorObject.h" 18 | #include "SensorEventCallback.h" 19 | #include "Utils.h" 20 | 21 | #include 22 | 23 | namespace android { 24 | namespace SensorHalExt { 25 | 26 | BaseSensorObject::BaseSensorObject() : mCallback(nullptr) { 27 | } 28 | 29 | bool BaseSensorObject::setEventCallback(SensorEventCallback* callback) { 30 | if (mCallback != nullptr) { 31 | return false; 32 | } 33 | mCallback = callback; 34 | return true; 35 | } 36 | 37 | void BaseSensorObject::getUuid(uint8_t* uuid) const { 38 | // default uuid denoting uuid feature is not supported on this sensor. 39 | memset(uuid, 0, 16); 40 | } 41 | 42 | int BaseSensorObject::flush() { 43 | static const sensors_event_t event = { 44 | .type = SENSOR_TYPE_META_DATA, 45 | .meta_data.what = META_DATA_FLUSH_COMPLETE, 46 | .timestamp = TIMESTAMP_AUTO_FILL // timestamp will be filled at dispatcher 47 | }; 48 | generateEvent(event); 49 | return 0; 50 | } 51 | 52 | void BaseSensorObject::generateEvent(const sensors_event_t &e) { 53 | if (mCallback) { 54 | mCallback->submitEvent(SP_THIS, e); 55 | } 56 | } 57 | 58 | } // namespace SensorHalExt 59 | } // namespace android 60 | 61 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/BaseSensorObject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SENSORHAL_BASE_SENSOR_OBJECT_H 18 | #define ANDROID_SENSORHAL_BASE_SENSOR_OBJECT_H 19 | 20 | #include "Utils.h" 21 | #include 22 | 23 | struct sensor_t; 24 | struct sensors_event_t; 25 | 26 | namespace android { 27 | namespace SensorHalExt { 28 | 29 | class SensorEventCallback; 30 | 31 | class BaseSensorObject : virtual public REF_BASE(BaseSensorObject) { 32 | public: 33 | BaseSensorObject(); 34 | virtual ~BaseSensorObject() = default; 35 | 36 | // always called by DynamicSensorManager, callback must point to 37 | // valid object throughout life cycle of BaseSensorObject 38 | bool setEventCallback(SensorEventCallback* callback); 39 | 40 | // virtual functions to get sensor information and operate sensor 41 | virtual const sensor_t* getSensor() const = 0; 42 | 43 | // get uuid of sensor, default implementation set it to all zero, means does not have a uuid. 44 | virtual void getUuid(uint8_t* uuid) const; 45 | 46 | // enable sensor 47 | virtual int enable(bool enable) = 0; 48 | 49 | // set sample period and batching period of sensor. 50 | // both sample period and batch period are in nano-seconds. 51 | virtual int batch(int64_t samplePeriod, int64_t batchPeriod) = 0; 52 | 53 | // flush sensor, default implementation will send a flush complete event back. 54 | virtual int flush(); 55 | 56 | protected: 57 | // utility function for sub-class 58 | void generateEvent(const sensors_event_t &e); 59 | private: 60 | SensorEventCallback* mCallback; 61 | }; 62 | 63 | } // namespace SensorHalExt 64 | } // namespace android 65 | 66 | #endif // ANDROID_SENSORHAL_BASE_SENSOR_OBJECT_H 67 | 68 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/DummyDynamicAccelDaemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SENSORHAL_EXT_DUMMY_DYNAMIC_ACCEL_DAEMON_H 18 | #define ANDROID_SENSORHAL_EXT_DUMMY_DYNAMIC_ACCEL_DAEMON_H 19 | 20 | #include "BaseDynamicSensorDaemon.h" 21 | #include "BaseSensorObject.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace android { 29 | namespace SensorHalExt { 30 | 31 | class ConnectionDetector; 32 | 33 | /** 34 | * This daemon simulates dynamic sensor connection without the need of actually connect peripheral 35 | * to Android. It is for debugging and testing. It can handle one concurrent connections at maximum. 36 | */ 37 | class DummyDynamicAccelDaemon : public BaseDynamicSensorDaemon { 38 | public: 39 | DummyDynamicAccelDaemon(DynamicSensorManager& manager); 40 | virtual ~DummyDynamicAccelDaemon() = default; 41 | private: 42 | class DummySensor : public BaseSensorObject, public Thread { 43 | public: 44 | DummySensor(const std::string &name); 45 | ~DummySensor(); 46 | virtual const sensor_t* getSensor() const; 47 | virtual void getUuid(uint8_t* uuid) const; 48 | virtual int enable(bool enable); 49 | virtual int batch(nsecs_t sample_period, nsecs_t batch_period); 50 | private: 51 | // implement Thread function 52 | virtual bool threadLoop() override; 53 | 54 | void waitUntilNextSample(); 55 | 56 | sensor_t mSensor; 57 | std::string mSensorName; 58 | 59 | std::mutex mLock; 60 | std::mutex mRunLock; 61 | bool mRunState; 62 | }; 63 | // implement BaseDynamicSensorDaemon function 64 | virtual BaseSensorVector createSensor(const std::string &deviceKey) override; 65 | 66 | sp mFileDetector; 67 | sp mSocketDetector; 68 | }; 69 | } // namespace SensorHalExt 70 | } // namespace android 71 | 72 | #endif // ANDROID_SENSORHAL_EXT_DYNAMIC_SENSOR_DAEMON_H 73 | 74 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SENSORHAL_EXT_HID_DEVICE_H 18 | #define ANDROID_SENSORHAL_EXT_HID_DEVICE_H 19 | #include "Utils.h" 20 | #include 21 | #include 22 | #include 23 | 24 | namespace android { 25 | namespace SensorHalExt { 26 | 27 | class HidDevice : virtual public REF_BASE(HidDevice) { 28 | public: 29 | virtual ~HidDevice() = default; 30 | 31 | struct HidDeviceInfo { 32 | std::string name; 33 | std::string physicalPath; 34 | std::string busType; 35 | uint16_t vendorId; 36 | uint16_t productId; 37 | std::vector descriptor; 38 | }; 39 | 40 | virtual const HidDeviceInfo& getDeviceInfo() = 0; 41 | 42 | // get feature from device 43 | virtual bool getFeature(uint8_t id, std::vector *out) = 0; 44 | 45 | // write feature to device 46 | virtual bool setFeature(uint8_t id, const std::vector &in) = 0; 47 | 48 | // send report to default output endpoint 49 | virtual bool sendReport(uint8_t id, std::vector &data) = 0; 50 | 51 | // receive from default input endpoint 52 | virtual bool receiveReport(uint8_t *id, std::vector *data) = 0; 53 | }; 54 | 55 | } // namespace SensorHalExt 56 | } // namespace android 57 | #endif // ANDROID_SENSORHAL_EXT_HID_DEVICE_H 58 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidRawSensorDaemon.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include "HidRawSensorDaemon.h" 17 | #include "ConnectionDetector.h" 18 | #include "DynamicSensorManager.h" 19 | #include "HidRawSensorDevice.h" 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #define DEV_PATH "/dev/" 33 | #define DEV_NAME_REGEX "^hidraw[0-9]+$" 34 | 35 | namespace android { 36 | namespace SensorHalExt { 37 | 38 | HidRawSensorDaemon::HidRawSensorDaemon(DynamicSensorManager& manager) 39 | : BaseDynamicSensorDaemon(manager) { 40 | mDetector = new FileConnectionDetector( 41 | this, std::string(DEV_PATH), std::string(DEV_NAME_REGEX)); 42 | mDetector->Init(); 43 | } 44 | 45 | BaseSensorVector HidRawSensorDaemon::createSensor(const std::string &deviceKey) { 46 | BaseSensorVector ret; 47 | sp device(HidRawSensorDevice::create(deviceKey)); 48 | 49 | if (device != nullptr) { 50 | ALOGV("created HidRawSensorDevice(%p) successfully on device %s contains %zu sensors", 51 | device.get(), deviceKey.c_str(), device->getSensors().size()); 52 | 53 | // convert type 54 | for (auto &i : device->getSensors()) { 55 | ret.push_back(i); 56 | } 57 | mHidRawSensorDevices.emplace(deviceKey, device); 58 | } else { 59 | ALOGE("failed to create HidRawSensorDevice object"); 60 | } 61 | 62 | ALOGI("return %zu sensors", ret.size()); 63 | return ret; 64 | } 65 | 66 | void HidRawSensorDaemon::removeSensor(const std::string &deviceKey) { 67 | mHidRawSensorDevices.erase(deviceKey); 68 | } 69 | 70 | } // namespace SensorHalExt 71 | } // namespace android 72 | 73 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidRawSensorDaemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SENSORHAL_EXT_HIDRAW_SENSOR_DAEMON_H 18 | #define ANDROID_SENSORHAL_EXT_HIDRAW_SENSOR_DAEMON_H 19 | 20 | #include "BaseDynamicSensorDaemon.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | 33 | using HidUtil::HidParser; 34 | using HidUtil::HidReport; 35 | using HidUtil::HidItem; 36 | 37 | namespace android { 38 | namespace SensorHalExt { 39 | 40 | class HidRawSensorDevice; 41 | class ConnectionDetector; 42 | 43 | class HidRawSensorDaemon : public BaseDynamicSensorDaemon { 44 | friend class HidRawSensorDaemonTest; 45 | public: 46 | HidRawSensorDaemon(DynamicSensorManager& manager); 47 | virtual ~HidRawSensorDaemon() = default; 48 | private: 49 | virtual BaseSensorVector createSensor(const std::string &deviceKey); 50 | virtual void removeSensor(const std::string &deviceKey); 51 | 52 | class HidRawSensor; 53 | void registerExisting(); 54 | 55 | sp mDetector; 56 | std::unordered_map> mHidRawSensorDevices; 57 | }; 58 | 59 | } // namespace SensorHalExt 60 | } // namespace android 61 | 62 | #endif // ANDROID_SENSORHAL_EXT_HIDRAW_SENSOR_DAEMON_H 63 | 64 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidRawSensorDevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef ANDROID_SENSORHAL_EXT_HIDRAW_SENSOR_DEVICE_H 17 | #define ANDROID_SENSORHAL_EXT_HIDRAW_SENSOR_DEVICE_H 18 | 19 | #include "BaseSensorObject.h" 20 | #include "BaseDynamicSensorDaemon.h" // BaseSensorVector 21 | #include "HidRawDevice.h" 22 | #include "HidRawSensor.h" 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace android { 30 | namespace SensorHalExt { 31 | 32 | class HidRawSensorDevice : public HidRawDevice, public Thread { 33 | public: 34 | static sp create(const std::string &devName); 35 | virtual ~HidRawSensorDevice(); 36 | 37 | // get a list of sensors associated with this device 38 | BaseSensorVector getSensors() const; 39 | private: 40 | static const std::unordered_set sInterested; 41 | 42 | // constructor will result in +1 strong count 43 | explicit HidRawSensorDevice(const std::string &devName); 44 | void enableSchedFifoMode(); 45 | // implement function of Thread 46 | virtual bool threadLoop() override; 47 | std::unordered_map> mSensors; 48 | bool mValid; 49 | }; 50 | 51 | } // namespace SensorHalExt 52 | } // namespace android 53 | 54 | #endif // ANDROID_SENSORHAL_EXT_HIDRAW_DEVICE_H 55 | 56 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidUtils/HidGlobal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef HIDUTIL_HIDGLOBAL_H_ 17 | #define HIDUTIL_HIDGLOBAL_H_ 18 | 19 | #include "HidItem.h" 20 | #include "TriState.h" 21 | 22 | namespace HidUtil { 23 | // A set of global states that parser has to keep track during parsing. 24 | // They are all specified in HID spec v1.11 section 6.2.2.7 25 | struct HidGlobal { 26 | // add a token and change global states, returns value indicates if operation is successful 27 | bool append(const HidItem &i); 28 | 29 | tri_uint usagePage; 30 | tri_int logicalMin; 31 | tri_int logicalMax; 32 | tri_int physicalMin; 33 | tri_int physicalMax; 34 | tri_uint exponent; 35 | tri_uint unit; 36 | tri_uint reportSize; 37 | tri_uint reportId; 38 | tri_uint reportCount; 39 | }; 40 | 41 | // HID specs allows PUSH and POP to save a snapshot of current global states and come back to the 42 | // saved sates later. HidStack manages this logic. Note that PUSH and POP are also HidItems, so 43 | // there is no explicit push and pop function in this stack implementation. 44 | class HidGlobalStack { 45 | public: 46 | HidGlobalStack(); 47 | 48 | // add a token and change global states, returns value indicates if operation is successful 49 | // it the token is push/pop, the stack push/pop accordingly. 50 | bool append(const HidItem &i); 51 | 52 | // get reference to top element on the stack 53 | const HidGlobal& top() const; 54 | private: 55 | std::vector mStack; 56 | }; 57 | 58 | } //namespace HidUtil 59 | 60 | #endif // HIDUTIL_HIDGLOABL_H_ 61 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidUtils/HidItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef HIDUTIL_HIDITEM_H_ 17 | #define HIDUTIL_HIDITEM_H_ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace HidUtil { 25 | 26 | struct HidItem { 27 | bool valid; 28 | unsigned int type; 29 | unsigned int tag; 30 | ssize_t offset; 31 | ssize_t byteSize; 32 | std::vector data; 33 | 34 | bool dataAsUnsigned(unsigned int *out) const; 35 | bool dataAsSigned(int *out) const; 36 | 37 | // friend stream functions 38 | friend std::istream& operator>>(std::istream &is, HidItem &h); 39 | friend std::ostream& operator<<(std::ostream &os, const HidItem &h); 40 | 41 | // tokenize from a unsigned char vector 42 | static std::vector tokenize(const std::vector &descriptor); 43 | static std::vector tokenize(const uint8_t *begin, size_t size); 44 | static std::vector tokenize(std::istream &is); 45 | }; 46 | 47 | // parsing in from binary stream 48 | std::istream& operator>>(std::istream &is, HidUtil::HidItem &h); 49 | 50 | // output as human readable string to stream 51 | std::ostream& operator<<(std::ostream &os, const HidUtil::HidItem &h); 52 | } //namespace HidUtil 53 | 54 | #endif // HIDUTIL_HIDITEM_H_ 55 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidUtils/HidLocal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef HIDUTIL_HIDLOCAL_H_ 17 | #define HIDUTIL_HIDLOCAL_H_ 18 | 19 | #include "HidItem.h" 20 | #include "TriState.h" 21 | #include 22 | #include 23 | 24 | namespace HidUtil { 25 | 26 | // A set of local states that parser has to keep track during parsing. 27 | // They are all specified in HID spec v1.11 section 6.2.2.8 28 | struct HidLocal { 29 | // add a token to change local states, return value indicates if operation is successful 30 | bool append(const HidItem &i); 31 | // clear all local states. This need to be done after each main tag 32 | void clear(); 33 | 34 | // multiple usage, designator or strings may exist for single input/output/feature report 35 | uint32_t getUsage(size_t index) const; 36 | uint32_t getDesignator(size_t index) const; 37 | uint32_t getString(size_t index) const; 38 | 39 | std::vector usage; 40 | // keep track of usage min when expecting a usage max 41 | tri_uint usageMin; 42 | 43 | std::vector designator; 44 | // keep track of designator min when expecting designator max 45 | tri_uint designatorMin; 46 | 47 | std::vector string; 48 | // keep track of string min when expecting string max 49 | tri_uint stringMin; 50 | 51 | tri_uint delimeter; 52 | }; 53 | } // namespace HidUtil 54 | 55 | #endif // HIDUTIL_HIDLOCAL_H_ 56 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidUtils/HidLog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef HIDUTIL_HIDLOG_H_ 17 | #define HIDUTIL_HIDLOG_H_ 18 | 19 | #if defined(__ANDROID__) && !defined(LOG_TO_CONSOLE) 20 | #include 21 | #define LOG_ENDL "" 22 | #define LOG_E LOG(ERROR) 23 | #define LOG_W LOG(WARNING) 24 | #define LOG_I LOG(INFO) 25 | #define LOG_D LOG(DEBUG) 26 | #define LOG_V LOG(VERBOSE) 27 | #else 28 | #include 29 | #define LOG_ENDL std::endl 30 | #define LOG_E (std::cerr << "E: ") 31 | #define LOG_W (std::cerr << "W: ") 32 | #define LOG_I (std::cerr << "I: ") 33 | #define LOG_D (std::cerr << "D: ") 34 | #define LOG_V (std::cerr << "V: ") 35 | #endif 36 | 37 | #endif // HIDUTIL_HIDLOG_H_ 38 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidUtils/HidUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef HIDUTIL_HIDUTILS_H_ 17 | #define HIDUTIL_HIDUTILS_H_ 18 | 19 | #include 20 | 21 | namespace HidUtil { 22 | 23 | void copyBits(const void *src, void *dst, size_t dst_size, 24 | unsigned int src_bit_offset, unsigned int dst_bit_offset, 25 | unsigned int bit_count); 26 | 27 | } // namespace HidUtil 28 | 29 | #endif // HIDUTIL_HIDUTILS_H_ 30 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidUtils/test/TestHidDescriptor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LineageOS/android_hardware_libhardware/9a53e28cbdc3a9aa2106ca596fbb17dada6f53f4/modules/sensors/dynamic_sensor/HidUtils/test/TestHidDescriptor.cpp -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidUtils/test/TestHidDescriptor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef HIDUTIL_TEST_HIDDESCRIPTOR_H_ 17 | #define HIDUTIL_TEST_HIDDESCRIPTOR_H_ 18 | 19 | #include 20 | 21 | struct TestHidDescriptor { 22 | const unsigned char *data; 23 | size_t len; 24 | const char *name; 25 | }; 26 | 27 | extern const TestHidDescriptor gDescriptorArray[]; 28 | const TestHidDescriptor *findTestDescriptor(const char *name); 29 | 30 | #endif // HIDUTIL_TEST_HIDDESCRIPTOR_H_ 31 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/HidUtils/test/TestHidSensorSpec.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LineageOS/android_hardware_libhardware/9a53e28cbdc3a9aa2106ca596fbb17dada6f53f4/modules/sensors/dynamic_sensor/HidUtils/test/TestHidSensorSpec.h -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/RingBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef RING_BUFFER_H_ 18 | 19 | #define RING_BUFFER_H_ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | namespace android { 27 | 28 | class RingBuffer { 29 | public: 30 | explicit RingBuffer(size_t size); 31 | ~RingBuffer(); 32 | 33 | ssize_t write(const sensors_event_t *ev, size_t size); 34 | ssize_t read(sensors_event_t *ev, size_t size); 35 | 36 | private: 37 | Mutex mLock; 38 | Condition mNotEmptyCondition; 39 | 40 | size_t mSize; 41 | sensors_event_t *mData; 42 | size_t mReadPos, mWritePos; 43 | 44 | DISALLOW_EVIL_CONSTRUCTORS(RingBuffer); 45 | }; 46 | 47 | } // namespace android 48 | 49 | #endif // RING_BUFFER_H_ 50 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/SensorEventCallback.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_SENSORHAL_DSE_SENSOR_EVENT_CALLBACK_H 18 | #define ANDROID_SENSORHAL_DSE_SENSOR_EVENT_CALLBACK_H 19 | 20 | #include "Utils.h" 21 | #include 22 | 23 | namespace android { 24 | namespace SensorHalExt { 25 | class BaseSensorObject; 26 | 27 | // if timestamp in sensors_event_t has this value, it will be filled at dispatcher. 28 | constexpr int64_t TIMESTAMP_AUTO_FILL = -1; 29 | 30 | class SensorEventCallback { 31 | public: 32 | virtual int submitEvent(SP(BaseSensorObject) sensor, const sensors_event_t &e) = 0; 33 | virtual ~SensorEventCallback() = default; 34 | }; 35 | 36 | } // namespace SensorHalExt 37 | } // namespace android 38 | 39 | #endif // ANDROID_SENSORHAL_DSE_SENSOR_EVENT_CALLBACK_H 40 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/Utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef ANDROID_SENSORHAL_EXT_UTILS_H 17 | #define ANDROID_SENSORHAL_EXT_UTILS_H 18 | 19 | // Host build does not have RefBase 20 | #ifdef __ANDROID__ 21 | #include 22 | #define REF_BASE(a) ::android::RefBase 23 | #define SP(a) sp 24 | #define WP(a) wp 25 | #define SP_THIS this 26 | #define PROMOTE(a) (a).promote() 27 | #else 28 | #include 29 | #define REF_BASE(a) std::enable_shared_from_this 30 | #define SP(a) std::shared_ptr 31 | #define WP(a) std::weak_ptr 32 | #define SP_THIS shared_from_this() 33 | #define PROMOTE(a) (a).lock() 34 | #endif 35 | 36 | #endif // ANDROID_SENSORHAL_EXT_UTILS_H 37 | -------------------------------------------------------------------------------- /modules/sensors/dynamic_sensor/dynamic_sensors.aconfig: -------------------------------------------------------------------------------- 1 | package: "com.android.libhardware.dynamic.sensors.flags" 2 | container: "system" 3 | 4 | flag { 5 | name: "dynamic_sensors_le_audio" 6 | namespace: "sensors" 7 | description: "This flag controls the enablement of LE audio support on dynamic sensors" 8 | bug: "298450041" 9 | } 10 | 11 | flag { 12 | name: "dynamic_sensors_hal_disconnect_dynamic_sensor" 13 | namespace: "sensors" 14 | description: "This flag controls if onDynamicSensorDisconnect callback in sensors HAL will be triggered" 15 | bug: "316958439" 16 | } -------------------------------------------------------------------------------- /modules/sensors/multihal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef HARDWARE_LIBHARDWARE_MODULES_SENSORS_MULTIHAL_H_ 17 | #define HARDWARE_LIBHARDWARE_MODULES_SENSORS_MULTIHAL_H_ 18 | 19 | #include 20 | #include 21 | 22 | static const char* MULTI_HAL_CONFIG_FILE_PATH = "/vendor/etc/sensors/hals.conf"; 23 | 24 | // Depracated because system partition HAL config file does not satisfy treble requirements. 25 | static const char* DEPRECATED_MULTI_HAL_CONFIG_FILE_PATH = "/system/etc/sensors/hals.conf"; 26 | 27 | struct sensors_module_t *get_multi_hal_module_info(void); 28 | 29 | #endif // HARDWARE_LIBHARDWARE_MODULES_SENSORS_MULTIHAL_H_ 30 | -------------------------------------------------------------------------------- /modules/soundtrigger/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Stub sound_trigger HAL module, used for tests 16 | package { 17 | // See: http://go/android-license-faq 18 | // A large-scale-change added 'default_applicable_licenses' to import 19 | // all of the 'license_kinds' from "hardware_libhardware_license" 20 | // to get the below license kinds: 21 | // SPDX-license-identifier-Apache-2.0 22 | default_applicable_licenses: ["hardware_libhardware_license"], 23 | } 24 | 25 | cc_library_shared { 26 | name: "sound_trigger.stub.default", 27 | relative_install_path: "hw", 28 | vendor: true, 29 | srcs: ["sound_trigger_hw.c"], 30 | shared_libs: [ 31 | "liblog", 32 | "libcutils", 33 | ], 34 | header_libs: ["libhardware_headers"], 35 | cflags: [ 36 | "-Wno-error=incompatible-pointer-types", 37 | "-Wno-unused-function", 38 | "-Wno-unused-parameter", 39 | "-Wno-unused-variable", 40 | ], 41 | } 42 | -------------------------------------------------------------------------------- /modules/thermal/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "thermal.default", 26 | relative_install_path: "hw", 27 | vendor: true, 28 | srcs: ["thermal.c"], 29 | shared_libs: [ 30 | "liblog", 31 | "libcutils", 32 | "libutils", 33 | ], 34 | header_libs: ["libhardware_headers"], 35 | cflags: ["-Wno-unused-parameter"], 36 | } 37 | -------------------------------------------------------------------------------- /modules/tv_input/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "tv_input.default", 26 | relative_install_path: "hw", 27 | proprietary: true, 28 | header_libs: ["libhardware_headers"], 29 | shared_libs: [ 30 | "libcutils", 31 | "liblog", 32 | ], 33 | srcs: ["tv_input.cpp"], 34 | cflags: ["-Wall", "-Werror"], 35 | } 36 | -------------------------------------------------------------------------------- /modules/usbaudio/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_defaults { 25 | name: "audio.usb_defaults", 26 | relative_install_path: "hw", 27 | vendor: true, 28 | srcs: ["audio_hal.c"], 29 | shared_libs: [ 30 | "liblog", 31 | "libcutils", 32 | "libaudioutils", 33 | ], 34 | cflags: ["-Wno-unused-parameter"], 35 | header_libs: ["libhardware_headers"], 36 | } 37 | 38 | cc_library_shared { 39 | name: "audio.usb.default", 40 | defaults: ["audio.usb_defaults"], 41 | shared_libs: [ 42 | "libtinyalsa", 43 | "libalsautils", 44 | ], 45 | } 46 | 47 | cc_library_shared { 48 | name: "audio.usbv2.default", 49 | defaults: ["audio.usb_defaults"], 50 | shared_libs: [ 51 | "libtinyalsav2", 52 | "libalsautilsv2", 53 | ], 54 | } 55 | -------------------------------------------------------------------------------- /modules/usbcamera/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "camera.usb.default", 26 | relative_install_path: "hw", 27 | 28 | srcs: [ 29 | "CameraHAL.cpp", 30 | "Camera.cpp", 31 | "UsbCamera.cpp", 32 | "Metadata.cpp", 33 | "Stream.cpp", 34 | "HotplugThread.cpp", 35 | ], 36 | 37 | shared_libs: [ 38 | "libcamera_metadata", 39 | "libcutils", 40 | "liblog", 41 | "libsync", 42 | "libutils", 43 | ], 44 | 45 | cflags: [ 46 | "-Wall", 47 | "-Wextra", 48 | "-Werror", 49 | "-fvisibility=hidden", 50 | ], 51 | } 52 | -------------------------------------------------------------------------------- /modules/usbcamera/CameraHAL.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef CAMERA_HAL_H_ 18 | #define CAMERA_HAL_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include "HotplugThread.h" 25 | #include "Camera.h" 26 | 27 | namespace usb_camera_hal { 28 | 29 | class HotplugThread; 30 | 31 | /** 32 | * CameraHAL contains all module state that isn't specific to an individual camera device 33 | */ 34 | class CameraHAL { 35 | public: 36 | CameraHAL(); 37 | ~CameraHAL(); 38 | 39 | // Camera Module Interface (see ) 40 | int getNumberOfCameras(); 41 | int getCameraInfo(int camera_id, struct camera_info *info); 42 | int setCallbacks(const camera_module_callbacks_t *callbacks); 43 | void getVendorTagOps(vendor_tag_ops_t* ops); 44 | 45 | // Hardware Module Interface (see ) 46 | int open(const hw_module_t* mod, const char* name, hw_device_t** dev); 47 | 48 | private: 49 | // Callback handle 50 | const camera_module_callbacks_t *mCallbacks; 51 | android::Vector mCameras; 52 | // Lock to protect the module method calls. 53 | android::Mutex mModuleLock; 54 | // Hot plug thread managing camera hot plug. 55 | HotplugThread *mHotplugThread; 56 | 57 | }; 58 | } // namespace usb_camera_hal 59 | 60 | #endif // CAMERA_HAL_H_ 61 | -------------------------------------------------------------------------------- /modules/usbcamera/HotplugThread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | //#define LOG_NDEBUG 0 18 | #define LOG_TAG "HotplugThread" 19 | 20 | #include 21 | 22 | #include "HotplugThread.h" 23 | 24 | namespace usb_camera_hal { 25 | 26 | HotplugThread::HotplugThread(CameraHAL *hal) 27 | : mModule(hal) { 28 | 29 | } 30 | 31 | HotplugThread::~HotplugThread() { 32 | 33 | } 34 | 35 | void HotplugThread::requestExit() { 36 | // Call parent to set up shutdown 37 | Thread::requestExit(); 38 | 39 | // Cleanup other states? 40 | } 41 | 42 | bool HotplugThread::threadLoop() { 43 | (void)mModule; // silence warning about unused member. 44 | 45 | /** 46 | * Check camera connection status change, if connected, do below: 47 | * 1. Create camera device, add to mCameras. 48 | * 2. Init static info (mCameras[id]->initStaticInfo()) 49 | * 3. Notify on_status_change callback 50 | * 51 | * If unconnected, similarly, do below: 52 | * 1. Destroy camera device and remove it from mCameras. 53 | * 2. Notify on_status_change callback 54 | * 55 | * DO NOT have a tight polling loop here, to avoid excessive CPU utilization. 56 | */ 57 | 58 | return true; 59 | } 60 | 61 | } // namespace usb_camera_hal 62 | -------------------------------------------------------------------------------- /modules/usbcamera/HotplugThread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #ifndef HOTPLUG_THREAD_H_ 17 | #define HOTPLUG_THREAD_H_ 18 | 19 | #include 20 | #include "CameraHAL.h" 21 | 22 | namespace usb_camera_hal { 23 | /** 24 | * Thread for managing usb camera hotplug. It does below: 25 | * 1. Monitor camera hotplug status, and notify the status changes by calling 26 | * module callback methods. 27 | * 2. When camera is plugged, create camera device instance, initialize the camera 28 | * static info. When camera is unplugged, destroy the camera device instance and 29 | * static metadata. As an optimization option, the camera device instance (including 30 | * the static info) could be cached when the same camera plugged/unplugged multiple 31 | * times. 32 | */ 33 | 34 | class CameraHAL; 35 | 36 | class HotplugThread : public android::Thread { 37 | 38 | public: 39 | explicit HotplugThread(CameraHAL *hal); 40 | ~HotplugThread(); 41 | 42 | // Override below two methods for proper cleanup. 43 | virtual bool threadLoop(); 44 | virtual void requestExit(); 45 | 46 | private: 47 | CameraHAL *mModule; 48 | }; 49 | 50 | } // namespace usb_camera_hal 51 | 52 | #endif // HOTPLUG_THREAD_H_ 53 | -------------------------------------------------------------------------------- /modules/usbcamera/Metadata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef METADATA_H_ 18 | #define METADATA_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace usb_camera_hal { 25 | // Metadata is a convenience class for dealing with libcamera_metadata 26 | class Metadata { 27 | public: 28 | Metadata(); 29 | ~Metadata(); 30 | // Initialize with framework metadata 31 | int init(const camera_metadata_t *metadata); 32 | 33 | // Parse and add an entry. Allocates and copies new storage for *data. 34 | int addUInt8(uint32_t tag, int count, const uint8_t *data); 35 | int add1UInt8(uint32_t tag, const uint8_t data); 36 | int addInt32(uint32_t tag, int count, const int32_t *data); 37 | int addFloat(uint32_t tag, int count, const float *data); 38 | int addInt64(uint32_t tag, int count, const int64_t *data); 39 | int addDouble(uint32_t tag, int count, const double *data); 40 | int addRational(uint32_t tag, int count, 41 | const camera_metadata_rational_t *data); 42 | 43 | // Get a handle to the current metadata 44 | // This is not a durable handle, and may be destroyed by add*/init 45 | camera_metadata_t* get(); 46 | 47 | private: 48 | // Actual internal storage 49 | camera_metadata_t* mData; 50 | // Destroy old metadata and replace with new 51 | void replace(camera_metadata_t *m); 52 | // Validate the tag, type and count for a metadata entry 53 | bool validate(uint32_t tag, int tag_type, int count); 54 | // Add a verified tag with data 55 | int add(uint32_t tag, int count, const void *tag_data); 56 | }; 57 | } // namespace usb_camera_hal 58 | 59 | #endif // METADATA_H_ 60 | -------------------------------------------------------------------------------- /modules/usbcamera/Stream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef STREAM_H_ 18 | #define STREAM_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace usb_camera_hal { 27 | // Stream represents a single input or output stream for a camera device. 28 | class Stream { 29 | public: 30 | Stream(int id, camera3_stream_t *s); 31 | ~Stream(); 32 | 33 | // validate that a stream's parameters match this stream's parameters 34 | bool isValidReuseStream(int id, camera3_stream_t *s); 35 | 36 | void setUsage(uint32_t usage); 37 | void setMaxBuffers(uint32_t max_buffers); 38 | 39 | int getType(); 40 | bool isInputType(); 41 | bool isOutputType(); 42 | const char* typeToString(int type); 43 | const char* formatToString(int format); 44 | void dump(int fd); 45 | 46 | // This stream is being reused. Used in stream configuration passes 47 | bool mReuse; 48 | 49 | private: 50 | // The camera device id this stream belongs to 51 | const int mId; 52 | // Handle to framework's stream, used as a cookie for buffers 53 | camera3_stream_t *mStream; 54 | // Array of handles to buffers currently in use by the stream 55 | android::Vector mBuffers; 56 | // Lock protecting the Stream object for modifications 57 | android::Mutex mLock; 58 | }; 59 | } // namespace usb_camera_hal 60 | 61 | #endif // STREAM_H_ 62 | -------------------------------------------------------------------------------- /modules/usbcamera/UsbCamera.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef EXAMPLE_CAMERA_H_ 18 | #define EXAMPLE_CAMERA_H_ 19 | 20 | #include 21 | #include "Camera.h" 22 | 23 | namespace usb_camera_hal { 24 | /** 25 | * UsbCamera is an example for a specific camera device. The Camera instance contains 26 | * a specific camera device (e.g. UsbCamera) holds all specific metadata and logic about 27 | * that device. 28 | */ 29 | class UsbCamera : public Camera { 30 | public: 31 | explicit UsbCamera(int id); 32 | ~UsbCamera(); 33 | 34 | private: 35 | // Initialize static camera characteristics for individual device 36 | int initStaticInfo(); 37 | int openDevice(); 38 | // Initialize whole device (templates/etc) when opened 39 | int initDevice(); 40 | int flushDevice(); 41 | int closeDevice(); 42 | int processCaptureBuffer(const camera3_stream_buffer_t *in, camera3_stream_buffer_t *out); 43 | // Initialize each template metadata controls 44 | int initPreviewTemplate(Metadata m); 45 | int initStillTemplate(Metadata m); 46 | int initRecordTemplate(Metadata m); 47 | int initSnapshotTemplate(Metadata m); 48 | int initZslTemplate(Metadata m); 49 | int initManualTemplate(Metadata m); 50 | // Verify settings are valid for a capture with this device 51 | bool isValidCaptureSettings(const camera_metadata_t* settings); 52 | }; 53 | } // namespace usb_camera_hal 54 | 55 | #endif // CAMERA_H_ 56 | -------------------------------------------------------------------------------- /modules/vibrator/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "vibrator.default", 26 | 27 | // HAL module implementation stored in 28 | // hw/.default.so 29 | relative_install_path: "hw", 30 | proprietary: true, 31 | header_libs: ["libhardware_headers"], 32 | srcs: ["vibrator.c"], 33 | cflags: ["-Wall", "-Werror"], 34 | shared_libs: ["liblog"], 35 | } 36 | -------------------------------------------------------------------------------- /modules/vr/Android.bp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2016 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package { 16 | // See: http://go/android-license-faq 17 | // A large-scale-change added 'default_applicable_licenses' to import 18 | // all of the 'license_kinds' from "hardware_libhardware_license" 19 | // to get the below license kinds: 20 | // SPDX-license-identifier-Apache-2.0 21 | default_applicable_licenses: ["hardware_libhardware_license"], 22 | } 23 | 24 | cc_library_shared { 25 | name: "vr.default", 26 | relative_install_path: "hw", 27 | vendor: true, 28 | srcs: ["vr.c"], 29 | header_libs: ["libhardware_headers"], 30 | shared_libs: ["libcutils"], 31 | 32 | cflags: [ 33 | "-Wall", 34 | "-Werror", 35 | "-Wno-unused-parameter", 36 | ], 37 | } 38 | -------------------------------------------------------------------------------- /modules/vr/vr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #define LOG_TAG "VrHal" 17 | 18 | #include 19 | #include 20 | 21 | static void vr_init(struct vr_module *module) { 22 | // NOOP 23 | } 24 | 25 | static void vr_set_vr_mode(struct vr_module *module, bool enabled) { 26 | // NOOP 27 | } 28 | 29 | static struct hw_module_methods_t vr_module_methods = { 30 | .open = NULL, 31 | }; 32 | 33 | 34 | vr_module_t HAL_MODULE_INFO_SYM = { 35 | .common = { 36 | .tag = HARDWARE_MODULE_TAG, 37 | .module_api_version = VR_MODULE_API_VERSION_1_0, 38 | .hal_api_version = HARDWARE_HAL_API_VERSION, 39 | .id = VR_HARDWARE_MODULE_ID, 40 | .name = "Demo VR HAL", 41 | .author = "The Android Open Source Project", 42 | .methods = &vr_module_methods, 43 | }, 44 | 45 | .init = vr_init, 46 | .set_vr_mode = vr_set_vr_mode, 47 | }; 48 | -------------------------------------------------------------------------------- /tests/camera2/AndroidTest.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 21 | 27 | -------------------------------------------------------------------------------- /tests/camera3/Android.bp: -------------------------------------------------------------------------------- 1 | package { 2 | // See: http://go/android-license-faq 3 | // A large-scale-change added 'default_applicable_licenses' to import 4 | // all of the 'license_kinds' from "hardware_libhardware_license" 5 | // to get the below license kinds: 6 | // SPDX-license-identifier-Apache-2.0 7 | default_applicable_licenses: ["hardware_libhardware_license"], 8 | } 9 | 10 | cc_test { 11 | name: "camera3_tests", 12 | srcs: ["camera3tests.cpp"], 13 | 14 | shared_libs: [ 15 | "liblog", 16 | "libhardware", 17 | "libcamera_metadata", 18 | ], 19 | 20 | cflags: [ 21 | "-Wall", 22 | "-Wextra", 23 | "-Werror", 24 | ], 25 | } 26 | -------------------------------------------------------------------------------- /tests/fingerprint/Android.bp: -------------------------------------------------------------------------------- 1 | package { 2 | // See: http://go/android-license-faq 3 | // A large-scale-change added 'default_applicable_licenses' to import 4 | // all of the 'license_kinds' from "hardware_libhardware_license" 5 | // to get the below license kinds: 6 | // SPDX-license-identifier-Apache-2.0 7 | default_applicable_licenses: ["hardware_libhardware_license"], 8 | } 9 | 10 | cc_test { 11 | name: "fingerprint_tests", 12 | srcs: ["fingerprint_tests.cpp"], 13 | 14 | shared_libs: [ 15 | "liblog", 16 | "libhardware", 17 | ], 18 | 19 | cflags: [ 20 | "-Wall", 21 | "-Werror", 22 | "-Wextra", 23 | ], 24 | } 25 | -------------------------------------------------------------------------------- /tests/fingerprint/fingerprint_tests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include "fingerprint_test_fixtures.h" 19 | 20 | namespace tests { 21 | 22 | TEST_F(FingerprintDevice, isThereEnroll) { 23 | ASSERT_TRUE(NULL != fp_device()->enroll) 24 | << "enroll() function is not implemented"; 25 | } 26 | 27 | TEST_F(FingerprintDevice, isTherePreEnroll) { 28 | ASSERT_TRUE(NULL != fp_device()->pre_enroll) 29 | << "pre_enroll() function is not implemented"; 30 | } 31 | 32 | TEST_F(FingerprintDevice, isThereGetAuthenticatorId) { 33 | ASSERT_TRUE(NULL != fp_device()->get_authenticator_id) 34 | << "get_authenticator_id() function is not implemented"; 35 | } 36 | 37 | TEST_F(FingerprintDevice, isThereCancel) { 38 | ASSERT_TRUE(NULL != fp_device()->cancel) 39 | << "cancel() function is not implemented"; 40 | } 41 | 42 | TEST_F(FingerprintDevice, isThereRemove) { 43 | ASSERT_TRUE(NULL != fp_device()->remove) 44 | << "remove() function is not implemented"; 45 | } 46 | 47 | TEST_F(FingerprintDevice, isThereAuthenticate) { 48 | ASSERT_TRUE(NULL != fp_device()->authenticate) 49 | << "authenticate() function is not implemented"; 50 | } 51 | 52 | TEST_F(FingerprintDevice, isThereSetActiveGroup) { 53 | ASSERT_TRUE(NULL != fp_device()->set_active_group) 54 | << "set_active_group() function is not implemented"; 55 | } 56 | 57 | TEST_F(FingerprintDevice, isThereSetNotify) { 58 | ASSERT_TRUE(NULL != fp_device()->set_notify) 59 | << "set_notify() function is not implemented"; 60 | } 61 | 62 | } // namespace tests 63 | -------------------------------------------------------------------------------- /tests/hardware/Android.bp: -------------------------------------------------------------------------------- 1 | package { 2 | // See: http://go/android-license-faq 3 | // A large-scale-change added 'default_applicable_licenses' to import 4 | // all of the 'license_kinds' from "hardware_libhardware_license" 5 | // to get the below license kinds: 6 | // SPDX-license-identifier-Apache-2.0 7 | default_applicable_licenses: ["hardware_libhardware_license"], 8 | } 9 | 10 | cc_library_static { 11 | name: "static-hal-check", 12 | srcs: [ 13 | "struct-size.cpp", 14 | "struct-offset.cpp", 15 | "struct-last.cpp", 16 | ], 17 | shared_libs: ["libhardware"], 18 | cflags: [ 19 | "-O0", 20 | "-Wall", 21 | "-Werror", 22 | ], 23 | 24 | vendor: true, 25 | 26 | include_dirs: ["system/media/camera/include"], 27 | } 28 | -------------------------------------------------------------------------------- /tests/hardware/struct-last.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #define GET_PADDING(align, size) (((align) - ((size) % (align))) % (align)) 28 | 29 | #define CHECK_LAST_MEMBER(type, member) \ 30 | do { \ 31 | static constexpr size_t calc_size = offsetof(type, member) + sizeof(((type *)0)->member); \ 32 | static_assert(sizeof(type) == calc_size + GET_PADDING(alignof(type), calc_size), \ 33 | "" #member " is not the last element of " #type); \ 34 | } while (0) 35 | 36 | void CheckSizes(void) { 37 | //Types defined in hardware.h 38 | CHECK_LAST_MEMBER(hw_module_t, reserved); 39 | CHECK_LAST_MEMBER(hw_device_t, close); 40 | 41 | //Types defined in sensors.h 42 | CHECK_LAST_MEMBER(sensors_vec_t, reserved); 43 | CHECK_LAST_MEMBER(sensors_event_t, reserved1); 44 | CHECK_LAST_MEMBER(struct sensor_t, reserved); 45 | CHECK_LAST_MEMBER(sensors_poll_device_1_t, reserved_procs); 46 | 47 | //Types defined in fb.h 48 | CHECK_LAST_MEMBER(framebuffer_device_t, reserved_proc); 49 | 50 | //Types defined in hwcomposer.h 51 | CHECK_LAST_MEMBER(hwc_layer_1_t, reserved); 52 | CHECK_LAST_MEMBER(hwc_composer_device_1_t, reserved_proc); 53 | 54 | //Types defined in gralloc.h 55 | CHECK_LAST_MEMBER(gralloc_module_t, reserved_proc); 56 | CHECK_LAST_MEMBER(alloc_device_t, reserved_proc); 57 | 58 | //Types defined in consumerir.h 59 | CHECK_LAST_MEMBER(consumerir_device_t, reserved); 60 | 61 | //Types defined in camera_common.h 62 | CHECK_LAST_MEMBER(vendor_tag_ops_t, reserved); 63 | CHECK_LAST_MEMBER(camera_module_t, reserved); 64 | 65 | //Types defined in camera3.h 66 | CHECK_LAST_MEMBER(camera3_device_ops_t, reserved); 67 | } 68 | 69 | -------------------------------------------------------------------------------- /tests/hardware/struct-size.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | template static constexpr size_t CheckSizeHelper(size_t, size_t) __attribute((unused)); 28 | 29 | template<> constexpr size_t CheckSizeHelper<4>(size_t size32, size_t /* size64 */) { 30 | return size32; 31 | } 32 | 33 | template<> constexpr size_t CheckSizeHelper<8>(size_t /* size32 */, size_t size64) { 34 | return size64; 35 | } 36 | 37 | template static void CheckTypeSize() { 38 | const size_t mySize = CheckSizeHelper(size32, size64); 39 | 40 | static_assert(sizeof(T) == mySize, "struct is the wrong size"); 41 | } 42 | 43 | void CheckSizes(void) { 44 | //Types defined in hardware.h 45 | CheckTypeSize(); 46 | CheckTypeSize(); 47 | 48 | //Types defined in sensors.h 49 | CheckTypeSize(); 50 | CheckTypeSize(); 51 | CheckTypeSize(); 52 | CheckTypeSize(); 53 | 54 | //Types defined in fb.h 55 | CheckTypeSize(); 56 | 57 | //Types defined in hwcomposer.h 58 | CheckTypeSize(); 59 | CheckTypeSize(); 60 | 61 | //Types defined in gralloc.h 62 | CheckTypeSize(); 63 | CheckTypeSize(); 64 | 65 | //Types defined in consumerir.h 66 | CheckTypeSize(); 67 | 68 | //Types defined in camera_common.h 69 | CheckTypeSize(); 70 | CheckTypeSize(); 71 | 72 | //Types defined in camera3.h 73 | CheckTypeSize(); 74 | } 75 | 76 | -------------------------------------------------------------------------------- /tests/hwc/Android.bp: -------------------------------------------------------------------------------- 1 | package { 2 | // See: http://go/android-license-faq 3 | // A large-scale-change added 'default_applicable_licenses' to import 4 | // all of the 'license_kinds' from "hardware_libhardware_license" 5 | // to get the below license kinds: 6 | // SPDX-license-identifier-Apache-2.0 7 | default_applicable_licenses: ["hardware_libhardware_license"], 8 | } 9 | 10 | cc_library_static { 11 | name: "libcnativewindow", 12 | srcs: [ 13 | "cnativewindow.c", 14 | "util.c", 15 | ], 16 | cflags: [ 17 | "-Wall", 18 | "-Werror", 19 | "-Wno-unused-parameter", 20 | ], 21 | shared_libs: [ 22 | "libEGL", 23 | "libGLESv2", 24 | "libdl", 25 | "libhardware", 26 | "libnativewindow", 27 | ], 28 | } 29 | 30 | cc_binary { 31 | name: "hwc-test-arrows", 32 | srcs: ["test-arrows.c"], 33 | static_libs: ["libcnativewindow"], 34 | shared_libs: [ 35 | "libEGL", 36 | "libGLESv2", 37 | "libdl", 38 | "libhardware", 39 | "libnativewindow", 40 | ], 41 | cflags: [ 42 | "-DGL_GLEXT_PROTOTYPES", 43 | "-Wall", 44 | "-Werror", 45 | ], 46 | } 47 | -------------------------------------------------------------------------------- /tests/hwc/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _GL_UTIL_H_ 18 | #define _GL_UTIL_H_ 19 | 20 | /* convenience */ 21 | 22 | GLuint load_program(const char *vert_src, const char *frag_src); 23 | void matrix_init_ortho(GLfloat *m, float w, float h); 24 | 25 | /* context setup / teardown */ 26 | 27 | int egl_create(EGLDisplay *_display, EGLSurface *_surface, int *_w, int *_h); 28 | void egl_destroy(EGLDisplay display, EGLSurface surface); 29 | 30 | /* internals needed by util.c */ 31 | 32 | struct CNativeWindow; 33 | struct CNativeWindow *cnw_create(void); 34 | void cnw_destroy(struct CNativeWindow *win); 35 | void cnw_info(struct CNativeWindow *win, 36 | unsigned *w, unsigned *h, unsigned *fmt); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /tests/input/evdev/Android.bp: -------------------------------------------------------------------------------- 1 | package { 2 | // See: http://go/android-license-faq 3 | // A large-scale-change added 'default_applicable_licenses' to import 4 | // all of the 'license_kinds' from "hardware_libhardware_license" 5 | // to get the below license kinds: 6 | // SPDX-license-identifier-Apache-2.0 7 | default_applicable_licenses: ["hardware_libhardware_license"], 8 | } 9 | 10 | cc_test { 11 | name: "libinput_evdevtests", 12 | 13 | srcs: [ 14 | "BitUtils_test.cpp", 15 | "InputDevice_test.cpp", 16 | "InputHub_test.cpp", 17 | "InputMocks.cpp", 18 | "MouseInputMapper_test.cpp", 19 | "SwitchInputMapper_test.cpp", 20 | "TestHelpers.cpp", 21 | ], 22 | 23 | static_libs: ["libgmock"], 24 | 25 | shared_libs: [ 26 | "libinput_evdev", 27 | "liblog", 28 | "libutils", 29 | ], 30 | 31 | cflags: [ 32 | "-Wall", 33 | "-Wextra", 34 | "-Werror", 35 | "-Wno-unused-parameter", 36 | 37 | // TestHelpers uses mktemp. As the path is given to TempFile, we can't do too much 38 | // here (e.g., use mkdtemp first). At least races will lead to an early failure, as 39 | // mkfifo fails on existing files. 40 | "-Wno-deprecated-declarations", 41 | ], 42 | } 43 | -------------------------------------------------------------------------------- /tests/input/evdev/BitUtils_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include "BitUtils.h" 18 | 19 | #include 20 | 21 | namespace android { 22 | namespace tests { 23 | 24 | TEST(BitInRange, testInvalidRange) { 25 | uint8_t arr[2] = { 0xff, 0xff }; 26 | EXPECT_FALSE(testBitInRange(arr, 0, 0)); 27 | EXPECT_FALSE(testBitInRange(arr, 1, 0)); 28 | } 29 | 30 | TEST(BitInRange, testNoBits) { 31 | uint8_t arr[1]; 32 | arr[0] = 0; 33 | EXPECT_FALSE(testBitInRange(arr, 0, 8)); 34 | } 35 | 36 | TEST(BitInRange, testOneBit) { 37 | uint8_t arr[1]; 38 | for (int i = 0; i < 8; ++i) { 39 | arr[0] = 1 << i; 40 | EXPECT_TRUE(testBitInRange(arr, 0, 8)); 41 | } 42 | } 43 | 44 | TEST(BitInRange, testZeroStart) { 45 | uint8_t arr[1] = { 0x10 }; 46 | for (int i = 0; i < 5; ++i) { 47 | EXPECT_FALSE(testBitInRange(arr, 0, i)); 48 | } 49 | for (int i = 5; i <= 8; ++i) { 50 | EXPECT_TRUE(testBitInRange(arr, 0, i)); 51 | } 52 | } 53 | 54 | TEST(BitInRange, testByteBoundaryEnd) { 55 | uint8_t arr[1] = { 0x10 }; 56 | for (int i = 0; i < 5; ++i) { 57 | EXPECT_TRUE(testBitInRange(arr, i, 8)); 58 | } 59 | for (int i = 5; i <= 8; ++i) { 60 | EXPECT_FALSE(testBitInRange(arr, i, 8)); 61 | } 62 | } 63 | 64 | TEST(BitInRange, testMultiByteArray) { 65 | // bits set: 11 and 16 66 | uint8_t arr[3] = { 0x00, 0x08, 0x01 }; 67 | for (int start = 0; start < 24; ++start) { 68 | for (int end = start + 1; end <= 24; ++end) { 69 | if (start > 16 || end <= 11 || (start > 11 && end <= 16)) { 70 | EXPECT_FALSE(testBitInRange(arr, start, end)) 71 | << "range = (" << start << ", " << end << ")"; 72 | } else { 73 | EXPECT_TRUE(testBitInRange(arr, start, end)) 74 | << "range = (" << start << ", " << end << ")"; 75 | } 76 | } 77 | } 78 | } 79 | 80 | } // namespace tests 81 | } // namespace android 82 | -------------------------------------------------------------------------------- /tests/input/evdev/TestHelpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef ANDROID_TEST_HELPERS_H_ 18 | #define ANDROID_TEST_HELPERS_H_ 19 | 20 | #include 21 | #include 22 | 23 | namespace android { 24 | 25 | /** 26 | * Runs the given function after the specified delay. 27 | * NOTE: if the std::future returned from std::async is not bound, this function 28 | * will block until the task completes. This is almost certainly NOT what you 29 | * want, so save the return value from delay_async into a variable: 30 | * 31 | * auto f = delay_async(100ms, []{ ALOGD("Hello world"); }); 32 | */ 33 | template 34 | decltype(auto) delay_async(Duration&& delay, Function&& task) 35 | { 36 | return std::async(std::launch::async, [=]{ std::this_thread::sleep_for(delay); task(); }); 37 | } 38 | 39 | /** 40 | * Creates and opens a temporary file at the given path. The file is unlinked 41 | * and closed in the destructor. 42 | */ 43 | class TempFile { 44 | public: 45 | explicit TempFile(const char* path); 46 | ~TempFile(); 47 | 48 | // No copy or assign 49 | TempFile(const TempFile&) = delete; 50 | TempFile& operator=(const TempFile&) = delete; 51 | 52 | const char* getName() const { return mName; } 53 | int getFd() const { return mFd; } 54 | 55 | private: 56 | char* mName; 57 | int mFd; 58 | }; 59 | 60 | /** 61 | * Creates a temporary directory that can create temporary files. The directory 62 | * is emptied and deleted in the destructor. 63 | */ 64 | class TempDir { 65 | public: 66 | TempDir(); 67 | ~TempDir(); 68 | 69 | // No copy or assign 70 | TempDir(const TempDir&) = delete; 71 | TempDir& operator=(const TempDir&) = delete; 72 | 73 | const char* getName() const { return mName; } 74 | 75 | TempFile* newTempFile(); 76 | 77 | private: 78 | char* mName; 79 | }; 80 | 81 | } // namespace android 82 | 83 | #endif // ANDROID_TEST_HELPERS_H_ 84 | -------------------------------------------------------------------------------- /tests/nusensors/Android.bp: -------------------------------------------------------------------------------- 1 | package { 2 | // See: http://go/android-license-faq 3 | // A large-scale-change added 'default_applicable_licenses' to import 4 | // all of the 'license_kinds' from "hardware_libhardware_license" 5 | // to get the below license kinds: 6 | // SPDX-license-identifier-Apache-2.0 7 | default_applicable_licenses: ["hardware_libhardware_license"], 8 | } 9 | 10 | cc_binary { 11 | name: "test-nusensors", 12 | 13 | srcs: ["nusensors.cpp"], 14 | 15 | cflags: ["-Wall", "-Werror"], 16 | 17 | shared_libs: [ 18 | "libcutils", 19 | "libhardware", 20 | ], 21 | } 22 | -------------------------------------------------------------------------------- /update-includes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set +ex 4 | 5 | if [ ! "$ANDROID_BUILD_TOP" ]; then 6 | echo "lunch?" 7 | exit 1 8 | fi 9 | 10 | function update-includes() { 11 | find -L "$ANDROID_BUILD_TOP/hardware/libhardware/include/hardware" -maxdepth 1 -xtype l -exec rm {} \; 12 | 13 | for f in $ANDROID_BUILD_TOP/hardware/libhardware/include_all/hardware/*; do 14 | local bn="$(basename $f)" 15 | ln -s "../../include_all/hardware/$bn" "$ANDROID_BUILD_TOP/hardware/libhardware/include/hardware/$bn" 16 | done 17 | } 18 | 19 | update-includes 20 | --------------------------------------------------------------------------------