├── Android.mk ├── AndroidProducts.mk ├── BoardConfig.mk ├── README.md ├── audio ├── audio_platform_info.xml └── mixer_paths_mtp.xml ├── biometrics ├── Android.bp ├── BiometricsFingerprint.cpp ├── BiometricsFingerprint.h ├── android.hardware.biometrics.fingerprint@2.1-service.xiaomi_mido.rc └── service.cpp ├── camera ├── Android.mk ├── CleanSpec.mk ├── MODULE_LICENSE_BSD ├── QCamera2 │ ├── Android.mk │ ├── HAL │ │ ├── CameraParameters.cpp │ │ ├── CameraParameters.h │ │ ├── QCamera2HWI.cpp │ │ ├── QCamera2HWI.h │ │ ├── QCamera2HWICallbacks.cpp │ │ ├── QCameraAllocator.h │ │ ├── QCameraChannel.cpp │ │ ├── QCameraChannel.h │ │ ├── QCameraMem.cpp │ │ ├── QCameraMem.h │ │ ├── QCameraMuxer.cpp │ │ ├── QCameraMuxer.h │ │ ├── QCameraParameters.cpp │ │ ├── QCameraParameters.h │ │ ├── QCameraParametersIntf.cpp │ │ ├── QCameraParametersIntf.h │ │ ├── QCameraPostProc.cpp │ │ ├── QCameraPostProc.h │ │ ├── QCameraStateMachine.cpp │ │ ├── QCameraStateMachine.h │ │ ├── QCameraStream.cpp │ │ ├── QCameraStream.h │ │ ├── QCameraThermalAdapter.cpp │ │ ├── QCameraThermalAdapter.h │ │ ├── android │ │ │ └── QCamera2External.h │ │ ├── test │ │ │ ├── Android.mk │ │ │ ├── qcamera_test.cpp │ │ │ └── qcamera_test.h │ │ ├── tsMakeuplib │ │ │ └── include │ │ │ │ ├── ts_detectface_engine.h │ │ │ │ ├── ts_makeup_data.h │ │ │ │ ├── ts_makeup_engine.h │ │ │ │ └── ts_makeup_image.h │ │ └── wrapper │ │ │ ├── QualcommCamera.cpp │ │ │ └── QualcommCamera.h │ ├── HAL3 │ │ ├── QCamera3Channel.cpp │ │ ├── QCamera3Channel.h │ │ ├── QCamera3CropRegionMapper.cpp │ │ ├── QCamera3CropRegionMapper.h │ │ ├── QCamera3HALHeader.h │ │ ├── QCamera3HWI.cpp │ │ ├── QCamera3HWI.h │ │ ├── QCamera3Mem.cpp │ │ ├── QCamera3Mem.h │ │ ├── QCamera3PostProc.cpp │ │ ├── QCamera3PostProc.h │ │ ├── QCamera3Stream.cpp │ │ ├── QCamera3Stream.h │ │ ├── QCamera3StreamMem.cpp │ │ ├── QCamera3StreamMem.h │ │ ├── QCamera3VendorTags.cpp │ │ ├── QCamera3VendorTags.h │ │ ├── android │ │ │ └── QCamera3External.h │ │ └── test │ │ │ ├── Android.mk │ │ │ ├── QCameraHAL3Base.cpp │ │ │ ├── QCameraHAL3Base.h │ │ │ ├── QCameraHAL3MainTestContext.cpp │ │ │ ├── QCameraHAL3MainTestContext.h │ │ │ ├── QCameraHAL3PreviewTest.cpp │ │ │ ├── QCameraHAL3PreviewTest.h │ │ │ ├── QCameraHAL3RawSnapshotTest.cpp │ │ │ ├── QCameraHAL3RawSnapshotTest.h │ │ │ ├── QCameraHAL3SnapshotTest.cpp │ │ │ ├── QCameraHAL3SnapshotTest.h │ │ │ ├── QCameraHAL3Test.cpp │ │ │ ├── QCameraHAL3Test.h │ │ │ ├── QCameraHAL3VideoTest.cpp │ │ │ └── QCameraHAL3VideoTest.h │ ├── QCamera2Factory.cpp │ ├── QCamera2Factory.h │ ├── QCamera2Hal.cpp │ ├── QCameraFormat.h │ ├── stack │ │ ├── Android.mk │ │ ├── common │ │ │ ├── cam_intf.h │ │ │ ├── cam_list.h │ │ │ ├── cam_queue.h │ │ │ ├── cam_semaphore.h │ │ │ ├── cam_types.h │ │ │ ├── mm_camera_interface.h │ │ │ ├── mm_camera_shim.h │ │ │ └── mm_jpeg_interface.h │ │ ├── mm-camera-interface │ │ │ ├── Android.mk │ │ │ ├── inc │ │ │ │ ├── mm_camera.h │ │ │ │ ├── mm_camera_dbg.h │ │ │ │ └── mm_camera_sock.h │ │ │ └── src │ │ │ │ ├── mm_camera.c │ │ │ │ ├── mm_camera_channel.c │ │ │ │ ├── mm_camera_interface.c │ │ │ │ ├── mm_camera_sock.c │ │ │ │ ├── mm_camera_stream.c │ │ │ │ └── mm_camera_thread.c │ │ ├── mm-jpeg-interface │ │ │ ├── Android.mk │ │ │ ├── inc │ │ │ │ ├── mm_jpeg.h │ │ │ │ ├── mm_jpeg_dbg.h │ │ │ │ ├── mm_jpeg_inlines.h │ │ │ │ ├── mm_jpeg_ionbuf.h │ │ │ │ └── mm_jpeg_mpo.h │ │ │ ├── src │ │ │ │ ├── mm_jpeg.c │ │ │ │ ├── mm_jpeg_exif.c │ │ │ │ ├── mm_jpeg_interface.c │ │ │ │ ├── mm_jpeg_ionbuf.c │ │ │ │ ├── mm_jpeg_mpo_composer.c │ │ │ │ ├── mm_jpeg_queue.c │ │ │ │ ├── mm_jpegdec.c │ │ │ │ └── mm_jpegdec_interface.c │ │ │ └── test │ │ │ │ ├── Android.mk │ │ │ │ ├── mm_jpeg_test.c │ │ │ │ └── mm_jpegdec_test.c │ │ └── mm-lib2d-interface │ │ │ ├── Android.mk │ │ │ ├── inc │ │ │ └── mm_lib2d.h │ │ │ ├── src │ │ │ └── mm_lib2d.c │ │ │ └── test │ │ │ ├── Android.mk │ │ │ └── mm_lib2d_test.c │ └── util │ │ ├── QCameraBufferMaps.cpp │ │ ├── QCameraBufferMaps.h │ │ ├── QCameraCmdThread.cpp │ │ ├── QCameraCmdThread.h │ │ ├── QCameraCommon.cpp │ │ ├── QCameraCommon.h │ │ ├── QCameraDisplay.cpp │ │ ├── QCameraDisplay.h │ │ ├── QCameraFlash.cpp │ │ ├── QCameraFlash.h │ │ ├── QCameraPerf.cpp │ │ ├── QCameraPerf.h │ │ ├── QCameraQueue.cpp │ │ ├── QCameraQueue.h │ │ └── QCameraTrace.h ├── QCameraParameters.h ├── QCamera_Intf.h ├── mm-image-codec │ ├── Android.mk │ ├── qexif │ │ ├── qexif.h │ │ └── qmpo.h │ └── qomx_core │ │ ├── Android.mk │ │ ├── QOMX_JpegExtensions.h │ │ ├── qomx_core.c │ │ └── qomx_core.h └── usbcamcore │ ├── inc │ ├── QCameraMjpegDecode.h │ ├── QCameraUsbParm.h │ ├── QCameraUsbPriv.h │ └── QualcommUsbCamera.h │ └── src │ ├── QCameraMjpegDecode.cpp │ ├── QCameraUsbParm.cpp │ └── QualcommUsbCamera.cpp ├── configs └── sensors │ └── sensor_def_qcomdev.conf ├── consumerir ├── Android.bp ├── ConsumerIr.cpp ├── ConsumerIr.h ├── android.hardware.ir@1.0-service.xiaomi_mido.rc └── service.cpp ├── device.mk ├── extract-files.sh ├── lineage.dependencies ├── lineage_mido.mk ├── lineagehw └── src │ └── org │ └── lineageos │ └── hardware │ └── HighTouchSensitivity.java ├── manifest.xml ├── overlay-lineage └── lineage-sdk │ └── lineage │ └── res │ └── res │ └── values │ └── config.xml ├── overlay ├── frameworks │ └── base │ │ └── core │ │ └── res │ │ └── res │ │ ├── values │ │ └── config.xml │ │ └── xml │ │ └── power_profile.xml └── packages │ └── apps │ └── Settings │ └── res │ └── values │ ├── dimens.xml │ └── lineage_config.xml ├── prop.mk ├── proprietary-files.txt ├── rootdir ├── Android.mk ├── init.goodix.sh └── init.mido.rc ├── sepolicy ├── genfs_contexts ├── private │ └── service_contexts └── vendor │ ├── file_contexts │ ├── gx_fpd.te │ ├── hal_camera_default.te │ ├── hal_fingerprint_mido.te │ ├── mm-qcamerad.te │ ├── service.te │ └── tee.te └── setup-makefiles.sh /Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2017 The LineageOS 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 | # This contains the module build definitions for the hardware-specific 18 | # components for this device. 19 | # 20 | # As much as possible, those components should be built unconditionally, 21 | # with device-specific names to avoid collisions, to avoid device-specific 22 | # bitrot and build breakages. Building a component unconditionally does 23 | # *not* include it on all devices, so it is safe even with hardware-specific 24 | # components. 25 | 26 | LOCAL_PATH := $(call my-dir) 27 | 28 | ifeq ($(TARGET_DEVICE),mido) 29 | include $(call all-makefiles-under,$(LOCAL_PATH)) 30 | endif 31 | -------------------------------------------------------------------------------- /AndroidProducts.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2017-2018 The LineageOS 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 | PRODUCT_MAKEFILES := \ 17 | $(LOCAL_DIR)/lineage_mido.mk 18 | -------------------------------------------------------------------------------- /BoardConfig.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2017 The LineageOS 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 | # Target kernel, must be set before inheriting common tree 17 | TARGET_KERNEL_VERSION := 3.18 18 | 19 | # Inherit from common msm8953-common 20 | -include device/xiaomi/msm8953-common/BoardConfigCommon.mk 21 | 22 | DEVICE_PATH := device/xiaomi/mido 23 | 24 | # Filesystem 25 | BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4 26 | BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4 27 | TARGET_COPY_OUT_VENDOR := vendor 28 | 29 | # HIDL 30 | DEVICE_MANIFEST_FILE += $(DEVICE_PATH)/manifest.xml 31 | 32 | # Kernel 33 | TARGET_KERNEL_CONFIG := mido_defconfig 34 | 35 | # Lineage Hardware 36 | JAVA_SOURCE_OVERLAYS := org.lineageos.hardware|$(VENDOR_PATH)/lineagehw|**/*.java 37 | 38 | # Partitions 39 | BOARD_CACHEIMAGE_PARTITION_SIZE := 268435456 40 | BOARD_RECOVERYIMAGE_PARTITION_SIZE := 67108864 41 | BOARD_USERDATAIMAGE_PARTITION_SIZE := 25765043200 # 25765059584 - 16384 42 | BOARD_VENDORIMAGE_PARTITION_SIZE := 872415232 43 | 44 | # Power 45 | TARGET_TAP_TO_WAKE_NODE := "/proc/touchpanel/enable_dt2w" 46 | 47 | # Sepolicy 48 | BOARD_PLAT_PRIVATE_SEPOLICY_DIR += $(DEVICE_PATH)/sepolicy/private 49 | BOARD_SEPOLICY_DIRS += $(DEVICE_PATH)/sepolicy/vendor 50 | 51 | # Treble 52 | BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true 53 | PRODUCT_FULL_TREBLE_OVERRIDE := true 54 | 55 | # Vendor Security Patch 56 | VENDOR_SECURITY_PATCH := 2018-11-01 57 | 58 | # Inherit from the proprietary version 59 | -include vendor/xiaomi/mido/BoardConfigVendor.mk 60 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Device Tree for Xiaomi Redmi Note 4 & 4x (Mido) 2 | 3 | ## Spec Sheet 4 | 5 | | Feature | Specification | 6 | | :---------------------- | :-------------------------------- | 7 | | CPU | Octa-core 2.0 GHz Cortex-A53 | 8 | | Chipset | Qualcomm MSM8953 Snapdragon 625 | 9 | | GPU | Adreno 506 | 10 | | Memory | 2/3/4 GB | 11 | | Shipped Android Version | 6.0.1 | 12 | | Storage | 32/64 GB | 13 | | MicroSD | Up to 256 GB | 14 | | Battery | 4100 mAh (non-removable) | 15 | | Dimensions | 151 x 76 x 8.5 mm | 16 | | Display | 1920x1080 pixels, 5.5 (~401 PPI) | 17 | | Rear Camera | 13 MP, LED flash | 18 | | Front Camera | 5 MP | 19 | | Release Date | January 2017 | 20 | 21 | ## Device Picture 22 | 23 | ![Redmi Note 4](http://i01.appmifile.com/webfile/globalimg/7/537557F3-A4F1-2490-E9D3-138B2A11DBF6.png "Redmi Note 4") 24 | -------------------------------------------------------------------------------- /biometrics/Android.bp: -------------------------------------------------------------------------------- 1 | cc_binary { 2 | name: "android.hardware.biometrics.fingerprint@2.1-service.xiaomi_mido", 3 | defaults: ["hidl_defaults"], 4 | init_rc: ["android.hardware.biometrics.fingerprint@2.1-service.xiaomi_mido.rc"], 5 | vendor: true, 6 | relative_install_path: "hw", 7 | srcs: [ 8 | "BiometricsFingerprint.cpp", 9 | "service.cpp", 10 | ], 11 | 12 | shared_libs: [ 13 | "libbinder", 14 | "libcutils", 15 | "liblog", 16 | "libhidlbase", 17 | "libhidltransport", 18 | "libhardware", 19 | "libutils", 20 | "libhwbinder", 21 | "android.hardware.biometrics.fingerprint@2.1", 22 | ], 23 | 24 | } 25 | -------------------------------------------------------------------------------- /biometrics/BiometricsFingerprint.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_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H 18 | #define ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | extern bool is_goodix; 29 | 30 | namespace android { 31 | namespace hardware { 32 | namespace biometrics { 33 | namespace fingerprint { 34 | namespace V2_1 { 35 | namespace implementation { 36 | 37 | using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint; 38 | using ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprintClientCallback; 39 | using ::android::hardware::biometrics::fingerprint::V2_1::RequestStatus; 40 | using ::android::hardware::Return; 41 | using ::android::hardware::Void; 42 | using ::android::hardware::hidl_vec; 43 | using ::android::hardware::hidl_string; 44 | using ::android::sp; 45 | 46 | struct BiometricsFingerprint : public IBiometricsFingerprint { 47 | public: 48 | BiometricsFingerprint(); 49 | ~BiometricsFingerprint(); 50 | 51 | // Method to wrap legacy HAL with BiometricsFingerprint class 52 | static IBiometricsFingerprint* getInstance(); 53 | 54 | // Methods from ::android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint follow. 55 | Return setNotify(const sp& clientCallback) override; 56 | Return preEnroll() override; 57 | Return enroll(const hidl_array& hat, uint32_t gid, uint32_t timeoutSec) override; 58 | Return postEnroll() override; 59 | Return getAuthenticatorId() override; 60 | Return cancel() override; 61 | Return enumerate() override; 62 | Return remove(uint32_t gid, uint32_t fid) override; 63 | Return setActiveGroup(uint32_t gid, const hidl_string& storePath) override; 64 | Return authenticate(uint64_t operationId, uint32_t gid) override; 65 | 66 | private: 67 | static fingerprint_device_t* openHal(); 68 | static void notify(const fingerprint_msg_t *msg); /* Static callback for legacy HAL implementation */ 69 | static Return ErrorFilter(int32_t error); 70 | static FingerprintError VendorErrorFilter(int32_t error, int32_t* vendorCode); 71 | static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error, int32_t* vendorCode); 72 | static BiometricsFingerprint* sInstance; 73 | 74 | std::mutex mClientCallbackMutex; 75 | sp mClientCallback; 76 | fingerprint_device_t *mDevice; 77 | }; 78 | 79 | } // namespace implementation 80 | } // namespace V2_1 81 | } // namespace fingerprint 82 | } // namespace biometrics 83 | } // namespace hardware 84 | } // namespace android 85 | 86 | #endif // ANDROID_HARDWARE_BIOMETRICS_FINGERPRINT_V2_1_BIOMETRICSFINGERPRINT_H 87 | -------------------------------------------------------------------------------- /biometrics/android.hardware.biometrics.fingerprint@2.1-service.xiaomi_mido.rc: -------------------------------------------------------------------------------- 1 | service vendor.fps_hal /vendor/bin/hw/android.hardware.biometrics.fingerprint@2.1-service.xiaomi_mido 2 | # "class hal" causes a race condition on some devices due to files created 3 | # in /data. As a workaround, postpone startup until later in boot once 4 | # /data is mounted. 5 | class late_start 6 | user system 7 | group system input 8 | writepid /dev/cpuset/system-background/tasks 9 | disabled 10 | 11 | service vendor.gx_fpd /vendor/bin/gx_fpd 12 | class core 13 | user system 14 | group system drmrpc 15 | writepid /dev/cpuset/system-background/tasks 16 | 17 | on post-fs-data 18 | # Create directories for Fingerprint 19 | mkdir /data/vendor/misc/qti_fp 0770 system system 20 | mkdir /data/vendor/misc/qti_fp/bg_estimation 0770 system system 21 | mkdir /data/vendor/misc/qti_fp/calib_test 0770 system system 22 | mkdir /data/vendor/misc/qti_fp/database 0770 system system 23 | 24 | on boot 25 | # Fingerprint Permissions 26 | chown system system /dev/goodix_fp 27 | chmod 0644 /dev/goodix_fp 28 | 29 | chown system system /sys/devices/soc/soc:fpc1020/compatible_all 30 | chmod 0664 /sys/devices/soc/soc:fpc1020/compatible_all 31 | chown system system /sys/devices/soc/soc:fpc1020/irq 32 | chmod 0660 /sys/devices/soc/soc:fpc1020/irq 33 | chown system system /sys/devices/soc/soc:fpc1020/hw_reset 34 | chmod 0660 /sys/devices/soc/soc:fpc1020/hw_reset 35 | chown system system /sys/devices/soc/soc:fpc1020/wakeup_enable 36 | chmod 0660 /sys/devices/soc/soc:fpc1020/wakeup_enable 37 | chown system system /sys/devices/soc/soc:fpc1020/wakeup_enable 38 | chmod 0660 /sys/devices/soc/soc:fpc1020/wakeup_enable 39 | 40 | on property:sys.fp.vendor=switchf 41 | stop vendor.gx_fpd 42 | setprop sys.fp.vendor searchf 43 | setprop fpc.fp.miui.token 0 44 | setprop ro.boot.fpsensor fpc 45 | setprop ro.hardware.fingerprint searchf 46 | start vendor.fps_hal 47 | 48 | on property:sys.fp.onstart=1 49 | setprop goodix.fp.miui.analyse 1 50 | setprop goodix.fp.miui.token 0 51 | setprop ro.boot.fpsensor gdx 52 | setprop ro.hardware.fingerprint goodix 53 | start vendor.fps_hal 54 | -------------------------------------------------------------------------------- /biometrics/service.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 | #define LOG_TAG "biometrics.fingerprint@2.1-service.xiaomi_mido" 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "BiometricsFingerprint.h" 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | using android::hardware::biometrics::fingerprint::V2_1::IBiometricsFingerprint; 34 | using android::hardware::biometrics::fingerprint::V2_1::implementation::BiometricsFingerprint; 35 | using android::hardware::configureRpcThreadpool; 36 | using android::hardware::joinRpcThreadpool; 37 | using android::sp; 38 | 39 | bool is_goodix = false; 40 | 41 | static constexpr char kGoodixFpDev[] = "/dev/goodix_fp"; 42 | 43 | int main() { 44 | char vend[PROPERTY_VALUE_MAX]; 45 | property_get("ro.hardware.fingerprint", vend, "none"); 46 | 47 | if (!strcmp(vend, "none")) { 48 | ALOGE("ro.hardware.fingerprint not set! Killing " LOG_TAG " binder service!"); 49 | return 1; 50 | } else if (!strcmp(vend, "goodix")) { 51 | ALOGI("is_goodix = true"); 52 | is_goodix = true; 53 | } 54 | 55 | ALOGI("Start biometrics"); 56 | android::sp bio = BiometricsFingerprint::getInstance(); 57 | 58 | if (is_goodix) { 59 | if (access(kGoodixFpDev, F_OK) != 0) { 60 | ALOGE("Cannot access %s (%s)", kGoodixFpDev, strerror(errno)); 61 | return 1; 62 | } 63 | 64 | // the conventional HAL might start binder services 65 | android::ProcessState::initWithDriver("/dev/binder"); 66 | android::ProcessState::self()->startThreadPool(); 67 | } 68 | 69 | /* process Binder transaction as a single-threaded program. */ 70 | configureRpcThreadpool(1, true /* callerWillJoin */); 71 | 72 | if (bio != nullptr) { 73 | if (::android::OK != bio->registerAsService()) { 74 | return 1; 75 | } 76 | } else { 77 | ALOGE("Can't create instance of BiometricsFingerprint, nullptr"); 78 | } 79 | 80 | joinRpcThreadpool(); 81 | 82 | return 0; // should never get here 83 | } 84 | -------------------------------------------------------------------------------- /camera/Android.mk: -------------------------------------------------------------------------------- 1 | MM_V4L2_DRIVER_LIST += msm8960 2 | MM_V4L2_DRIVER_LIST += msm8974 3 | MM_V4L2_DRIVER_LIST += msm8916 4 | MM_V4L2_DRIVER_LIST += msm8226 5 | MM_V4L2_DRIVER_LIST += msm8610 6 | MM_V4L2_DRIVER_LIST += apq8084 7 | MM_V4L2_DRIVER_LIST += mpq8092 8 | MM_V4L2_DRIVER_LIST += msm_bronze 9 | MM_V4L2_DRIVER_LIST += msm8916 10 | MM_V4L2_DRIVER_LIST += msm8994 11 | MM_V4L2_DRIVER_LIST += msm8084 12 | MM_V4L2_DRIVER_LIST += msm8909 13 | MM_V4L2_DRIVER_LIST += msm8952 14 | MM_V4L2_DRIVER_LIST += msm8996 15 | MM_V4L2_DRIVER_LIST += msm8992 16 | MM_V4L2_DRIVER_LIST += msm8937 17 | MM_V4L2_DRIVER_LIST += msm8953 18 | MM_V4L2_DRIVER_LIST += msmcobalt 19 | MM_V4L2_DRIVER_LIST += msmfalcon 20 | 21 | ifneq (,$(filter $(MM_V4L2_DRIVER_LIST),$(TARGET_BOARD_PLATFORM))) 22 | ifneq ($(strip $(USE_CAMERA_STUB)),true) 23 | ifneq ($(BUILD_TINY_ANDROID),true) 24 | include $(call all-subdir-makefiles) 25 | endif 26 | endif 27 | endif 28 | -------------------------------------------------------------------------------- /camera/CleanSpec.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2007 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 | 16 | # If you don't need to do a full clean build but would like to touch 17 | # a file or delete some intermediate files, add a clean step to the end 18 | # of the list. These steps will only be run once, if they haven't been 19 | # run before. 20 | # 21 | # E.g.: 22 | # $(call add-clean-step, touch -c external/sqlite/sqlite3.h) 23 | # $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) 24 | # 25 | # Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with 26 | # files that are missing or have been moved. 27 | # 28 | # Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. 29 | # Use $(OUT_DIR) to refer to the "out" directory. 30 | # 31 | # If you need to re-do something that's already mentioned, just copy 32 | # the command and add it to the bottom of the list. E.g., if a change 33 | # that you made last week required touching a file and a change you 34 | # made today requires touching the same file, just copy the old 35 | # touch step and add it to the end of the list. 36 | # 37 | # ************************************************ 38 | # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST 39 | # ************************************************ 40 | 41 | # For example: 42 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) 43 | #$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) 44 | #$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) 45 | #$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) 46 | 47 | $(call add-clean-step, find $(OUT_DIR) -name "camera.msm8960*" -print0 | xargs -0 rm -rf) 48 | -------------------------------------------------------------------------------- /camera/MODULE_LICENSE_BSD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LineageOS/android_device_xiaomi_mido/0a68cefc10043b46d8227a7c101ee7462d62f565/camera/MODULE_LICENSE_BSD -------------------------------------------------------------------------------- /camera/QCamera2/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq (,$(filter $(TARGET_ARCH), arm arm64)) 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | 7 | LOCAL_COPY_HEADERS_TO := qcom/camera 8 | LOCAL_COPY_HEADERS := QCameraFormat.h 9 | 10 | LOCAL_SRC_FILES := \ 11 | util/QCameraBufferMaps.cpp \ 12 | util/QCameraCmdThread.cpp \ 13 | util/QCameraFlash.cpp \ 14 | util/QCameraPerf.cpp \ 15 | util/QCameraQueue.cpp \ 16 | util/QCameraCommon.cpp \ 17 | QCamera2Hal.cpp \ 18 | QCamera2Factory.cpp 19 | 20 | #HAL 3.0 source 21 | LOCAL_SRC_FILES += \ 22 | HAL3/QCamera3HWI.cpp \ 23 | HAL3/QCamera3Mem.cpp \ 24 | HAL3/QCamera3Stream.cpp \ 25 | HAL3/QCamera3Channel.cpp \ 26 | HAL3/QCamera3VendorTags.cpp \ 27 | HAL3/QCamera3PostProc.cpp \ 28 | HAL3/QCamera3CropRegionMapper.cpp \ 29 | HAL3/QCamera3StreamMem.cpp 30 | 31 | LOCAL_CFLAGS := -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable 32 | 33 | #HAL 1.0 source 34 | 35 | ifeq ($(TARGET_SUPPORT_HAL1),false) 36 | LOCAL_CFLAGS += -DQCAMERA_HAL3_SUPPORT 37 | else 38 | LOCAL_CFLAGS += -DQCAMERA_HAL1_SUPPORT 39 | LOCAL_SRC_FILES += \ 40 | HAL/QCamera2HWI.cpp \ 41 | HAL/QCameraMuxer.cpp \ 42 | HAL/QCameraMem.cpp \ 43 | HAL/QCameraStateMachine.cpp \ 44 | HAL/QCameraChannel.cpp \ 45 | HAL/QCameraStream.cpp \ 46 | HAL/QCameraPostProc.cpp \ 47 | HAL/QCamera2HWICallbacks.cpp \ 48 | HAL/QCameraParameters.cpp \ 49 | HAL/CameraParameters.cpp \ 50 | HAL/QCameraParametersIntf.cpp \ 51 | HAL/QCameraThermalAdapter.cpp 52 | endif 53 | 54 | # System header file path prefix 55 | LOCAL_CFLAGS += -DSYSTEM_HEADER_PREFIX=sys 56 | 57 | LOCAL_CFLAGS += -DHAS_MULTIMEDIA_HINTS -D_ANDROID 58 | 59 | ifeq ($(TARGET_USES_AOSP),true) 60 | LOCAL_CFLAGS += -DVANILLA_HAL 61 | endif 62 | 63 | ifeq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) <= 23 ))" ))) 64 | LOCAL_CFLAGS += -DUSE_HAL_3_3 65 | endif 66 | 67 | #use media extension 68 | ifeq ($(TARGET_USES_MEDIA_EXTENSIONS), true) 69 | LOCAL_CFLAGS += -DUSE_MEDIA_EXTENSIONS 70 | endif 71 | 72 | LOCAL_CFLAGS += -std=c++11 -std=gnu++0x 73 | #HAL 1.0 Flags 74 | LOCAL_CFLAGS += -DDEFAULT_DENOISE_MODE_ON -DHAL3 -DQCAMERA_REDEFINE_LOG 75 | 76 | LOCAL_C_INCLUDES := \ 77 | $(LOCAL_PATH)/../mm-image-codec/qexif \ 78 | $(LOCAL_PATH)/../mm-image-codec/qomx_core \ 79 | $(LOCAL_PATH)/include \ 80 | $(LOCAL_PATH)/stack/common \ 81 | $(LOCAL_PATH)/stack/mm-camera-interface/inc \ 82 | $(LOCAL_PATH)/util \ 83 | $(LOCAL_PATH)/HAL3 \ 84 | hardware/libhardware/include/hardware \ 85 | $(call project-path-for,qcom-media)/libstagefrighthw \ 86 | $(call project-path-for,qcom-media)/mm-core/inc \ 87 | system/core/include/cutils \ 88 | system/core/include/system \ 89 | system/media/camera/include/system 90 | 91 | #HAL 1.0 Include paths 92 | LOCAL_C_INCLUDES += \ 93 | $(LOCAL_PATH)/HAL 94 | 95 | ifeq ($(TARGET_COMPILE_WITH_MSM_KERNEL),true) 96 | LOCAL_HEADER_LIBRARIES := generated_kernel_headers 97 | endif 98 | ifeq ($(TARGET_TS_MAKEUP),true) 99 | LOCAL_CFLAGS += -DTARGET_TS_MAKEUP 100 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/HAL/tsMakeuplib/include 101 | endif 102 | ifneq (,$(filter msm8974 msm8916 msm8226 msm8610 msm8916 apq8084 msm8084 msm8994 msm8992 msm8952 msm8937 msm8953 msm8996 msmcobalt msmfalcon, $(TARGET_BOARD_PLATFORM))) 103 | LOCAL_CFLAGS += -DVENUS_PRESENT 104 | endif 105 | 106 | ifneq (,$(filter msm8996 msmcobalt msmfalcon,$(TARGET_BOARD_PLATFORM))) 107 | LOCAL_CFLAGS += -DUBWC_PRESENT 108 | endif 109 | 110 | #LOCAL_STATIC_LIBRARIES := libqcamera2_util 111 | LOCAL_C_INCLUDES += \ 112 | $(TARGET_OUT_HEADERS)/qcom/display 113 | LOCAL_C_INCLUDES += \ 114 | $(call project-path-for,qcom-display)/libqservice 115 | LOCAL_SHARED_LIBRARIES := liblog libhardware libutils libcutils libdl libsync 116 | LOCAL_SHARED_LIBRARIES += libmmcamera_interface libmmjpeg_interface libui libcamera_metadata 117 | LOCAL_SHARED_LIBRARIES += libqdMetaData libqservice libbinder 118 | LOCAL_SHARED_LIBRARIES += libcutils libdl 119 | ifeq ($(TARGET_TS_MAKEUP),true) 120 | LOCAL_SHARED_LIBRARIES += libts_face_beautify_hal libts_detected_face_hal 121 | endif 122 | 123 | LOCAL_STATIC_LIBRARIES := android.hardware.camera.common@1.0-helper 124 | 125 | 126 | LOCAL_MODULE_RELATIVE_PATH := hw 127 | LOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM) 128 | LOCAL_VENDOR_MODULE := true 129 | LOCAL_MODULE_TAGS := optional 130 | 131 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 132 | include $(BUILD_SHARED_LIBRARY) 133 | 134 | include $(call first-makefiles-under,$(LOCAL_PATH)) 135 | endif 136 | 137 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL/QCameraAllocator.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA_ALLOCATOR__ 31 | #define __QCAMERA_ALLOCATOR__ 32 | 33 | extern "C" { 34 | #include "mm_camera_interface.h" 35 | } 36 | 37 | namespace qcamera { 38 | 39 | class QCameraMemory; 40 | class QCameraHeapMemory; 41 | 42 | typedef struct { 43 | int32_t (*bgFunction) (void *); 44 | void* bgArgs; 45 | } BackgroundTask; 46 | 47 | class QCameraAllocator { 48 | public: 49 | virtual QCameraMemory *allocateStreamBuf(cam_stream_type_t stream_type, 50 | size_t size, int stride, int scanline, uint8_t &bufferCnt) = 0; 51 | virtual int32_t allocateMoreStreamBuf(QCameraMemory *mem_obj, 52 | size_t size, uint8_t &bufferCnt) = 0; 53 | virtual QCameraHeapMemory *allocateStreamInfoBuf(cam_stream_type_t stream_type) = 0; 54 | virtual QCameraHeapMemory *allocateMiscBuf(cam_stream_info_t *streamInfo) = 0; 55 | virtual QCameraMemory *allocateStreamUserBuf(cam_stream_info_t *streamInfo) = 0; 56 | virtual void waitForDeferredAlloc(cam_stream_type_t stream_type) = 0; 57 | virtual uint32_t scheduleBackgroundTask(BackgroundTask* bgTask) = 0; 58 | virtual int32_t waitForBackgroundTask(uint32_t &taskId) = 0; 59 | virtual ~QCameraAllocator() {} 60 | }; 61 | 62 | }; /* namespace qcamera */ 63 | #endif /* __QCAMERA_ALLOCATOR__ */ 64 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL/QCameraThermalAdapter.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA_THERMAL_ADAPTER__ 31 | #define __QCAMERA_THERMAL_ADAPTER__ 32 | 33 | namespace qcamera { 34 | 35 | typedef enum { 36 | QCAMERA_THERMAL_NO_ADJUSTMENT = 0, 37 | QCAMERA_THERMAL_SLIGHT_ADJUSTMENT, 38 | QCAMERA_THERMAL_BIG_ADJUSTMENT, 39 | QCAMERA_THERMAL_MAX_ADJUSTMENT, 40 | QCAMERA_THERMAL_SHUTDOWN = 10 41 | } qcamera_thermal_level_enum_t; 42 | 43 | typedef enum { 44 | QCAMERA_THERMAL_ADJUST_FPS, 45 | QCAMERA_THERMAL_ADJUST_FRAMESKIP, 46 | } qcamera_thermal_mode; 47 | 48 | class QCameraThermalCallback 49 | { 50 | public: 51 | virtual int thermalEvtHandle(qcamera_thermal_level_enum_t *level, 52 | void *userdata, void *data) = 0; 53 | virtual ~QCameraThermalCallback() {} 54 | qcamera_thermal_level_enum_t *getThermalLevel(); 55 | void setThermalLevel(qcamera_thermal_level_enum_t level); 56 | 57 | private: 58 | qcamera_thermal_level_enum_t mLevel; 59 | }; 60 | 61 | class QCameraThermalAdapter 62 | { 63 | public: 64 | static QCameraThermalAdapter& getInstance(); 65 | 66 | int init(QCameraThermalCallback *thermalCb); 67 | void deinit(); 68 | 69 | private: 70 | static char mStrCamera[]; 71 | static char mStrCamcorder[]; 72 | 73 | static int thermalCallback(int level, void *userdata, void *data); 74 | 75 | QCameraThermalCallback *mCallback; 76 | void *mHandle; 77 | int (*mRegister)(char *name, 78 | int (*callback)(int, void *userdata, void *data), void *data); 79 | int (*mUnregister)(int handle); 80 | int mCameraHandle; 81 | int mCamcorderHandle; 82 | 83 | QCameraThermalAdapter(); 84 | QCameraThermalAdapter(QCameraThermalAdapter const& copy); // not implemented 85 | QCameraThermalAdapter& operator=(QCameraThermalAdapter const& copy); // not implemented 86 | 87 | }; 88 | 89 | }; // namespace qcamera 90 | 91 | #endif /* __QCAMERA_THERMAL_ADAPTER__ */ 92 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL/android/QCamera2External.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA2EXTERNAL_H__ 31 | #define __QCAMERA2EXTERNAL_H__ 32 | 33 | // System dependencies 34 | #include 35 | 36 | // Display dependencies 37 | #include "QServiceUtils.h" 38 | 39 | namespace qcamera { 40 | 41 | inline android::status_t setCameraLaunchStatus(uint32_t on) { 42 | return ::setCameraLaunchStatus(on); 43 | } 44 | 45 | }; // namespace qcamera 46 | 47 | #endif /* __QCAMERA2EXTERNAL_H__ */ 48 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL/test/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_SRC_FILES:= \ 6 | qcamera_test.cpp \ 7 | 8 | LOCAL_SHARED_LIBRARIES:= \ 9 | libdl \ 10 | libui \ 11 | libutils \ 12 | libcutils \ 13 | libbinder \ 14 | libmedia \ 15 | libui \ 16 | libgui \ 17 | libcamera_client \ 18 | libskia \ 19 | libstagefright \ 20 | libstagefright_foundation \ 21 | 22 | ifneq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) >= 18 ))" ))) 23 | 24 | LOCAL_SHARED_LIBRARIES += \ 25 | libmedia_native \ 26 | 27 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 28 | LOCAL_CFLAGS += -DUSE_JB_MR1 29 | 30 | endif 31 | 32 | LOCAL_C_INCLUDES += \ 33 | frameworks/base/include/ui \ 34 | frameworks/base/include/surfaceflinger \ 35 | frameworks/base/include/camera \ 36 | frameworks/base/include/media \ 37 | external/skia/include/core \ 38 | external/skia/include/images \ 39 | $(TARGET_OUT_HEADERS)/qcom/display \ 40 | $(LOCAL_PATH)/../stack/common \ 41 | $(LOCAL_PATH)/../stack/mm-camera-interface/inc \ 42 | frameworks/av/include/media/stagefright \ 43 | frameworks/native/include/media/openmax \ 44 | $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include 45 | 46 | LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 47 | 48 | LOCAL_MODULE:= camera_test 49 | LOCAL_MODULE_TAGS:= tests 50 | LOCAL_VENDOR_MODULE := true 51 | 52 | LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter 53 | LOCAL_CFLAGS += -O0 54 | 55 | ifeq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) >= 20 ))" ))) 56 | 57 | LOCAL_CFLAGS += -DUSE_SDK_20_OR_HIGHER 58 | 59 | ifeq ($(TARGET_USES_AOSP),true) 60 | LOCAL_CFLAGS += -DVANILLA_HAL 61 | endif 62 | 63 | endif 64 | 65 | #include $(BUILD_EXECUTABLE) 66 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL/tsMakeuplib/include/ts_detectface_engine.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014,2015 Thundersoft Corporation 3 | * All rights Reserved 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef __TS_DETECTFACE_ENGINE_H__ 19 | #define __TS_DETECTFACE_ENGINE_H__ 20 | #include "ts_makeup_data.h" 21 | #include "ts_makeup_image.h" 22 | 23 | typedef void* TSHandle; 24 | 25 | /*=========================================================================== 26 | * FUNCTION : ts_detectface_create_context 27 | * 28 | * DESCRIPTION: create context.The method MUST call at first time. 29 | * 30 | * 31 | * RETURN : TSHandle as the context handle 32 | * 33 | *==========================================================================*/ 34 | TSHandle ts_detectface_create_context(); 35 | 36 | 37 | /*=========================================================================== 38 | * FUNCTION : ts_detectface_destroy_context 39 | * 40 | * DESCRIPTION: destroy context. The method MUST call at last time. 41 | * Before you MUST call ts_detectface_create_context method 42 | * to create context and get context handle. 43 | * 44 | * PARAMETERS : 45 | * @param[in] contexTSHandle : The context handle pointer. 46 | * 47 | * 48 | *==========================================================================*/ 49 | void ts_detectface_destroy_context(TSHandle* contexTSHandle); 50 | 51 | 52 | /*=========================================================================== 53 | * FUNCTION : ts_detectface_detect 54 | * 55 | * DESCRIPTION: start detect.Before you MUST call ts_detectface_create_context method 56 | * to create context and get context handle. 57 | * 58 | * PARAMETERS : 59 | * @param[in] contexTSHandle : The context handle. 60 | * @param[in] pInData : The TSMakeupData pointer.MUST not NULL. 61 | * 62 | * RETURN : int If less than zero failed, otherwise the number of the detected faces. 63 | * 64 | *==========================================================================*/ 65 | int ts_detectface_detect(TSHandle contexTSHandle, TSMakeupData *pInData); 66 | 67 | /*=========================================================================== 68 | * FUNCTION : ts_detectface_detectEx 69 | * 70 | * DESCRIPTION: start detect.Before you MUST call ts_detectface_create_context method 71 | * to create context and get context handle. 72 | * 73 | * PARAMETERS : 74 | * @param[in] contexTSHandle : The context handle. 75 | * @param[in] pInData : The TSMakeupDataEx pointer.MUST not NULL. 76 | * 77 | * RETURN : int If less than zero failed, otherwise the number of the detected faces. 78 | * 79 | *==========================================================================*/ 80 | int ts_detectface_detectEx(TSHandle contexTSHandle, TSMakeupDataEx *pInData); 81 | /*=========================================================================== 82 | * FUNCTION : ts_detectface_get_face_info 83 | * 84 | * DESCRIPTION: get detected face information.Before you MUST call ts_detectface_detect method 85 | * to detect face. 86 | * 87 | * PARAMETERS : 88 | * @param[in] contexTSHandle : The context handle. 89 | * @param[in] index : The face index.MUST > 0. 90 | * @param[out] pFaceRect : The face rects.MUST not NULL. 91 | * @param[out] leftEye : The left eye rect. 92 | * @param[out] rightEye : The right eye rect. 93 | * @param[out] pMouth : The mount rect. 94 | * 95 | * RETURN : TS_OK if success, otherwise failed. 96 | * 97 | *==========================================================================*/ 98 | int ts_detectface_get_face_info(TSHandle contexTSHandle, int index, TSRect *pFaceRect, TSRect *leftEye, TSRect *rightEye, TSRect *pMouth); 99 | 100 | #endif // __TS_DETECTFACE_ENGINE_H__ 101 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL/tsMakeuplib/include/ts_makeup_data.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014,2015 Thundersoft Corporation 3 | * All rights Reserved 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef __TS_MAKEUP_DATA_H__ 19 | #define __TS_MAKEUP_DATA_H__ 20 | 21 | #define TS_OK (0x00000000) //Successful 22 | #define TS_ERROR_PARAM (0x00000001) //Parameters error 23 | #define TS_ERROR_IO (0x00000002) //Input or output error 24 | #define TS_ERROR_INTERNAL (0x00000003) //Internal error 25 | #define TS_NO_MEMORY (0x00000004) //No memory error 26 | 27 | 28 | /* 29 | * Data struct : rectangle 30 | */ 31 | typedef struct __tag_tsrect 32 | { 33 | long left; 34 | long top; 35 | long right; 36 | long bottom; 37 | } TSRect; 38 | 39 | /* 40 | * Data struct : point 41 | */ 42 | typedef struct __tag_tsmakeuppoint 43 | { 44 | long x; 45 | long y; 46 | } TSPoint; 47 | 48 | 49 | #endif // __TS_MAKEUP_DATA_H__ 50 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL/tsMakeuplib/include/ts_makeup_engine.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014,2015 Thundersoft Corporation 3 | * All rights Reserved 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef __TS_MAKEUP_ENGINI_H__ 19 | #define __TS_MAKEUP_ENGINI_H__ 20 | #include "ts_makeup_data.h" 21 | #include "ts_makeup_image.h" 22 | 23 | 24 | /* 25 | * FUNCTION : ts_makeup_get_supported_face_num 26 | * 27 | * DESCRIPTION: get supported face number 28 | * 29 | * RETURN : The supported face number 30 | * 31 | */ 32 | int ts_makeup_get_supported_face_num(); 33 | 34 | 35 | /* 36 | * FUNCTION : ts_makeup_skin_beauty 37 | * 38 | * DESCRIPTION: skin beauty method. 39 | * 40 | * PARAMETERS : 41 | * @param[in] pInData : The TSMakeupData pointer.MUST not NULL. 42 | * @param[out] pOutData : The TSMakeupData pointer.MUST not NULL. 43 | * @param[in] pFaceRect : The face rect.MUST not NULL. 44 | * @param[in] cleanLevel : Skin clean level, value range [0,100]. 45 | * @param[in] whiteLevel : Skin white level, value range [0,100]. 46 | * RETURN : TS_OK if success, otherwise failed. 47 | * 48 | */ 49 | int ts_makeup_skin_beauty(TSMakeupData *pInData, TSMakeupData *pOutData, const TSRect *pFaceRect, int cleanLevel,int whiteLevel); 50 | /* 51 | * FUNCTION : ts_makeup_skin_beautyEx 52 | * 53 | * DESCRIPTION: skin beauty method. 54 | * 55 | * PARAMETERS : 56 | * @param[in] pInData : The TSMakeupDataEx pointer.MUST not NULL. 57 | * @param[out] pOutData : The TSMakeupDataEx pointer.MUST not NULL. 58 | * @param[in] pFaceRect : The face rect.MUST not NULL. 59 | * @param[in] cleanLevel : Skin clean level, value range [0,100]. 60 | * @param[in] whiteLevel : Skin white level, value range [0,100]. 61 | * RETURN : TS_OK if success, otherwise failed. 62 | * 63 | */ 64 | int ts_makeup_skin_beautyEx(TSMakeupDataEx *pInData, TSMakeupDataEx *pOutData, const TSRect *pFaceRect, int cleanLevel, int whiteLevel); 65 | /* 66 | * FUNCTION : ts_makeup_finish 67 | * 68 | * DESCRIPTION: Finish makeup,call this method at last time. 69 | * This method MUST be called After ts_makeup_skin_clean and ts_makeup_skin_whiten 70 | * 71 | */ 72 | void ts_makeup_finish(); 73 | 74 | 75 | /* 76 | * FUNCTION : ts_makeup_warp_face 77 | * 78 | * DESCRIPTION: do warp face. 79 | * 80 | * PARAMETERS : 81 | * @param[in] pInData : The TSMakeupData pointer.MUST not NULL. 82 | * @param[out] pOutData : The TSMakeupData pointer.MUST not NULL. 83 | * @param[in] pLeftEye : The left eye rect pointer.MUST not NULL. 84 | * @param[in] pRightEye : The right eye rect pointer.MUST not NULL. 85 | * @param[in] pMouth : The mouth rect pointer.MUST not NULL. 86 | * @param[in] bigEyeLevel : The big eye level, value range [0,100]. 87 | * @param[in] trimFaceLevel : The trim face level, value range [0,100]. 88 | * 89 | * RETURN : TS_OK if success, otherwise failed. 90 | * 91 | */ 92 | int ts_makeup_warp_face(TSMakeupData *pInData, TSMakeupData *pOutData, 93 | const TSRect *pLeftEye, const TSRect *pRightEye, const TSRect *pMouth, int bigEyeLevel, int trimFaceLevel); 94 | 95 | #endif // __TS_MAKEUP_ENGINI_H__ 96 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL/tsMakeuplib/include/ts_makeup_image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014,2015 Thundersoft Corporation 3 | * All rights Reserved 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef __TS_MAKEUP_IMGAGE_H__ 19 | #define __TS_MAKEUP_IMGAGE_H__ 20 | 21 | /* 22 | * Data struct : TSMakeupData 23 | */ 24 | typedef struct __tag_tsmakeupdata 25 | { 26 | int frameWidth; //NV21 Frame width.MUST > 0. 27 | int frameHeight; //NV21 Frame height. MUST > 0. 28 | unsigned char *yBuf; //NV21 Y buffer pointer.MUST not null. 29 | unsigned char *uvBuf; //NV21 UV buffer pointer.MUST not null. 30 | }TSMakeupData; 31 | 32 | /* 33 | * Data struct : TSMakeupDataEx 34 | */ 35 | typedef struct __tag_tsmakeupdataEx 36 | { 37 | int frameWidth; //NV21 Frame width.MUST > 0. 38 | int frameHeight; //NV21 Frame height. MUST > 0. 39 | unsigned char *yBuf; //NV21 Y buffer pointer.MUST not null. 40 | unsigned char *uvBuf; //NV21 UV buffer pointer.MUST not null. 41 | int yStride; //NV21 Y buffer stride len 42 | int uvStride; //NV21 uv buffer stride len 43 | }TSMakeupDataEx; 44 | 45 | 46 | #endif // __TS_MAKEUP_IMGAGE_H__ 47 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL/wrapper/QualcommCamera.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2013, 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef ANDROID_HARDWARE_QUALCOMM_CAMERA_H 31 | #define ANDROID_HARDWARE_QUALCOMM_CAMERA_H 32 | 33 | // Camera dependencies 34 | #include "QCamera2HWI.h" 35 | 36 | extern "C" { 37 | 38 | int get_number_of_cameras(); 39 | int get_camera_info(int camera_id, struct camera_info *info); 40 | 41 | int camera_device_open(const struct hw_module_t* module, const char* id, 42 | struct hw_device_t** device); 43 | 44 | hw_device_t * open_camera_device(int cameraId); 45 | 46 | int close_camera_device( hw_device_t *); 47 | 48 | namespace android { 49 | int set_preview_window(struct camera_device *, 50 | struct preview_stream_ops *window); 51 | void set_CallBacks(struct camera_device *, 52 | camera_notify_callback notify_cb, 53 | camera_data_callback data_cb, 54 | camera_data_timestamp_callback data_cb_timestamp, 55 | camera_request_memory get_memory, 56 | void *user); 57 | 58 | void enable_msg_type(struct camera_device *, int32_t msg_type); 59 | 60 | void disable_msg_type(struct camera_device *, int32_t msg_type); 61 | int msg_type_enabled(struct camera_device *, int32_t msg_type); 62 | 63 | int start_preview(struct camera_device *); 64 | 65 | void stop_preview(struct camera_device *); 66 | 67 | int preview_enabled(struct camera_device *); 68 | int store_meta_data_in_buffers(struct camera_device *, int enable); 69 | 70 | int start_recording(struct camera_device *); 71 | 72 | void stop_recording(struct camera_device *); 73 | 74 | int recording_enabled(struct camera_device *); 75 | 76 | void release_recording_frame(struct camera_device *, 77 | const void *opaque); 78 | 79 | int auto_focus(struct camera_device *); 80 | 81 | int cancel_auto_focus(struct camera_device *); 82 | 83 | int take_picture(struct camera_device *); 84 | 85 | int cancel_picture(struct camera_device *); 86 | 87 | int set_parameters(struct camera_device *, const char *parms); 88 | 89 | char* get_parameters(struct camera_device *); 90 | 91 | void put_parameters(struct camera_device *, char *); 92 | 93 | int send_command(struct camera_device *, 94 | int32_t cmd, int32_t arg1, int32_t arg2); 95 | 96 | void release(struct camera_device *); 97 | 98 | int dump(struct camera_device *, int fd); 99 | 100 | 101 | 102 | }; // namespace android 103 | 104 | } //extern "C" 105 | 106 | #endif 107 | 108 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/QCamera3CropRegionMapper.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA3CROPREGIONMAPPER_H__ 31 | #define __QCAMERA3CROPREGIONMAPPER_H__ 32 | 33 | // System dependencies 34 | #include 35 | 36 | using namespace android; 37 | 38 | namespace qcamera { 39 | 40 | class QCamera3CropRegionMapper { 41 | public: 42 | QCamera3CropRegionMapper(); 43 | virtual ~QCamera3CropRegionMapper(); 44 | 45 | void update(uint32_t active_array_w, uint32_t active_array_h, 46 | uint32_t sensor_w, uint32_t sensor_h); 47 | void toActiveArray(int32_t& crop_left, int32_t& crop_top, 48 | int32_t& crop_width, int32_t& crop_height); 49 | void toSensor(int32_t& crop_left, int32_t& crop_top, 50 | int32_t& crop_width, int32_t& crop_height); 51 | void toActiveArray(uint32_t& x, uint32_t& y); 52 | void toSensor(uint32_t& x, uint32_t& y); 53 | 54 | private: 55 | /* sensor output size */ 56 | int32_t mSensorW, mSensorH; 57 | int32_t mActiveArrayW, mActiveArrayH; 58 | 59 | void boundToSize(int32_t& left, int32_t& top, int32_t& width, 60 | int32_t& height, int32_t bound_w, int32_t bound_h); 61 | }; 62 | 63 | }; // namespace qcamera 64 | 65 | #endif /* __QCAMERA3CROPREGIONMAPPER_H__ */ 66 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/QCamera3HALHeader.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef __QCAMERA_HALHEADER_H__ 30 | #define __QCAMERA_HALHEADER_H__ 31 | 32 | // System dependencies 33 | #include "hardware/gralloc.h" 34 | 35 | // Camera dependencies 36 | #include "cam_types.h" 37 | 38 | using namespace android; 39 | 40 | namespace qcamera { 41 | 42 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) 43 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) 44 | 45 | #define IS_USAGE_ZSL(usage) (((usage) & (GRALLOC_USAGE_HW_CAMERA_ZSL)) \ 46 | == (GRALLOC_USAGE_HW_CAMERA_ZSL)) 47 | 48 | class QCamera3ProcessingChannel; 49 | 50 | typedef enum { 51 | INVALID, 52 | VALID, 53 | } stream_status_t; 54 | 55 | typedef enum { 56 | REPROCESS_TYPE_NONE, 57 | REPROCESS_TYPE_JPEG, 58 | REPROCESS_TYPE_YUV, 59 | REPROCESS_TYPE_PRIVATE, 60 | REPROCESS_TYPE_RAW 61 | } reprocess_type_t; 62 | 63 | typedef struct { 64 | uint32_t out_buf_index; 65 | int32_t jpeg_orientation; 66 | uint8_t jpeg_quality; 67 | uint8_t jpeg_thumb_quality; 68 | cam_dimension_t thumbnail_size; 69 | uint8_t gps_timestamp_valid; 70 | int64_t gps_timestamp; 71 | uint8_t gps_coordinates_valid; 72 | double gps_coordinates[3]; 73 | char gps_processing_method[GPS_PROCESSING_METHOD_SIZE]; 74 | uint8_t image_desc_valid; 75 | char image_desc[EXIF_IMAGE_DESCRIPTION_SIZE]; 76 | } jpeg_settings_t; 77 | 78 | typedef struct { 79 | int32_t iso_speed; 80 | int64_t exposure_time; 81 | } metadata_response_t; 82 | 83 | typedef struct { 84 | cam_stream_type_t stream_type; 85 | cam_format_t stream_format; 86 | cam_dimension_t input_stream_dim; 87 | cam_stream_buf_plane_info_t input_stream_plane_info; 88 | cam_dimension_t output_stream_dim; 89 | cam_padding_info_t *padding; 90 | reprocess_type_t reprocess_type; 91 | QCamera3ProcessingChannel *src_channel; 92 | } reprocess_config_t; 93 | 94 | };//namespace qcamera 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/QCamera3Mem.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA3HWI_MEM_H__ 31 | #define __QCAMERA3HWI_MEM_H__ 32 | 33 | // System dependencies 34 | #include 35 | #include 36 | 37 | // Camera dependencies 38 | #include "hardware/camera3.h" 39 | 40 | extern "C" { 41 | #include "mm_camera_interface.h" 42 | } 43 | 44 | using namespace android; 45 | 46 | namespace qcamera { 47 | 48 | // Base class for all memory types. Abstract. 49 | class QCamera3Memory { 50 | 51 | public: 52 | int cleanCache(uint32_t index) 53 | { 54 | return cacheOps(index, ION_IOC_CLEAN_CACHES); 55 | } 56 | int invalidateCache(uint32_t index) 57 | { 58 | return cacheOps(index, ION_IOC_INV_CACHES); 59 | } 60 | int cleanInvalidateCache(uint32_t index) 61 | { 62 | return cacheOps(index, ION_IOC_CLEAN_INV_CACHES); 63 | } 64 | int getFd(uint32_t index); 65 | ssize_t getSize(uint32_t index); 66 | uint32_t getCnt(); 67 | 68 | virtual int cacheOps(uint32_t index, unsigned int cmd) = 0; 69 | virtual int getMatchBufIndex(void *object) = 0; 70 | virtual void *getPtr(uint32_t index) = 0; 71 | 72 | virtual int32_t markFrameNumber(uint32_t index, uint32_t frameNumber) = 0; 73 | virtual int32_t getFrameNumber(uint32_t index) = 0; 74 | virtual int32_t getBufferIndex(uint32_t frameNumber) = 0; 75 | 76 | QCamera3Memory(); 77 | virtual ~QCamera3Memory(); 78 | 79 | int32_t getBufDef(const cam_frame_len_offset_t &offset, 80 | mm_camera_buf_def_t &bufDef, uint32_t index); 81 | 82 | protected: 83 | struct QCamera3MemInfo { 84 | int fd; 85 | int main_ion_fd; 86 | ion_user_handle_t handle; 87 | size_t size; 88 | }; 89 | 90 | int cacheOpsInternal(uint32_t index, unsigned int cmd, void *vaddr); 91 | virtual void *getPtrLocked(uint32_t index) = 0; 92 | 93 | uint32_t mBufferCount; 94 | struct QCamera3MemInfo mMemInfo[MM_CAMERA_MAX_NUM_FRAMES]; 95 | void *mPtr[MM_CAMERA_MAX_NUM_FRAMES]; 96 | int32_t mCurrentFrameNumbers[MM_CAMERA_MAX_NUM_FRAMES]; 97 | Mutex mLock; 98 | }; 99 | 100 | // Internal heap memory is used for memories used internally 101 | // They are allocated from /dev/ion. Examples are: capabilities, 102 | // parameters, metadata, and internal YUV data for jpeg encoding. 103 | class QCamera3HeapMemory : public QCamera3Memory { 104 | public: 105 | QCamera3HeapMemory(uint32_t maxCnt); 106 | virtual ~QCamera3HeapMemory(); 107 | 108 | int allocate(size_t size); 109 | int allocateOne(size_t size); 110 | void deallocate(); 111 | 112 | virtual int cacheOps(uint32_t index, unsigned int cmd); 113 | virtual int getMatchBufIndex(void *object); 114 | virtual void *getPtr(uint32_t index); 115 | 116 | virtual int32_t markFrameNumber(uint32_t index, uint32_t frameNumber); 117 | virtual int32_t getFrameNumber(uint32_t index); 118 | virtual int32_t getBufferIndex(uint32_t frameNumber); 119 | 120 | protected: 121 | virtual void *getPtrLocked(uint32_t index); 122 | private: 123 | int allocOneBuffer(struct QCamera3MemInfo &memInfo, 124 | unsigned int heap_id, size_t size); 125 | void deallocOneBuffer(struct QCamera3MemInfo &memInfo); 126 | uint32_t mMaxCnt; 127 | }; 128 | 129 | // Gralloc Memory shared with frameworks 130 | class QCamera3GrallocMemory : public QCamera3Memory { 131 | public: 132 | QCamera3GrallocMemory(uint32_t startIdx); 133 | virtual ~QCamera3GrallocMemory(); 134 | 135 | int registerBuffer(buffer_handle_t *buffer, cam_stream_type_t type); 136 | int32_t unregisterBuffer(size_t idx); 137 | void unregisterBuffers(); 138 | virtual int cacheOps(uint32_t index, unsigned int cmd); 139 | virtual int getMatchBufIndex(void *object); 140 | virtual void *getPtr(uint32_t index); 141 | 142 | virtual int32_t markFrameNumber(uint32_t index, uint32_t frameNumber); 143 | virtual int32_t getFrameNumber(uint32_t index); 144 | virtual int32_t getBufferIndex(uint32_t frameNumber); 145 | 146 | void *getBufferHandle(uint32_t index); 147 | protected: 148 | virtual void *getPtrLocked(uint32_t index); 149 | private: 150 | int32_t unregisterBufferLocked(size_t idx); 151 | int32_t getFreeIndexLocked(); 152 | buffer_handle_t *mBufferHandle[MM_CAMERA_MAX_NUM_FRAMES]; 153 | struct private_handle_t *mPrivateHandle[MM_CAMERA_MAX_NUM_FRAMES]; 154 | 155 | uint32_t mStartIdx; 156 | }; 157 | }; 158 | #endif 159 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/QCamera3StreamMem.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA3_STREAMMEM_H__ 31 | #define __QCAMERA3_STREAMMEM_H__ 32 | 33 | // System dependencies 34 | #include 35 | 36 | // Camera dependencies 37 | #include "QCamera3Mem.h" 38 | 39 | extern "C" { 40 | #include "mm_camera_interface.h" 41 | } 42 | 43 | using namespace android; 44 | 45 | namespace qcamera { 46 | 47 | class QCamera3StreamMem { 48 | public: 49 | QCamera3StreamMem(uint32_t maxHeapBuffer, bool queueAll = true); 50 | virtual ~QCamera3StreamMem(); 51 | 52 | uint32_t getCnt(); 53 | int getRegFlags(uint8_t *regFlags); 54 | 55 | // Helper function to access individual QCamera3Buffer object 56 | int getFd(uint32_t index); 57 | ssize_t getSize(uint32_t index); 58 | int invalidateCache(uint32_t index); 59 | int cleanInvalidateCache(uint32_t index); 60 | int32_t getBufDef(const cam_frame_len_offset_t &offset, 61 | mm_camera_buf_def_t &bufDef, uint32_t index); 62 | void *getPtr(uint32_t index); 63 | 64 | bool valid(uint32_t index); 65 | 66 | // Gralloc buffer related functions 67 | int registerBuffer(buffer_handle_t *buffer, cam_stream_type_t type); 68 | int unregisterBuffer(uint32_t index); 69 | int getMatchBufIndex(void *object); 70 | void *getBufferHandle(uint32_t index); 71 | void unregisterBuffers(); //TODO: relace with unififed clear() function? 72 | 73 | // Heap buffer related functions 74 | int allocateAll(size_t size); 75 | int allocateOne(size_t size); 76 | void deallocate(); //TODO: replace with unified clear() function? 77 | 78 | // Clear function: unregister for gralloc buffer, and deallocate for heap buffer 79 | void clear() {unregisterBuffers(); deallocate(); } 80 | 81 | // Frame number getter and setter 82 | int32_t markFrameNumber(uint32_t index, uint32_t frameNumber); 83 | int32_t getFrameNumber(uint32_t index); 84 | int32_t getGrallocBufferIndex(uint32_t frameNumber); 85 | int32_t getHeapBufferIndex(uint32_t frameNumber); 86 | 87 | private: 88 | //variables 89 | QCamera3HeapMemory mHeapMem; 90 | QCamera3GrallocMemory mGrallocMem; 91 | uint32_t mMaxHeapBuffers; 92 | Mutex mLock; 93 | bool mQueueHeapBuffers; 94 | }; 95 | 96 | }; 97 | #endif // __QCAMERA3_STREAMMEM_H__ 98 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/android/QCamera3External.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA3EXTERNAL_H__ 31 | #define __QCAMERA3EXTERNAL_H__ 32 | 33 | // System dependencies 34 | #include 35 | 36 | // Display dependencies 37 | #include "QServiceUtils.h" 38 | 39 | namespace qcamera { 40 | 41 | inline android::status_t setCameraLaunchStatus(uint32_t on) { 42 | return ::setCameraLaunchStatus(on); 43 | } 44 | 45 | }; // namespace qcamera 46 | 47 | #endif /* __QCAMERA3EXTERNAL_H__ */ 48 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/test/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:=$(call my-dir) 2 | 3 | # Build command line test app: mm-hal3-app 4 | include $(CLEAR_VARS) 5 | 6 | ifeq ($(TARGET_SUPPORT_HAL1),false) 7 | LOCAL_CFLAGS += -DQCAMERA_HAL3_SUPPORT 8 | endif 9 | 10 | ifeq ($(TARGET_BOARD_PLATFORM),msm8953) 11 | LOCAL_CFLAGS += -DCAMERA_CHIPSET_8953 12 | else 13 | LOCAL_CFLAGS += -DCAMERA_CHIPSET_8937 14 | endif 15 | 16 | LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include 17 | LOCAL_C_INCLUDES+= $(kernel_includes) 18 | 19 | LOCAL_C_INCLUDES += \ 20 | hardware/libhardware/include/hardware \ 21 | system/media/camera/include \ 22 | system/media/private/camera/include \ 23 | $(LOCAL_PATH)/../ \ 24 | $(LOCAL_PATH)/../../stack/mm-camera-interface/inc \ 25 | 26 | 27 | LOCAL_SRC_FILES := \ 28 | QCameraHAL3Base.cpp \ 29 | QCameraHAL3MainTestContext.cpp \ 30 | QCameraHAL3VideoTest.cpp \ 31 | QCameraHAL3PreviewTest.cpp \ 32 | QCameraHAL3SnapshotTest.cpp \ 33 | QCameraHAL3RawSnapshotTest.cpp \ 34 | QCameraHAL3Test.cpp 35 | 36 | 37 | LOCAL_SHARED_LIBRARIES:= libutils libcamera_client liblog libcamera_metadata libcutils 38 | 39 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 40 | 41 | LOCAL_MODULE:= hal3-test-app 42 | LOCAL_VENDOR_MODULE := true 43 | 44 | LOCAL_CFLAGS += -Wall -Wextra 45 | 46 | LOCAL_CFLAGS += -std=c++11 -std=gnu++0x 47 | 48 | include $(BUILD_EXECUTABLE) 49 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/test/QCameraHAL3Base.h: -------------------------------------------------------------------------------- 1 | /*Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef __HAL3APP_H__ 30 | #define __HAL3APP_H__ 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | extern "C" { 48 | #include "mm_camera_dbg.h" 49 | } 50 | 51 | #define HAL3_DATASPACE_UNKNOWN 0x0 52 | #define HAL3_DATASPACE_ARBITRARY 0x1 53 | #define HAL3_DATASPACE_JFIF 0x101 54 | #define FLAGS_VIDEO_ENCODER 0x00010000 55 | 56 | #define PREVIEW_WIDTH 1440 57 | #define PREVIEW_HEIGHT 1080 58 | 59 | #define VIDEO_WIDTH 1920 60 | #define VIDEO_HEIGHT 1080 61 | 62 | #define SNAPSHOT_CAPTURE_WIDTH 5344 63 | #define SNAPSHOT_CAPTURE_HEIGHT 4008 64 | 65 | #define RAWSNAPSHOT_CAPTURE_WIDTH 5344 66 | #define RAWSNAPSHOT_CAPTURE_HEIGHT 4016 67 | 68 | namespace qcamera { 69 | 70 | typedef enum { 71 | HAL3_CAM_OK, 72 | HAL3_CAM_E_GENERAL, 73 | HAL3_CAM_E_NO_MEMORY, 74 | HAL3_CAM_E_NOT_SUPPORTED, 75 | HAL3_CAM_E_INVALID_INPUT, 76 | HAL3_CAM_E_INVALID_OPERATION, 77 | HAL3_CAM_E_ENCODE, 78 | HAL3_CAM_E_BUFFER_REG, 79 | HAL3_CAM_E_PMEM_ALLOC, 80 | HAL3_CAM_E_CAPTURE_FAILED, 81 | HAL3_CAM_E_CAPTURE_TIMEOUT, 82 | } hal3_camera_status_type_t; 83 | 84 | typedef enum { 85 | PROCESS_BUFFER, 86 | } buffer_thread_msg_type_t; 87 | 88 | typedef struct { 89 | camera3_device_t *device; 90 | camera3_callback_ops callback_ops; 91 | struct camera_info cam_info; 92 | camera_module_callbacks_t module_cb; 93 | } hal3_camera_test_obj_t; 94 | 95 | typedef struct { 96 | int fd; 97 | int ion_fd; 98 | ion_user_handle_t ion_handle; 99 | size_t size; 100 | } hal3_camtest_meminfo_t; 101 | 102 | typedef struct { 103 | buffer_thread_msg_type_t msg; 104 | bool stop_thread; 105 | } buffer_thread_msg_t; 106 | 107 | typedef struct { 108 | void *ptr; 109 | camera_module_t* halModule_t; 110 | } hal3_interface_lib_t; 111 | 112 | typedef struct { 113 | uint8_t num_cameras; 114 | vendor_tag_ops_t mVendorTagOps; 115 | hal3_interface_lib_t hal3_lib; 116 | } hal3_camera_app_t; 117 | 118 | typedef struct { 119 | hal3_camera_app_t app_obj; 120 | hal3_camera_test_obj_t test_obj; 121 | } hal3_camera_lib_test; 122 | 123 | typedef struct { 124 | pthread_t td; 125 | pthread_mutex_t mutex; 126 | pthread_cond_t cond; 127 | int32_t readfd; 128 | int32_t writefd; 129 | void *data_obj; 130 | bool is_thread_started; 131 | int testcase; 132 | } buffer_thread_t; 133 | 134 | extern int32_t pfd[2]; 135 | typedef hal3_camera_lib_test hal3_camera_lib_handle; 136 | 137 | class CameraHAL3Base 138 | { 139 | friend class MainTestContext; 140 | protected: 141 | int mCameraIndex; 142 | public: 143 | CameraHAL3Base(); 144 | CameraHAL3Base(int cameraIndex); 145 | hal3_camera_lib_test *mLibHandle; 146 | int mFrameCount; 147 | int fps; 148 | int mSecElapsed; 149 | int mTestCaseSelected; 150 | int mPreviewRunning; 151 | int mVideoRunning; 152 | int mSnapShotRunning; 153 | 154 | int hal3appCamInitialize(int camid, hal3_camera_test_obj_t *my_test_obj); 155 | void hal3appCamCapabilityGet(hal3_camera_lib_test *handle,int camid); 156 | int hal3appCameraLibOpen(int ); 157 | int hal3appTestLoad(hal3_camera_app_t *); 158 | int hal3appCamOpen(hal3_camera_app_t *, 159 | int, 160 | hal3_camera_test_obj_t *); 161 | int hal3appCameraPreviewInit(int, int, int, int); 162 | int hal3appCameraVideoInit(int, int camid, int w, int h); 163 | int hal3appCameraCaptureInit(hal3_camera_lib_test *, int, int); 164 | int hal3appRawCaptureInit(hal3_camera_lib_test *handle, int camid, int ); 165 | int hal3appCameraTestLoad(); 166 | void hal3appCheckStream(int testcase, int camid); 167 | }; 168 | 169 | } 170 | #endif -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/test/QCameraHAL3MainTestContext.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef __HAL3TEST_H__ 30 | #define __HAL3TEST_H__ 31 | 32 | #include 33 | #include 34 | #include 35 | namespace qcamera { 36 | 37 | 38 | typedef enum 39 | { 40 | MENU_BASE = 0, 41 | MENU_START_PREVIEW, 42 | MENU_START_VIDEO, 43 | MENU_START_CAPTURE, 44 | MENU_START_RAW_CAPTURE, 45 | MENU_EXIT 46 | } menu_id; 47 | 48 | typedef struct { 49 | menu_id base_menu; 50 | char * basemenu_name; 51 | } HAL3TEST_BASE_MENU_TBL_T; 52 | 53 | typedef struct { 54 | char * menu_name; 55 | } HAL3TEST_SENSOR_MENU_TBL_T; 56 | 57 | typedef struct { 58 | menu_id main_menu; 59 | char * menu_name; 60 | } CAMERA_BASE_MENU_TBL_T; 61 | 62 | class CameraHAL3Base; 63 | class MainTestContext 64 | { 65 | int choice; 66 | bool mTestRunning; 67 | public: 68 | MainTestContext(); 69 | int hal3appGetUserEvent(); 70 | int hal3appDisplaySensorMenu(uint8_t ); 71 | void hal3appDisplayCapabilityMenu(); 72 | int hal3appDisplayPreviewMenu(); 73 | int hal3appDisplayVideoMenu(); 74 | void hal3appDisplayRawCaptureMenu(); 75 | void hal3appDisplaySnapshotMenu(); 76 | void hal3appDisplayExitMenu(); 77 | int hal3appPrintMenu(); 78 | }; 79 | 80 | } 81 | 82 | #endif -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/test/QCameraHAL3PreviewTest.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef __HAL3APPPREVIEWTEST_H__ 30 | #define __HAL3APPPREVIEWTEST_H__ 31 | 32 | #include "QCameraHAL3Base.h" 33 | #include "QCameraHAL3Test.h" 34 | 35 | namespace qcamera { 36 | 37 | class QCameraHAL3PreviewTest : public QCameraHAL3Test 38 | { 39 | private: 40 | hal3_camtest_meminfo_t mPreviewMeminfo; 41 | native_handle_t **mPreviewHandle; 42 | hal3_camtest_meminfo_t mCaptureMemInfo; 43 | native_handle_t *mCaptureHandle; 44 | const camera_metadata_t *mMetaDataPtr[3]; 45 | camera3_stream_t *mPreviewStream; 46 | camera3_stream_t *mSnapshotStream; 47 | camera3_capture_request mRequest; 48 | camera3_stream_buffer_t mPreviewStreamBuffs; 49 | camera3_stream_buffer_t mSnapshotStreamBuffs; 50 | camera3_stream_configuration mPreviewConfig; 51 | public: 52 | int width; 53 | int height; 54 | int nobuffer; 55 | int mPipelineDepthPreview; 56 | 57 | QCameraHAL3PreviewTest(int cameraIndex); 58 | void configurePreviewStream(hal3_camera_test_obj_t *my_test_obj, int camid, 59 | int w, int h); 60 | 61 | void snapshotCaptureRequest(hal3_camera_lib_test *handle, 62 | int testcase, int camid, int w, int h); 63 | void constructDefaultRequest(hal3_camera_test_obj_t *, int); 64 | void initTest(hal3_camera_lib_test *handle, 65 | int testcase, int camid, int w, int h); 66 | 67 | void captureRequestRepeat(hal3_camera_lib_test *, int, int); 68 | void previewAllocateBuffers(int, 69 | int, int); 70 | bool previewProcessThreadCreate(hal3_camera_lib_test *); 71 | void previewTestEnd(hal3_camera_lib_test *my_hal3test_obj, int camid); 72 | void snapshotAllocateBuffers(int, int ); 73 | virtual ~QCameraHAL3PreviewTest(); 74 | }; 75 | 76 | void * hal3appPreviewProcessBuffers(void *); 77 | } 78 | #endif -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/test/QCameraHAL3RawSnapshotTest.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __HAL3APPRAWSNAPSHOT_H__ 31 | #define __HAL3APPRAWSNAPSHOT_H__ 32 | 33 | #include "QCameraHAL3SnapshotTest.h" 34 | 35 | namespace qcamera 36 | { 37 | class QCameraHAL3RawSnapshotTest : public QCameraHAL3Test 38 | { 39 | private: 40 | hal3_camtest_meminfo_t mRawCaptureMemInfo; 41 | native_handle_t *mRawCaptureHandle; 42 | const camera_metadata_t *mMetaDataPtr[3]; 43 | camera3_stream_t *mPreviewStream; 44 | camera3_stream_t *mRawSnapshotStream; 45 | camera3_capture_request mRequest; 46 | camera3_stream_buffer_t mRawSnapshotStreamBuffs; 47 | camera3_stream_configuration mRawSnapshotConfig; 48 | public: 49 | int mRequestedCapture; 50 | QCameraHAL3RawSnapshotTest(int req_cap); 51 | void constructDefaultRequest(hal3_camera_test_obj_t *my_test_obj, 52 | int camid); 53 | void configureRawSnapshotStream(hal3_camera_test_obj_t *my_test_obj, 54 | int camid, int, int ); 55 | void rawProcessCaptureRequest(hal3_camera_test_obj_t *my_test_obj, 56 | int camid); 57 | void rawProcessCaptureRequestRepeat(hal3_camera_lib_test *my_hal3test_obj, 58 | int camid); 59 | void initTest(hal3_camera_lib_test *handle, int testcase, int, int, int); 60 | bool rawProcessThreadCreate(int testcase_id, 61 | void *(*hal3_thread_ops)(void *)); 62 | void rawAllocateBuffers(int height, int width); 63 | void rawTestEnd(hal3_camera_lib_test *my_hal3test_obj, int camid); 64 | void captureRequestRepeat(hal3_camera_lib_test *my_hal3test_obj, int camid, int testcase); 65 | virtual ~QCameraHAL3RawSnapshotTest(); 66 | }; 67 | void * rawProcessBuffers(void *data); 68 | } 69 | #endif 70 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/test/QCameraHAL3SnapshotTest.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef __HAL3APPSNAPSHOT_H__ 30 | #define __HAL3APPSNAPSHOT_H__ 31 | 32 | #include "QCameraHAL3VideoTest.h" 33 | 34 | namespace qcamera 35 | { 36 | class QCameraHAL3SnapshotTest : public QCameraHAL3Test 37 | { 38 | private: 39 | hal3_camtest_meminfo_t mCaptureMemInfo; 40 | native_handle_t *mCaptureHandle; 41 | const camera_metadata_t *mMetaDataPtr[3]; 42 | camera3_stream_t *mPreviewStream; 43 | camera3_stream_t *mSnapshotStream; 44 | camera3_capture_request mRequest; 45 | camera3_stream_buffer_t mSnapshotStreamBuffs; 46 | camera3_stream_configuration mSnapshotConfig; 47 | public: 48 | int mRequestedCapture; 49 | QCameraHAL3SnapshotTest(int req_cap); 50 | void constructDefaultRequest(hal3_camera_test_obj_t *, int ); 51 | void configureSnapshotStream(hal3_camera_test_obj_t *, int, 52 | int w, int h); 53 | void snapshotProcessCaptureRequest(hal3_camera_test_obj_t *my_test_obj, 54 | int camid); 55 | void snapshotAllocateBuffers(int, int ); 56 | void initTest(hal3_camera_lib_test *my_test_obj, 57 | int testcase, int camid, int w, int h); 58 | bool snapshotThreadCreate(int testcase_id, void * (*hal3_thread_ops)(void *)); 59 | void snapshotProcessCaptureRequestRepeat(hal3_camera_lib_test *my_hal3test_obj, 60 | int camid); 61 | void captureRequestRepeat(hal3_camera_lib_test *my_hal3test_obj, int camid, int testcase); 62 | void snapshotTestEnd(hal3_camera_lib_test *my_hal3test_obj, int camid); 63 | virtual ~QCameraHAL3SnapshotTest(); 64 | }; 65 | 66 | void * hal3appSnapshotProcessBuffers(void *data); 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/test/QCameraHAL3Test.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef __HAL3APPTESTINIT_H__ 30 | #define __HAL3APPTESTINIT_H__ 31 | 32 | #include "QCameraHAL3MainTestContext.h" 33 | #include "QCameraHAL3Base.h" 34 | 35 | namespace qcamera { 36 | 37 | class QCameraHAL3Test 38 | { 39 | int mCamId; 40 | public: 41 | QCameraHAL3Test(int cameraIndex); 42 | camera3_stream_t *requested_stream; 43 | camera3_stream_t *initStream(int streamtype, 44 | int camid, int w, int h, int format,int usage,int dataspace); 45 | 46 | camera3_stream_configuration configureStream( 47 | int opmode, int num_streams); 48 | virtual void captureRequestRepeat(hal3_camera_lib_test *, int, int); 49 | camera_metadata_t* hal3appGetDefaultRequest(int type); 50 | 51 | camera3_capture_request hal3appGetRequestSettings( 52 | camera3_stream_buffer_t *stream_buffs, int num_buffer); 53 | camera3_stream_buffer_t hal3appGetStreamBuffs(camera3_stream_t *req_stream); 54 | 55 | native_handle_t *allocateBuffers(int width, int height, 56 | hal3_camtest_meminfo_t *req_meminfo); 57 | bool processThreadCreate(void *obj, int testcase); 58 | virtual ~QCameraHAL3Test(); 59 | }; 60 | 61 | void * processBuffers(void *data); 62 | } 63 | #endif -------------------------------------------------------------------------------- /camera/QCamera2/HAL3/test/QCameraHAL3VideoTest.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | #ifndef __HAL3APPVIDEOTEST_H__ 30 | #define __HAL3APPVIDEOTEST_H__ 31 | 32 | #include "QCameraHAL3Base.h" 33 | #include "QCameraHAL3Test.h" 34 | 35 | 36 | namespace qcamera { 37 | 38 | 39 | class QCameraHAL3VideoTest : public QCameraHAL3Test 40 | { 41 | 42 | private: 43 | hal3_camtest_meminfo_t mVideoMeminfo; 44 | native_handle_t **mVideoHandle; 45 | hal3_camtest_meminfo_t mCaptureMemInfo; 46 | native_handle_t *mCaptureHandle; 47 | const camera_metadata_t *mMetaDataPtr[3]; 48 | camera3_stream_t *mVideoStream; 49 | camera3_stream_t *mSnapshotStream; 50 | camera3_capture_request mRequest; 51 | camera3_stream_buffer_t mVideoStreamBuffs; 52 | camera3_stream_buffer_t mSnapshotStreamBuffs; 53 | camera3_stream_configuration mVideoConfig; 54 | public: 55 | int width; 56 | int height; 57 | int nobuffer; 58 | int mPipelineDepthVideo; 59 | 60 | QCameraHAL3VideoTest(int cameraIndex); 61 | 62 | void configureVideoStream(hal3_camera_test_obj_t *, 63 | int, int, int); 64 | void snapshotCaptureRequest(hal3_camera_lib_test *handle,int testcase, 65 | int camid, int w, int h); 66 | 67 | void constructDefaultRequest(hal3_camera_test_obj_t *, 68 | int); 69 | 70 | void captureRequestRepeat(hal3_camera_lib_test *, int, int); 71 | void initTest(hal3_camera_lib_test *handle, int testcase, int camid, 72 | int w, int h); 73 | void vidoeAllocateBuffers(int, int, int); 74 | 75 | bool videoProcessThreadCreate(hal3_camera_lib_test *); 76 | void videoTestEnd(hal3_camera_lib_test *my_hal3test_obj, int camid); 77 | void snapshotAllocateBuffers(int, int ); 78 | virtual ~QCameraHAL3VideoTest(); 79 | }; 80 | 81 | void * hal3appVideoProcessBuffers(void *); 82 | } 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /camera/QCamera2/QCamera2Factory.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA2FACTORY_H__ 31 | #define __QCAMERA2FACTORY_H__ 32 | 33 | // Camera dependencies 34 | #include "hardware/camera_common.h" 35 | 36 | namespace qcamera { 37 | 38 | typedef struct { 39 | uint32_t cameraId; 40 | uint32_t device_version; 41 | } hal_desc; 42 | 43 | class QCamera2Factory 44 | { 45 | public: 46 | QCamera2Factory(); 47 | virtual ~QCamera2Factory(); 48 | 49 | static int get_number_of_cameras(); 50 | static int get_camera_info(int camera_id, struct camera_info *info); 51 | static int set_callbacks(const camera_module_callbacks_t *callbacks); 52 | static int open_legacy(const struct hw_module_t* module, 53 | const char* id, uint32_t halVersion, struct hw_device_t** device); 54 | static int set_torch_mode(const char* camera_id, bool on); 55 | bool isDualCamAvailable(int hal3Enabled); 56 | 57 | private: 58 | int getNumberOfCameras(); 59 | int getCameraInfo(int camera_id, struct camera_info *info); 60 | int setCallbacks(const camera_module_callbacks_t *callbacks); 61 | int cameraDeviceOpen(int camera_id, struct hw_device_t **hw_device); 62 | static int camera_device_open(const struct hw_module_t *module, const char *id, 63 | struct hw_device_t **hw_device); 64 | static int openLegacy( 65 | int32_t cameraId, uint32_t halVersion, struct hw_device_t** hw_device); 66 | int setTorchMode(const char* camera_id, bool on); 67 | public: 68 | static struct hw_module_methods_t mModuleMethods; 69 | 70 | private: 71 | int mNumOfCameras; 72 | hal_desc *mHalDescriptors; 73 | const camera_module_callbacks_t *mCallbacks; 74 | }; 75 | 76 | }; /*namespace qcamera*/ 77 | 78 | extern camera_module_t HAL_MODULE_INFO_SYM; 79 | 80 | #endif /* __QCAMERA2FACTORY_H__ */ 81 | -------------------------------------------------------------------------------- /camera/QCamera2/QCamera2Hal.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | // Camera dependencies 31 | #include "QCamera2Factory.h" 32 | #include "HAL3/QCamera3VendorTags.h" 33 | 34 | static hw_module_t camera_common = { 35 | .tag = HARDWARE_MODULE_TAG, 36 | .module_api_version = CAMERA_MODULE_API_VERSION_2_4, 37 | .hal_api_version = HARDWARE_HAL_API_VERSION, 38 | .id = CAMERA_HARDWARE_MODULE_ID, 39 | .name = "QCamera Module", 40 | .author = "Qualcomm Innovation Center Inc", 41 | .methods = &qcamera::QCamera2Factory::mModuleMethods, 42 | .dso = NULL, 43 | .reserved = {0} 44 | }; 45 | 46 | camera_module_t HAL_MODULE_INFO_SYM = { 47 | .common = camera_common, 48 | .get_number_of_cameras = qcamera::QCamera2Factory::get_number_of_cameras, 49 | .get_camera_info = qcamera::QCamera2Factory::get_camera_info, 50 | .set_callbacks = qcamera::QCamera2Factory::set_callbacks, 51 | .get_vendor_tag_ops = qcamera::QCamera3VendorTags::get_vendor_tag_ops, 52 | .open_legacy = qcamera::QCamera2Factory::open_legacy, 53 | .set_torch_mode = qcamera::QCamera2Factory::set_torch_mode, 54 | .init = NULL, 55 | .reserved = {0} 56 | }; 57 | -------------------------------------------------------------------------------- /camera/QCamera2/QCameraFormat.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | 31 | /* Macros exposed to gralloc to query camera HAL for gralloc format to be 32 | used for vedor specific camera formats. */ 33 | 34 | #define PREFERRED_IMPLEMENTATION_DEFINED_CAMERA_FORMAT HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS 35 | #define PREFERRED_YCBCR_420_888_CAMERA_FORMAT HAL_PIXEL_FORMAT_NV21_ZSL 36 | 37 | /* Macros exposed to camera HAL to get the preview and callback stream 38 | formats. Please ensure that if the macros below are changed then the 39 | corresponding change should be done in the above macros and vice versa 40 | to prevent format mismatch between Gralloc and Camera HAL for stream 41 | buffers */ 42 | 43 | #define PREVIEW_STREAM_FORMAT CAM_FORMAT_YUV_420_NV12_VENUS 44 | #define CALLBACK_STREAM_FORMAT CAM_FORMAT_YUV_420_NV21 45 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(LOCAL_PATH)/mm-camera-interface/Android.mk 3 | include $(LOCAL_PATH)/mm-jpeg-interface/Android.mk 4 | include $(LOCAL_PATH)/mm-jpeg-interface/test/Android.mk 5 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/common/cam_intf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LineageOS/android_device_xiaomi_mido/0a68cefc10043b46d8227a7c101ee7462d62f565/camera/QCamera2/stack/common/cam_intf.h -------------------------------------------------------------------------------- /camera/QCamera2/stack/common/cam_list.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | /* This file is a slave copy from /vendor/qcom/propreitary/mm-cammera/common, 31 | * Please do not modify it directly here. */ 32 | 33 | #ifndef __CAMLIST_H 34 | #define __CAMLIST_H 35 | 36 | #include 37 | // System dependency 38 | #include 39 | 40 | #define member_of(ptr, type, member) ({ \ 41 | const typeof(((type *)0)->member) *__mptr = (ptr); \ 42 | (type *)((char *)__mptr - offsetof(type,member));}) 43 | 44 | struct cam_list { 45 | struct cam_list *next, *prev; 46 | }; 47 | 48 | static inline void cam_list_init(struct cam_list *ptr) 49 | { 50 | ptr->next = ptr; 51 | ptr->prev = ptr; 52 | } 53 | 54 | static inline void cam_list_add_tail_node(struct cam_list *item, 55 | struct cam_list *head) 56 | { 57 | struct cam_list *prev = head->prev; 58 | 59 | head->prev = item; 60 | item->next = head; 61 | item->prev = prev; 62 | prev->next = item; 63 | } 64 | 65 | static inline void cam_list_insert_before_node(struct cam_list *item, 66 | struct cam_list *node) 67 | { 68 | item->next = node; 69 | item->prev = node->prev; 70 | item->prev->next = item; 71 | node->prev = item; 72 | } 73 | 74 | static inline void cam_list_del_node(struct cam_list *ptr) 75 | { 76 | struct cam_list *prev = ptr->prev; 77 | struct cam_list *next = ptr->next; 78 | 79 | next->prev = ptr->prev; 80 | prev->next = ptr->next; 81 | ptr->next = ptr; 82 | ptr->prev = ptr; 83 | } 84 | 85 | #endif /* __CAMLIST_H */ 86 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/common/cam_queue.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | // System dependencies 31 | #include 32 | 33 | // Camera dependencies 34 | #include "cam_list.h" 35 | 36 | typedef struct { 37 | struct cam_list list; 38 | void *data; 39 | } cam_node_t; 40 | 41 | typedef struct { 42 | cam_node_t head; /* dummy head */ 43 | uint32_t size; 44 | pthread_mutex_t lock; 45 | } cam_queue_t; 46 | 47 | static inline int32_t cam_queue_init(cam_queue_t *queue) 48 | { 49 | pthread_mutex_init(&queue->lock, NULL); 50 | cam_list_init(&queue->head.list); 51 | queue->size = 0; 52 | return 0; 53 | } 54 | 55 | static inline int32_t cam_queue_enq(cam_queue_t *queue, void *data) 56 | { 57 | cam_node_t *node = 58 | (cam_node_t *)malloc(sizeof(cam_node_t)); 59 | if (NULL == node) { 60 | return -1; 61 | } 62 | 63 | memset(node, 0, sizeof(cam_node_t)); 64 | node->data = data; 65 | 66 | pthread_mutex_lock(&queue->lock); 67 | cam_list_add_tail_node(&node->list, &queue->head.list); 68 | queue->size++; 69 | pthread_mutex_unlock(&queue->lock); 70 | 71 | return 0; 72 | } 73 | 74 | static inline void *cam_queue_deq(cam_queue_t *queue) 75 | { 76 | cam_node_t *node = NULL; 77 | void *data = NULL; 78 | struct cam_list *head = NULL; 79 | struct cam_list *pos = NULL; 80 | 81 | pthread_mutex_lock(&queue->lock); 82 | head = &queue->head.list; 83 | pos = head->next; 84 | if (pos != head) { 85 | node = member_of(pos, cam_node_t, list); 86 | cam_list_del_node(&node->list); 87 | queue->size--; 88 | } 89 | pthread_mutex_unlock(&queue->lock); 90 | 91 | if (NULL != node) { 92 | data = node->data; 93 | free(node); 94 | } 95 | 96 | return data; 97 | } 98 | 99 | static inline int32_t cam_queue_flush(cam_queue_t *queue) 100 | { 101 | cam_node_t *node = NULL; 102 | struct cam_list *head = NULL; 103 | struct cam_list *pos = NULL; 104 | 105 | pthread_mutex_lock(&queue->lock); 106 | head = &queue->head.list; 107 | pos = head->next; 108 | 109 | while(pos != head) { 110 | node = member_of(pos, cam_node_t, list); 111 | pos = pos->next; 112 | cam_list_del_node(&node->list); 113 | queue->size--; 114 | 115 | /* TODO later to consider ptr inside data */ 116 | /* for now we only assume there is no ptr inside data 117 | * so we free data directly */ 118 | if (NULL != node->data) { 119 | free(node->data); 120 | } 121 | free(node); 122 | 123 | } 124 | queue->size = 0; 125 | pthread_mutex_unlock(&queue->lock); 126 | return 0; 127 | } 128 | 129 | static inline int32_t cam_queue_deinit(cam_queue_t *queue) 130 | { 131 | cam_queue_flush(queue); 132 | pthread_mutex_destroy(&queue->lock); 133 | return 0; 134 | } 135 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/common/cam_semaphore.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA_SEMAPHORE_H__ 31 | #define __QCAMERA_SEMAPHORE_H__ 32 | 33 | // System dependencies 34 | #include 35 | 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /* Implement semaphore with mutex and conditional variable. 41 | * Reason being, POSIX semaphore on Android are not used or 42 | * well tested. 43 | */ 44 | 45 | typedef struct { 46 | int val; 47 | pthread_mutex_t mutex; 48 | pthread_cond_t cond; 49 | } cam_semaphore_t; 50 | 51 | static inline void cam_sem_init(cam_semaphore_t *s, int n) 52 | { 53 | pthread_mutex_init(&(s->mutex), NULL); 54 | pthread_cond_init(&(s->cond), NULL); 55 | s->val = n; 56 | } 57 | 58 | static inline void cam_sem_post(cam_semaphore_t *s) 59 | { 60 | pthread_mutex_lock(&(s->mutex)); 61 | s->val++; 62 | pthread_cond_signal(&(s->cond)); 63 | pthread_mutex_unlock(&(s->mutex)); 64 | } 65 | 66 | static inline int cam_sem_wait(cam_semaphore_t *s) 67 | { 68 | int rc = 0; 69 | pthread_mutex_lock(&(s->mutex)); 70 | while (s->val == 0) 71 | rc = pthread_cond_wait(&(s->cond), &(s->mutex)); 72 | s->val--; 73 | pthread_mutex_unlock(&(s->mutex)); 74 | return rc; 75 | } 76 | 77 | static inline void cam_sem_destroy(cam_semaphore_t *s) 78 | { 79 | pthread_mutex_destroy(&(s->mutex)); 80 | pthread_cond_destroy(&(s->cond)); 81 | s->val = 0; 82 | } 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* __QCAMERA_SEMAPHORE_H__ */ 89 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/common/mm_camera_shim.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __MM_CAMERA_SHIMLAYER_H_ 31 | #define __MM_CAMERA_SHIMLAYER_H_ 32 | 33 | #include "cam_intf.h" 34 | 35 | /* 36 | * MCT shim layer APIs 37 | */ 38 | #define SHIMLAYER_LIB "/system/vendor/lib/libmmcamera2_mct_shimlayer.so" 39 | 40 | struct cam_shim_packet; 41 | 42 | /* 43 | * Bundled events structure. 44 | */ 45 | typedef struct { 46 | uint8_t cmd_count; /* Total number of events in this packet */ 47 | struct cam_shim_packet *cmd; /*Events to process*/ 48 | } cam_shim_cmd_packet_t; 49 | 50 | /* 51 | * Bundled stream event structure 52 | */ 53 | typedef struct { 54 | uint8_t stream_count; /*Number of streams in a bundle*/ 55 | cam_shim_cmd_packet_t stream_event[MAX_NUM_STREAMS]; /*Event for different streams*/ 56 | } cam_shim_stream_cmd_packet_t; 57 | 58 | /* 59 | * Command types to process in shim layer 60 | */ 61 | typedef enum { 62 | CAM_SHIM_SET_PARM, /*v4l2 set parameter*/ 63 | CAM_SHIM_GET_PARM, /*v4l2 get parameter*/ 64 | CAM_SHIM_REG_BUF, /*Reg/unreg buffers with back-end*/ 65 | CAM_SHIM_BUNDLE_CMD, /*Bundled command for streams*/ 66 | } cam_shim_cmd_type; 67 | 68 | typedef struct { 69 | uint32_t command; /*V4L2 or private command*/ 70 | uint32_t stream_id; /*streamID*/ 71 | void *value; /*command value/data*/ 72 | } cam_shim_cmd_data; 73 | 74 | /* 75 | * Structure to communicate command with shim layer 76 | */ 77 | typedef struct cam_shim_packet { 78 | uint32_t session_id; 79 | cam_shim_cmd_type cmd_type; /*Command type to process*/ 80 | union { 81 | cam_shim_cmd_data cmd_data; /*get/set parameter structure*/ 82 | cam_reg_buf_t reg_buf; /*Buffer register and unregister*/ 83 | cam_shim_stream_cmd_packet_t bundle_cmd;/*Bundled command*/ 84 | }; 85 | } cam_shim_packet_t; 86 | 87 | typedef int32_t (*mm_camera_shim_event_handler_func)(uint32_t session_id, 88 | cam_event_t *event); 89 | 90 | typedef struct { 91 | cam_status_t (*mm_camera_shim_open_session) (int session, 92 | mm_camera_shim_event_handler_func evt_cb); 93 | int32_t (*mm_camera_shim_close_session)(int session); 94 | int32_t (*mm_camera_shim_send_cmd)(cam_shim_packet_t *event); 95 | } mm_camera_shim_ops_t; 96 | 97 | int32_t (*mm_camera_shim_module_init)(mm_camera_shim_ops_t *shim_ops); 98 | 99 | #endif /*__MM_CAMERA_SHIMLAYER_H_*/ 100 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-camera-interface/Android.mk: -------------------------------------------------------------------------------- 1 | OLD_LOCAL_PATH := $(LOCAL_PATH) 2 | LOCAL_PATH := $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | 6 | MM_CAM_FILES := \ 7 | src/mm_camera_interface.c \ 8 | src/mm_camera.c \ 9 | src/mm_camera_channel.c \ 10 | src/mm_camera_stream.c \ 11 | src/mm_camera_thread.c \ 12 | src/mm_camera_sock.c 13 | 14 | ifeq ($(CAMERA_DAEMON_NOT_PRESENT), true) 15 | else 16 | LOCAL_CFLAGS += -DDAEMON_PRESENT 17 | endif 18 | 19 | # System header file path prefix 20 | LOCAL_CFLAGS += -DSYSTEM_HEADER_PREFIX=sys 21 | 22 | ifeq ($(strip $(TARGET_USES_ION)),true) 23 | LOCAL_CFLAGS += -DUSE_ION 24 | endif 25 | 26 | ifneq (,$(filter msm8974 msm8916 msm8226 msm8610 msm8916 apq8084 msm8084 msm8994 msm8992 msm8952 msm8937 msm8953 msm8996 msmcobalt msmfalcon, $(TARGET_BOARD_PLATFORM))) 27 | LOCAL_CFLAGS += -DVENUS_PRESENT 28 | endif 29 | 30 | ifneq (,$(filter msm8996 msmcobalt msmfalcon,$(TARGET_BOARD_PLATFORM))) 31 | LOCAL_CFLAGS += -DUBWC_PRESENT 32 | endif 33 | 34 | LOCAL_CFLAGS += -D_ANDROID_ -DQCAMERA_REDEFINE_LOG 35 | LOCAL_COPY_HEADERS_TO := mm-camera-interface 36 | LOCAL_COPY_HEADERS += ../common/cam_intf.h 37 | LOCAL_COPY_HEADERS += ../common/cam_types.h 38 | 39 | LOCAL_C_INCLUDES := \ 40 | $(LOCAL_PATH)/inc \ 41 | $(LOCAL_PATH)/../common \ 42 | hardware/libhardware/include/hardware \ 43 | system/media/camera/include \ 44 | 45 | LOCAL_CFLAGS += -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID 46 | 47 | ifneq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) >= 17 ))" ))) 48 | LOCAL_CFLAGS += -include bionic/libc/kernel/common/linux/socket.h 49 | LOCAL_CFLAGS += -include bionic/libc/kernel/common/linux/un.h 50 | endif 51 | 52 | LOCAL_CFLAGS += -Wall -Wextra -Werror 53 | 54 | LOCAL_SRC_FILES := $(MM_CAM_FILES) 55 | 56 | LOCAL_MODULE := libmmcamera_interface 57 | LOCAL_PRELINK_MODULE := false 58 | LOCAL_SHARED_LIBRARIES := libdl libcutils liblog 59 | LOCAL_HEADER_LIBRARIES := generated_kernel_headers 60 | LOCAL_MODULE_TAGS := optional 61 | LOCAL_VENDOR_MODULE := true 62 | 63 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 64 | include $(BUILD_SHARED_LIBRARY) 65 | 66 | LOCAL_PATH := $(OLD_LOCAL_PATH) 67 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-camera-interface/inc/mm_camera_dbg.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2014, 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __MM_CAMERA_DBG_H__ 31 | #define __MM_CAMERA_DBG_H__ 32 | 33 | // System dependencies 34 | #include 35 | 36 | #ifdef QCAMERA_REDEFINE_LOG 37 | 38 | // Camera dependencies 39 | #include "cam_types.h" 40 | 41 | typedef enum { 42 | CAM_NO_MODULE, 43 | CAM_HAL_MODULE, 44 | CAM_MCI_MODULE, 45 | CAM_JPEG_MODULE, 46 | CAM_LAST_MODULE 47 | } cam_modules_t; 48 | 49 | /* values that persist.camera.global.debug can be set to */ 50 | /* all camera modules need to map their internal debug levels to this range */ 51 | typedef enum { 52 | CAM_GLBL_DBG_NONE = 0, 53 | CAM_GLBL_DBG_ERR = 1, 54 | CAM_GLBL_DBG_WARN = 2, 55 | CAM_GLBL_DBG_HIGH = 3, 56 | CAM_GLBL_DBG_DEBUG = 4, 57 | CAM_GLBL_DBG_LOW = 5, 58 | CAM_GLBL_DBG_INFO = 6 59 | } cam_global_debug_level_t; 60 | 61 | extern int g_cam_log[CAM_LAST_MODULE][CAM_GLBL_DBG_INFO + 1]; 62 | 63 | #define FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__) 64 | 65 | #undef CLOGx 66 | #define CLOGx(module, level, fmt, args...) \ 67 | {\ 68 | if (g_cam_log[module][level]) { \ 69 | mm_camera_debug_log(module, level, __func__, __LINE__, fmt, ##args); \ 70 | }\ 71 | } 72 | 73 | #undef CLOGI 74 | #define CLOGI(module, fmt, args...) \ 75 | CLOGx(module, CAM_GLBL_DBG_INFO, fmt, ##args) 76 | #undef CLOGD 77 | #define CLOGD(module, fmt, args...) \ 78 | CLOGx(module, CAM_GLBL_DBG_DEBUG, fmt, ##args) 79 | #undef CLOGL 80 | #define CLOGL(module, fmt, args...) \ 81 | CLOGx(module, CAM_GLBL_DBG_LOW, fmt, ##args) 82 | #undef CLOGW 83 | #define CLOGW(module, fmt, args...) \ 84 | CLOGx(module, CAM_GLBL_DBG_WARN, fmt, ##args) 85 | #undef CLOGH 86 | #define CLOGH(module, fmt, args...) \ 87 | CLOGx(module, CAM_GLBL_DBG_HIGH, fmt, ##args) 88 | #undef CLOGE 89 | #define CLOGE(module, fmt, args...) \ 90 | CLOGx(module, CAM_GLBL_DBG_ERR, fmt, ##args) 91 | 92 | #ifndef CAM_MODULE 93 | #define CAM_MODULE CAM_MCI_MODULE 94 | #endif 95 | 96 | #undef LOGD 97 | #define LOGD(fmt, args...) CLOGD(CAM_MODULE, fmt, ##args) 98 | #undef LOGL 99 | #define LOGL(fmt, args...) CLOGL(CAM_MODULE, fmt, ##args) 100 | #undef LOGW 101 | #define LOGW(fmt, args...) CLOGW(CAM_MODULE, fmt, ##args) 102 | #undef LOGH 103 | #define LOGH(fmt, args...) CLOGH(CAM_MODULE, fmt, ##args) 104 | #undef LOGE 105 | #define LOGE(fmt, args...) CLOGE(CAM_MODULE, fmt, ##args) 106 | #undef LOGI 107 | #define LOGI(fmt, args...) CLOGI(CAM_MODULE, fmt, ##args) 108 | 109 | /* reads and updates camera logging properties */ 110 | void mm_camera_set_dbg_log_properties(void); 111 | 112 | /* generic logger function */ 113 | void mm_camera_debug_log(const cam_modules_t module, 114 | const cam_global_debug_level_t level, 115 | const char *func, const int line, const char *fmt, ...); 116 | 117 | #else 118 | 119 | #undef LOGD 120 | #define LOGD(fmt, args...) ALOGD(fmt, ##args) 121 | #undef LOGL 122 | #define LOGL(fmt, args...) ALOGD(fmt, ##args) 123 | #undef LOGW 124 | #define LOGW(fmt, args...) ALOGW(fmt, ##args) 125 | #undef LOGH 126 | #define LOGH(fmt, args...) ALOGD(fmt, ##args) 127 | #undef LOGE 128 | #define LOGE(fmt, args...) ALOGE(fmt, ##args) 129 | #undef LOGI 130 | #define LOGI(fmt, args...) ALOGV(fmt, ##args) 131 | 132 | #endif 133 | 134 | #endif /* __MM_CAMERA_DBG_H__ */ 135 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-camera-interface/inc/mm_camera_sock.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2014, 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __MM_CAMERA_SOCKET_H__ 31 | #define __MM_CAMERA_SOCKET_H__ 32 | 33 | // System dependencies 34 | #define SOCKET_H 35 | #include SOCKET_H 36 | #define UN_H 37 | #include UN_H 38 | 39 | // Camera dependencies 40 | #include "cam_types.h" 41 | 42 | typedef enum { 43 | MM_CAMERA_SOCK_TYPE_UDP, 44 | MM_CAMERA_SOCK_TYPE_TCP, 45 | } mm_camera_sock_type_t; 46 | 47 | typedef union { 48 | struct sockaddr addr; 49 | struct sockaddr_un addr_un; 50 | } mm_camera_sock_addr_t; 51 | 52 | int mm_camera_socket_create(int cam_id, mm_camera_sock_type_t sock_type); 53 | 54 | int mm_camera_socket_sendmsg( 55 | int fd, 56 | void *msg, 57 | size_t buf_size, 58 | int sendfd); 59 | 60 | int mm_camera_socket_bundle_sendmsg( 61 | int fd, 62 | void *msg, 63 | size_t buf_size, 64 | int sendfds[CAM_MAX_NUM_BUFS_PER_STREAM], 65 | int num_fds); 66 | 67 | int mm_camera_socket_recvmsg( 68 | int fd, 69 | void *msg, 70 | uint32_t buf_size, 71 | int *rcvdfd); 72 | 73 | void mm_camera_socket_close(int fd); 74 | 75 | #endif /*__MM_CAMERA_SOCKET_H__*/ 76 | 77 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-jpeg-interface/Android.mk: -------------------------------------------------------------------------------- 1 | OLD_LOCAL_PATH := $(LOCAL_PATH) 2 | LOCAL_PATH := $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 7 | LOCAL_CFLAGS+= -D_ANDROID_ -DQCAMERA_REDEFINE_LOG 8 | 9 | LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter 10 | 11 | LOCAL_HEADER_LIBRARIES := generated_kernel_headers 12 | 13 | LIB2D_ROTATION=false 14 | 15 | LOCAL_C_INCLUDES += \ 16 | frameworks/native/include/media/openmax \ 17 | $(LOCAL_PATH)/inc \ 18 | $(LOCAL_PATH)/../common \ 19 | $(LOCAL_PATH)/../mm-camera-interface/inc \ 20 | $(LOCAL_PATH)/../../.. \ 21 | $(LOCAL_PATH)/../../../mm-image-codec/qexif \ 22 | $(LOCAL_PATH)/../../../mm-image-codec/qomx_core 23 | 24 | ifeq ($(strip $(LIB2D_ROTATION)),true) 25 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../mm-lib2d-interface/inc 26 | LOCAL_CFLAGS += -DLIB2D_ROTATION_ENABLE 27 | endif 28 | 29 | 30 | ifeq ($(strip $(TARGET_USES_ION)),true) 31 | LOCAL_CFLAGS += -DUSE_ION 32 | endif 33 | 34 | ifneq (,$(filter msm8610,$(TARGET_BOARD_PLATFORM))) 35 | LOCAL_CFLAGS+= -DLOAD_ADSP_RPC_LIB 36 | endif 37 | 38 | DUAL_JPEG_TARGET_LIST := msm8974 39 | DUAL_JPEG_TARGET_LIST += msm8994 40 | 41 | ifneq (,$(filter $(DUAL_JPEG_TARGET_LIST),$(TARGET_BOARD_PLATFORM))) 42 | LOCAL_CFLAGS+= -DMM_JPEG_CONCURRENT_SESSIONS_COUNT=2 43 | else 44 | LOCAL_CFLAGS+= -DMM_JPEG_CONCURRENT_SESSIONS_COUNT=1 45 | endif 46 | 47 | JPEG_PIPELINE_TARGET_LIST := msm8994 48 | JPEG_PIPELINE_TARGET_LIST += msm8992 49 | JPEG_PIPELINE_TARGET_LIST += msm8996 50 | JPEG_PIPELINE_TARGET_LIST += msmcobalt 51 | 52 | ifneq (,$(filter $(JPEG_PIPELINE_TARGET_LIST),$(TARGET_BOARD_PLATFORM))) 53 | LOCAL_CFLAGS+= -DMM_JPEG_USE_PIPELINE 54 | endif 55 | 56 | # System header file path prefix 57 | LOCAL_CFLAGS += -DSYSTEM_HEADER_PREFIX=sys 58 | 59 | LOCAL_SRC_FILES := \ 60 | src/mm_jpeg_queue.c \ 61 | src/mm_jpeg_exif.c \ 62 | src/mm_jpeg.c \ 63 | src/mm_jpeg_interface.c \ 64 | src/mm_jpeg_ionbuf.c \ 65 | src/mm_jpegdec_interface.c \ 66 | src/mm_jpegdec.c \ 67 | src/mm_jpeg_mpo_composer.c 68 | 69 | LOCAL_MODULE := libmmjpeg_interface 70 | LOCAL_PRELINK_MODULE := false 71 | LOCAL_SHARED_LIBRARIES := libdl libcutils liblog libqomx_core libmmcamera_interface 72 | ifeq ($(strip $(LIB2D_ROTATION)),true) 73 | LOCAL_SHARED_LIBRARIES += libmmlib2d_interface 74 | endif 75 | LOCAL_MODULE_TAGS := optional 76 | LOCAL_VENDOR_MODULE := true 77 | 78 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 79 | include $(BUILD_SHARED_LIBRARY) 80 | 81 | LOCAL_PATH := $(OLD_LOCAL_PATH) 82 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_dbg.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __MM_JPEG_DBG_H__ 31 | #define __MM_JPEG_DBG_H__ 32 | 33 | #ifdef QCAMERA_REDEFINE_LOG 34 | #define CAM_MODULE CAM_JPEG_MODULE 35 | #include "mm_camera_dbg.h" 36 | #endif 37 | 38 | extern volatile uint32_t gKpiDebugLevel; 39 | 40 | #ifndef KPI_DEBUG 41 | #define KPI_DEBUG 42 | #define ATRACE_TAG ATRACE_TAG_CAMERA 43 | #include 44 | 45 | #define KPI_APT 1 46 | #define KPI_DBG 2 47 | 48 | #define KPI_ATRACE_INT(name,val) ({\ 49 | if (gKpiDebugLevel >= KPI_APT) { \ 50 | atrace_int(ATRACE_TAG, name, val); \ 51 | }\ 52 | }) 53 | 54 | #endif 55 | #endif /* __MM_JPEG_DBG_H__ */ 56 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_inlines.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef MM_JPEG_INLINES_H_ 31 | #define MM_JPEG_INLINES_H_ 32 | 33 | // JPEG dependencies 34 | #include "mm_jpeg.h" 35 | 36 | /** mm_jpeg_get_session: 37 | * 38 | * Arguments: 39 | * @my_obj: jpeg object 40 | * @client_idx: client index 41 | * 42 | * Return: 43 | * job index 44 | * 45 | * Description: 46 | * Get job index by client id 47 | * 48 | **/ 49 | static inline mm_jpeg_job_session_t *mm_jpeg_get_session(mm_jpeg_obj *my_obj, uint32_t job_id) 50 | { 51 | mm_jpeg_job_session_t *p_session = NULL; 52 | int client_idx = GET_CLIENT_IDX(job_id); 53 | int session_idx= GET_SESSION_IDX(job_id); 54 | 55 | LOGD("client_idx %d session_idx %d", 56 | client_idx, session_idx); 57 | if ((session_idx >= MM_JPEG_MAX_SESSION) || 58 | (client_idx >= MAX_JPEG_CLIENT_NUM)) { 59 | LOGE("invalid job id %x", 60 | job_id); 61 | return NULL; 62 | } 63 | pthread_mutex_lock(&my_obj->clnt_mgr[client_idx].lock); 64 | p_session = &my_obj->clnt_mgr[client_idx].session[session_idx]; 65 | pthread_mutex_unlock(&my_obj->clnt_mgr[client_idx].lock); 66 | return p_session; 67 | } 68 | 69 | /** mm_jpeg_get_job_idx: 70 | * 71 | * Arguments: 72 | * @my_obj: jpeg object 73 | * @client_idx: client index 74 | * 75 | * Return: 76 | * job index 77 | * 78 | * Description: 79 | * Get job index by client id 80 | * 81 | **/ 82 | static inline int mm_jpeg_get_new_session_idx(mm_jpeg_obj *my_obj, int client_idx, 83 | mm_jpeg_job_session_t **pp_session) 84 | { 85 | int i = 0; 86 | int index = -1; 87 | for (i = 0; i < MM_JPEG_MAX_SESSION; i++) { 88 | pthread_mutex_lock(&my_obj->clnt_mgr[client_idx].lock); 89 | if (!my_obj->clnt_mgr[client_idx].session[i].active) { 90 | *pp_session = &my_obj->clnt_mgr[client_idx].session[i]; 91 | my_obj->clnt_mgr[client_idx].session[i].active = OMX_TRUE; 92 | index = i; 93 | pthread_mutex_unlock(&my_obj->clnt_mgr[client_idx].lock); 94 | break; 95 | } 96 | pthread_mutex_unlock(&my_obj->clnt_mgr[client_idx].lock); 97 | } 98 | return index; 99 | } 100 | 101 | /** mm_jpeg_get_job_idx: 102 | * 103 | * Arguments: 104 | * @my_obj: jpeg object 105 | * @client_idx: client index 106 | * 107 | * Return: 108 | * job index 109 | * 110 | * Description: 111 | * Get job index by client id 112 | * 113 | **/ 114 | static inline void mm_jpeg_remove_session_idx(mm_jpeg_obj *my_obj, uint32_t job_id) 115 | { 116 | int client_idx = GET_CLIENT_IDX(job_id); 117 | int session_idx= GET_SESSION_IDX(job_id); 118 | LOGD("client_idx %d session_idx %d", 119 | client_idx, session_idx); 120 | pthread_mutex_lock(&my_obj->clnt_mgr[client_idx].lock); 121 | my_obj->clnt_mgr[client_idx].session[session_idx].active = OMX_FALSE; 122 | pthread_mutex_unlock(&my_obj->clnt_mgr[client_idx].lock); 123 | } 124 | 125 | 126 | 127 | #endif /* MM_JPEG_INLINES_H_ */ 128 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_ionbuf.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013-2014, 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __MM_JPEG_IONBUF_H__ 31 | #define __MM_JPEG_IONBUF_H__ 32 | 33 | // System dependencies 34 | #include 35 | 36 | // JPEG dependencies 37 | #include "mm_jpeg_dbg.h" 38 | 39 | typedef struct { 40 | struct ion_fd_data ion_info_fd; 41 | struct ion_allocation_data alloc; 42 | int p_pmem_fd; 43 | size_t size; 44 | int ion_fd; 45 | uint8_t *addr; 46 | } buffer_t; 47 | 48 | /** buffer_allocate: 49 | * 50 | * Arguments: 51 | * @p_buffer: ION buffer 52 | * 53 | * Return: 54 | * buffer address 55 | * 56 | * Description: 57 | * allocates ION buffer 58 | * 59 | **/ 60 | void* buffer_allocate(buffer_t *p_buffer, int cached); 61 | 62 | /** buffer_deallocate: 63 | * 64 | * Arguments: 65 | * @p_buffer: ION buffer 66 | * 67 | * Return: 68 | * error val 69 | * 70 | * Description: 71 | * deallocates ION buffer 72 | * 73 | **/ 74 | int buffer_deallocate(buffer_t *p_buffer); 75 | 76 | /** buffer_invalidate: 77 | * 78 | * Arguments: 79 | * @p_buffer: ION buffer 80 | * 81 | * Return: 82 | * error val 83 | * 84 | * Description: 85 | * Invalidates the cached buffer 86 | * 87 | **/ 88 | int buffer_invalidate(buffer_t *p_buffer); 89 | 90 | /** buffer_clean: 91 | * 92 | * Arguments: 93 | * @p_buffer: ION buffer 94 | * 95 | * Return: 96 | * error val 97 | * 98 | * Description: 99 | * clean the cached buffer 100 | * 101 | **/ 102 | int buffer_clean(buffer_t *p_buffer); 103 | 104 | #endif 105 | 106 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_mpo.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef MM_JPEG_MPO_H_ 31 | #define MM_JPEG_MPO_H_ 32 | 33 | // JPEG dependencies 34 | #include "mm_jpeg_interface.h" 35 | #include "qmpo.h" 36 | 37 | #define TRUE 1 38 | #define FALSE 0 39 | 40 | extern int mm_jpeg_mpo_compose(mm_jpeg_mpo_info_t *mpo_info); 41 | 42 | extern int get_mpo_size(mm_jpeg_output_t jpeg_buffer[MM_JPEG_MAX_MPO_IMAGES], 43 | int num_of_images); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_queue.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2014, 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | // System dependencies 31 | #include 32 | 33 | // JPEG dependencies 34 | #include "mm_jpeg_dbg.h" 35 | #include "mm_jpeg.h" 36 | 37 | int32_t mm_jpeg_queue_init(mm_jpeg_queue_t* queue) 38 | { 39 | pthread_mutex_init(&queue->lock, NULL); 40 | cam_list_init(&queue->head.list); 41 | queue->size = 0; 42 | return 0; 43 | } 44 | 45 | int32_t mm_jpeg_queue_enq(mm_jpeg_queue_t* queue, mm_jpeg_q_data_t data) 46 | { 47 | mm_jpeg_q_node_t* node = 48 | (mm_jpeg_q_node_t *)malloc(sizeof(mm_jpeg_q_node_t)); 49 | if (NULL == node) { 50 | LOGE("No memory for mm_jpeg_q_node_t"); 51 | return -1; 52 | } 53 | 54 | memset(node, 0, sizeof(mm_jpeg_q_node_t)); 55 | node->data = data; 56 | 57 | pthread_mutex_lock(&queue->lock); 58 | cam_list_add_tail_node(&node->list, &queue->head.list); 59 | queue->size++; 60 | pthread_mutex_unlock(&queue->lock); 61 | 62 | return 0; 63 | 64 | } 65 | 66 | int32_t mm_jpeg_queue_enq_head(mm_jpeg_queue_t* queue, mm_jpeg_q_data_t data) 67 | { 68 | struct cam_list *head = NULL; 69 | struct cam_list *pos = NULL; 70 | mm_jpeg_q_node_t* node = 71 | (mm_jpeg_q_node_t *)malloc(sizeof(mm_jpeg_q_node_t)); 72 | if (NULL == node) { 73 | LOGE("No memory for mm_jpeg_q_node_t"); 74 | return -1; 75 | } 76 | 77 | memset(node, 0, sizeof(mm_jpeg_q_node_t)); 78 | node->data = data; 79 | 80 | head = &queue->head.list; 81 | pos = head->next; 82 | 83 | pthread_mutex_lock(&queue->lock); 84 | cam_list_insert_before_node(&node->list, pos); 85 | queue->size++; 86 | pthread_mutex_unlock(&queue->lock); 87 | 88 | return 0; 89 | } 90 | 91 | mm_jpeg_q_data_t mm_jpeg_queue_deq(mm_jpeg_queue_t* queue) 92 | { 93 | mm_jpeg_q_data_t data; 94 | mm_jpeg_q_node_t* node = NULL; 95 | struct cam_list *head = NULL; 96 | struct cam_list *pos = NULL; 97 | 98 | memset(&data, 0, sizeof(data)); 99 | 100 | pthread_mutex_lock(&queue->lock); 101 | head = &queue->head.list; 102 | pos = head->next; 103 | if (pos != head) { 104 | node = member_of(pos, mm_jpeg_q_node_t, list); 105 | cam_list_del_node(&node->list); 106 | queue->size--; 107 | } 108 | pthread_mutex_unlock(&queue->lock); 109 | 110 | if (NULL != node) { 111 | data = node->data; 112 | free(node); 113 | } 114 | 115 | return data; 116 | } 117 | 118 | uint32_t mm_jpeg_queue_get_size(mm_jpeg_queue_t* queue) 119 | { 120 | uint32_t size = 0; 121 | 122 | pthread_mutex_lock(&queue->lock); 123 | size = queue->size; 124 | pthread_mutex_unlock(&queue->lock); 125 | 126 | return size; 127 | 128 | } 129 | 130 | int32_t mm_jpeg_queue_deinit(mm_jpeg_queue_t* queue) 131 | { 132 | mm_jpeg_queue_flush(queue); 133 | pthread_mutex_destroy(&queue->lock); 134 | return 0; 135 | } 136 | 137 | int32_t mm_jpeg_queue_flush(mm_jpeg_queue_t* queue) 138 | { 139 | mm_jpeg_q_node_t* node = NULL; 140 | struct cam_list *head = NULL; 141 | struct cam_list *pos = NULL; 142 | 143 | pthread_mutex_lock(&queue->lock); 144 | head = &queue->head.list; 145 | pos = head->next; 146 | 147 | while(pos != head) { 148 | node = member_of(pos, mm_jpeg_q_node_t, list); 149 | cam_list_del_node(&node->list); 150 | queue->size--; 151 | 152 | /* for now we only assume there is no ptr inside data 153 | * so we free data directly */ 154 | if (NULL != node->data.p) { 155 | free(node->data.p); 156 | } 157 | free(node); 158 | pos = pos->next; 159 | } 160 | queue->size = 0; 161 | pthread_mutex_unlock(&queue->lock); 162 | return 0; 163 | } 164 | 165 | mm_jpeg_q_data_t mm_jpeg_queue_peek(mm_jpeg_queue_t* queue) 166 | { 167 | mm_jpeg_q_data_t data; 168 | mm_jpeg_q_node_t* node = NULL; 169 | struct cam_list *head = NULL; 170 | struct cam_list *pos = NULL; 171 | 172 | memset(&data, 0, sizeof(data)); 173 | 174 | pthread_mutex_lock(&queue->lock); 175 | head = &queue->head.list; 176 | pos = head->next; 177 | if (pos != head) { 178 | node = member_of(pos, mm_jpeg_q_node_t, list); 179 | } 180 | pthread_mutex_unlock(&queue->lock); 181 | 182 | if (NULL != node) { 183 | data = node->data; 184 | } 185 | return data; 186 | } 187 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-jpeg-interface/test/Android.mk: -------------------------------------------------------------------------------- 1 | #encoder int test 2 | OLD_LOCAL_PATH := $(LOCAL_PATH) 3 | MM_JPEG_TEST_PATH := $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | LOCAL_PATH := $(MM_JPEG_TEST_PATH) 7 | LOCAL_MODULE_TAGS := optional 8 | 9 | LOCAL_CFLAGS := -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID 10 | LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter 11 | LOCAL_CFLAGS += -D_ANDROID_ 12 | 13 | ifeq ($(strip $(TARGET_USES_ION)),true) 14 | LOCAL_CFLAGS += -DUSE_ION 15 | endif 16 | 17 | # System header file path prefix 18 | LOCAL_CFLAGS += -DSYSTEM_HEADER_PREFIX=sys 19 | 20 | OMX_HEADER_DIR := frameworks/native/include/media/openmax 21 | OMX_CORE_DIR := $(MM_JPEG_TEST_PATH)/../../../../mm-image-codec 22 | 23 | LOCAL_C_INCLUDES := $(MM_JPEG_TEST_PATH) 24 | LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../inc 25 | LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../../common 26 | LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../../mm-camera-interface/inc 27 | LOCAL_C_INCLUDES += $(OMX_HEADER_DIR) 28 | LOCAL_C_INCLUDES += $(OMX_CORE_DIR)/qexif 29 | LOCAL_C_INCLUDES += $(OMX_CORE_DIR)/qomx_core 30 | 31 | LOCAL_C_INCLUDES+= $(kernel_includes) 32 | LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) 33 | 34 | LOCAL_SRC_FILES := mm_jpeg_test.c 35 | 36 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 37 | LOCAL_MODULE := mm-jpeg-interface-test 38 | LOCAL_VENDOR_MODULE := true 39 | LOCAL_PRELINK_MODULE := false 40 | LOCAL_SHARED_LIBRARIES := libcutils libdl libmmjpeg_interface liblog 41 | 42 | include $(BUILD_EXECUTABLE) 43 | 44 | 45 | 46 | #decoder int test 47 | 48 | include $(CLEAR_VARS) 49 | LOCAL_PATH := $(MM_JPEG_TEST_PATH) 50 | LOCAL_MODULE_TAGS := optional 51 | 52 | LOCAL_CFLAGS := -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID 53 | LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter 54 | 55 | LOCAL_CFLAGS += -D_ANDROID_ 56 | 57 | ifeq ($(strip $(TARGET_USES_ION)),true) 58 | LOCAL_CFLAGS += -DUSE_ION 59 | endif 60 | 61 | # System header file path prefix 62 | LOCAL_CFLAGS += -DSYSTEM_HEADER_PREFIX=sys 63 | 64 | OMX_HEADER_DIR := frameworks/native/include/media/openmax 65 | OMX_CORE_DIR := $(MM_JPEG_TEST_PATH)/../../../../mm-image-codec 66 | 67 | LOCAL_C_INCLUDES := $(MM_JPEG_TEST_PATH) 68 | LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../inc 69 | LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../../common 70 | LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../../mm-camera-interface/inc 71 | LOCAL_C_INCLUDES += $(OMX_HEADER_DIR) 72 | LOCAL_C_INCLUDES += $(OMX_CORE_DIR)/qexif 73 | LOCAL_C_INCLUDES += $(OMX_CORE_DIR)/qomx_core 74 | 75 | LOCAL_HEADER_LIBRARIES := generated_kernel_headers 76 | 77 | LOCAL_SRC_FILES := mm_jpegdec_test.c 78 | 79 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 80 | LOCAL_MODULE := mm-jpegdec-interface-test 81 | LOCAL_VENDOR_MODULE := true 82 | LOCAL_PRELINK_MODULE := false 83 | LOCAL_SHARED_LIBRARIES := libcutils libdl libmmjpeg_interface liblog 84 | 85 | include $(BUILD_EXECUTABLE) 86 | 87 | LOCAL_PATH := $(OLD_LOCAL_PATH) 88 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-lib2d-interface/Android.mk: -------------------------------------------------------------------------------- 1 | OLD_LOCAL_PATH := $(LOCAL_PATH) 2 | LOCAL_PATH := $(call my-dir) 3 | 4 | include $(LOCAL_PATH)/../../../common.mk 5 | include $(CLEAR_VARS) 6 | 7 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 8 | LOCAL_CFLAGS+= -D_ANDROID_ -DQCAMERA_REDEFINE_LOG 9 | 10 | LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter 11 | 12 | LOCAL_C_INCLUDES+= $(kernel_includes) 13 | LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) 14 | 15 | IMGLIB_HEADER_PATH := $(TARGET_OUT_INTERMEDIATES)/include/mm-camera/imglib 16 | 17 | LOCAL_C_INCLUDES += \ 18 | $(IMGLIB_HEADER_PATH) \ 19 | $(LOCAL_PATH)/inc \ 20 | $(LOCAL_PATH)/../common \ 21 | $(LOCAL_PATH)/../mm-camera-interface/inc \ 22 | 23 | ifeq ($(strip $(TARGET_USES_ION)),true) 24 | LOCAL_CFLAGS += -DUSE_ION 25 | endif 26 | 27 | 28 | LOCAL_SRC_FILES := \ 29 | src/mm_lib2d.c 30 | 31 | LOCAL_MODULE := libmmlib2d_interface 32 | LOCAL_PRELINK_MODULE := false 33 | LOCAL_SHARED_LIBRARIES := libdl libcutils liblog libmmcamera_interface 34 | LOCAL_MODULE_TAGS := optional 35 | LOCAL_VENDOR_MODULE := true 36 | 37 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 38 | include $(BUILD_SHARED_LIBRARY) 39 | 40 | LOCAL_PATH := $(OLD_LOCAL_PATH) 41 | -------------------------------------------------------------------------------- /camera/QCamera2/stack/mm-lib2d-interface/test/Android.mk: -------------------------------------------------------------------------------- 1 | #lib2d sample test 2 | OLD_LOCAL_PATH := $(LOCAL_PATH) 3 | MM_LIB2D_TEST_PATH := $(call my-dir) 4 | 5 | include $(LOCAL_PATH)/../../common.mk 6 | include $(CLEAR_VARS) 7 | LOCAL_PATH := $(MM_LIB2D_TEST_PATH) 8 | LOCAL_MODULE_TAGS := optional 9 | 10 | LOCAL_CFLAGS := -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID 11 | LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter 12 | LOCAL_CFLAGS += -D_ANDROID_ 13 | 14 | ifeq ($(strip $(TARGET_USES_ION)),true) 15 | LOCAL_CFLAGS += -DUSE_ION 16 | endif 17 | 18 | IMGLIB_HEADER_PATH := $(TARGET_OUT_INTERMEDIATES)/include/mm-camera/imglib 19 | 20 | LOCAL_C_INCLUDES += \ 21 | $(IMGLIB_HEADER_PATH) \ 22 | $(LOCAL_PATH)/../../common \ 23 | $(LOCAL_PATH)/../inc 24 | 25 | LOCAL_C_INCLUDES+= $(kernel_includes) 26 | LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) 27 | 28 | LOCAL_SRC_FILES := mm_lib2d_test.c 29 | 30 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 31 | LOCAL_MODULE := mm-lib2d-interface-test 32 | LOCAL_VENDOR_MODULE := true 33 | LOCAL_PRELINK_MODULE := false 34 | LOCAL_SHARED_LIBRARIES := libcutils libdl libmmlib2d_interface 35 | 36 | include $(BUILD_EXECUTABLE) 37 | 38 | LOCAL_PATH := $(OLD_LOCAL_PATH) 39 | -------------------------------------------------------------------------------- /camera/QCamera2/util/QCameraBufferMaps.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA_BUFFERMAPS_H__ 31 | #define __QCAMERA_BUFFERMAPS_H__ 32 | 33 | // Camera dependencies 34 | #include "cam_types.h" 35 | 36 | namespace qcamera { 37 | 38 | class QCameraBufferMaps { 39 | public: 40 | QCameraBufferMaps(); 41 | QCameraBufferMaps(const QCameraBufferMaps& pBufferMaps); 42 | QCameraBufferMaps(const cam_buf_map_type_list& pBufMapList); 43 | QCameraBufferMaps(cam_mapping_buf_type pType, 44 | uint32_t pStreamId, 45 | uint32_t pFrameIndex, 46 | int32_t pPlaneIndex, 47 | uint32_t pCookie, 48 | int32_t pFd, 49 | size_t pSize, 50 | void *buffer); 51 | 52 | ~QCameraBufferMaps(); 53 | 54 | QCameraBufferMaps& operator=(const QCameraBufferMaps& pBufferMaps); 55 | 56 | uint32_t enqueue(cam_mapping_buf_type pType, 57 | uint32_t pStreamId, 58 | uint32_t pFrameIndex, 59 | int32_t pPlaneIndex, 60 | uint32_t pCookie, 61 | int32_t pFd, 62 | size_t pSize, 63 | void *buffer); 64 | 65 | uint32_t getCamBufMapList(cam_buf_map_type_list& pBufMapList) const; 66 | 67 | static uint32_t makeSingletonBufMapList(cam_mapping_buf_type pType, 68 | uint32_t pStreamId, 69 | uint32_t pFrameIndex, 70 | int32_t pPlaneIndex, 71 | uint32_t pCookie, 72 | int32_t pFd, 73 | size_t pSize, 74 | cam_buf_map_type_list& pBufMapList, 75 | void *buffer); 76 | 77 | private: 78 | cam_buf_map_type_list mBufMapList; 79 | }; 80 | 81 | }; // namespace qcamera 82 | #endif /* __QCAMERA_BUFFERMAPS_H__ */ 83 | 84 | -------------------------------------------------------------------------------- /camera/QCamera2/util/QCameraCmdThread.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA_CMD_THREAD_H__ 31 | #define __QCAMERA_CMD_THREAD_H__ 32 | 33 | // System dependencies 34 | #include 35 | 36 | // Camera dependencies 37 | #include "cam_semaphore.h" 38 | #include "cam_types.h" 39 | #include "QCameraQueue.h" 40 | 41 | namespace qcamera { 42 | 43 | typedef enum 44 | { 45 | CAMERA_CMD_TYPE_NONE, 46 | CAMERA_CMD_TYPE_START_DATA_PROC, 47 | CAMERA_CMD_TYPE_STOP_DATA_PROC, 48 | CAMERA_CMD_TYPE_DO_NEXT_JOB, 49 | CAMERA_CMD_TYPE_EXIT, 50 | CAMERA_CMD_TYPE_MAX 51 | } camera_cmd_type_t; 52 | 53 | typedef struct { 54 | camera_cmd_type_t cmd; 55 | } camera_cmd_t; 56 | 57 | class QCameraCmdThread { 58 | public: 59 | QCameraCmdThread(); 60 | ~QCameraCmdThread(); 61 | 62 | int32_t launch(void *(*start_routine)(void *), void* user_data); 63 | int32_t setName(const char* name); 64 | int32_t exit(); 65 | int32_t sendCmd(camera_cmd_type_t cmd, uint8_t sync_cmd, uint8_t priority); 66 | camera_cmd_type_t getCmd(); 67 | 68 | QCameraQueue cmd_queue; /* cmd queue */ 69 | pthread_t cmd_pid; /* cmd thread ID */ 70 | cam_semaphore_t cmd_sem; /* semaphore for cmd thread */ 71 | cam_semaphore_t sync_sem; /* semaphore for synchronized call signal */ 72 | }; 73 | 74 | }; // namespace qcamera 75 | 76 | #endif /* __QCAMERA_CMD_THREAD_H__ */ 77 | -------------------------------------------------------------------------------- /camera/QCamera2/util/QCameraCommon.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA_COMMON_H__ 31 | #define __QCAMERA_COMMON_H__ 32 | 33 | #include 34 | 35 | // Camera dependencies 36 | #include "cam_types.h" 37 | #include "cam_intf.h" 38 | 39 | namespace qcamera { 40 | 41 | #define ALIGN(a, b) (((a) + (b)) & ~(b)) 42 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) 43 | 44 | class QCameraCommon { 45 | public: 46 | QCameraCommon(); 47 | ~QCameraCommon(); 48 | 49 | int32_t init(cam_capability_t *cap); 50 | 51 | int32_t getAnalysisInfo( 52 | bool fdVideoEnabled, bool hal3, cam_feature_mask_t featureMask, 53 | cam_analysis_info_t *pAnalysisInfo); 54 | static uint32_t calculateLCM(int32_t num1, int32_t num2); 55 | static nsecs_t getBootToMonoTimeOffset(); 56 | 57 | private: 58 | cam_capability_t *m_pCapability; 59 | 60 | }; 61 | 62 | }; // namespace qcamera 63 | #endif /* __QCAMERA_COMMON_H__ */ 64 | 65 | -------------------------------------------------------------------------------- /camera/QCamera2/util/QCameraDisplay.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERADISPLAY_H__ 31 | #define __QCAMERADISPLAY_H__ 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | namespace qcamera { 38 | 39 | #define CAMERA_NUM_VSYNC_INTERVAL_HISTORY 8 40 | #define NSEC_PER_MSEC 1000000LLU 41 | 42 | class QCameraDisplay { 43 | public: 44 | QCameraDisplay(); 45 | ~QCameraDisplay(); 46 | static int vsyncEventReceiverCamera(int fd, int events, void* data); 47 | static void* vsyncThreadCamera(void * data); 48 | void computeAverageVsyncInterval(nsecs_t currentVsyncTimeStamp); 49 | nsecs_t computePresentationTimeStamp(nsecs_t frameTimeStamp); 50 | 51 | private: 52 | pthread_t mVsyncThreadCameraHandle; 53 | nsecs_t mVsyncTimeStamp; 54 | nsecs_t mAvgVsyncInterval; 55 | nsecs_t mOldTimeStamp; 56 | nsecs_t mVsyncIntervalHistory[CAMERA_NUM_VSYNC_INTERVAL_HISTORY]; 57 | nsecs_t mVsyncHistoryIndex; 58 | nsecs_t mAdditionalVsyncOffsetForWiggle; 59 | uint32_t mThreadExit; 60 | // Tunable property. Increasing this will increase the frame delay and will loose 61 | // the real time display. 62 | uint32_t mNum_vsync_from_vfe_isr_to_presentation_timestamp; 63 | // Tunable property. Set the time stamp x ns prior to expected vsync so that 64 | // it will be picked in that vsync 65 | nsecs_t mSet_timestamp_num_ns_prior_to_vsync; 66 | // Tunable property for filtering timestamp wiggle when VFE ISR crosses 67 | // over MDP ISR over a period. Typical scenario is VFE is running at 68 | // 30.2 fps vs display running at 60 fps. 69 | nsecs_t mVfe_and_mdp_freq_wiggle_filter_max_ns; 70 | nsecs_t mVfe_and_mdp_freq_wiggle_filter_min_ns; 71 | 72 | android::DisplayEventReceiver mDisplayEventReceiver; 73 | }; 74 | 75 | }; // namespace qcamera 76 | 77 | #endif /* __QCAMERADISPLAY_H__ */ 78 | -------------------------------------------------------------------------------- /camera/QCamera2/util/QCameraFlash.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA_FLASH_H__ 31 | #define __QCAMERA_FLASH_H__ 32 | 33 | // Camera dependencies 34 | #include "hardware/camera_common.h" 35 | 36 | extern "C" { 37 | #include "mm_camera_interface.h" 38 | } 39 | 40 | namespace qcamera { 41 | 42 | #define QCAMERA_TORCH_CURRENT_VALUE 200 43 | 44 | class QCameraFlash { 45 | public: 46 | static QCameraFlash& getInstance(); 47 | 48 | int32_t registerCallbacks(const camera_module_callbacks_t* callbacks); 49 | int32_t initFlash(const int camera_id); 50 | int32_t setFlashMode(const int camera_id, const bool on); 51 | int32_t deinitFlash(const int camera_id); 52 | int32_t reserveFlashForCamera(const int camera_id); 53 | int32_t releaseFlashFromCamera(const int camera_id); 54 | 55 | private: 56 | QCameraFlash(); 57 | virtual ~QCameraFlash(); 58 | QCameraFlash(const QCameraFlash&); 59 | QCameraFlash& operator=(const QCameraFlash&); 60 | 61 | const camera_module_callbacks_t *m_callbacks; 62 | int32_t m_flashFds[MM_CAMERA_MAX_NUM_SENSORS]; 63 | bool m_flashOn[MM_CAMERA_MAX_NUM_SENSORS]; 64 | bool m_cameraOpen[MM_CAMERA_MAX_NUM_SENSORS]; 65 | }; 66 | 67 | }; // namespace qcamera 68 | 69 | #endif /* __QCAMERA_FLASH_H__ */ 70 | -------------------------------------------------------------------------------- /camera/QCamera2/util/QCameraPerf.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERAPERF_H__ 31 | #define __QCAMERAPERF_H__ 32 | 33 | // System dependencies 34 | #include 35 | #include 36 | 37 | // Camera dependencies 38 | #include "hardware/power.h" 39 | 40 | typedef enum { 41 | ALL_CORES_ONLINE = 0x7FE, 42 | ALL_CPUS_PWR_CLPS_DIS = 0x101, 43 | CPU0_MIN_FREQ_TURBO_MAX = 0x2FE, 44 | CPU4_MIN_FREQ_TURBO_MAX = 0x1FFE, 45 | }perf_lock_params_t; 46 | 47 | /* Time related macros */ 48 | #define ONE_SEC 1000 49 | typedef int64_t nsecs_t; 50 | #define NSEC_PER_SEC 1000000000LLU 51 | 52 | using namespace android; 53 | 54 | namespace qcamera { 55 | 56 | class QCameraPerfLock { 57 | public: 58 | QCameraPerfLock(); 59 | ~QCameraPerfLock(); 60 | 61 | void lock_init(); 62 | void lock_deinit(); 63 | int32_t lock_rel(); 64 | int32_t lock_acq(); 65 | int32_t lock_acq_timed(int32_t timer_val); 66 | int32_t lock_rel_timed(); 67 | bool isTimerReset(); 68 | void powerHintInternal(power_hint_t hint, bool enable); 69 | void powerHint(power_hint_t hint, bool enable); 70 | 71 | private: 72 | int32_t (*perf_lock_acq)(int, int, int[], int); 73 | int32_t (*perf_lock_rel)(int); 74 | void startTimer(uint32_t timer_val); 75 | void resetTimer(); 76 | void *mDlHandle; 77 | uint32_t mPerfLockEnable; 78 | Mutex mLock; 79 | int32_t mPerfLockHandle; // Performance lock library handle 80 | int32_t mPerfLockHandleTimed; // Performance lock library handle 81 | power_module_t *m_pPowerModule; // power module Handle 82 | power_hint_t mCurrentPowerHint; 83 | bool mCurrentPowerHintEnable; 84 | uint32_t mTimerSet; 85 | uint32_t mPerfLockTimeout; 86 | nsecs_t mStartTimeofLock; 87 | List mActivePowerHints; // Active/enabled power hints list 88 | }; 89 | 90 | }; // namespace qcamera 91 | 92 | #endif /* __QCAMREAPERF_H__ */ 93 | -------------------------------------------------------------------------------- /camera/QCamera2/util/QCameraQueue.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef __QCAMERA_QUEUE_H__ 31 | #define __QCAMERA_QUEUE_H__ 32 | 33 | // System dependencies 34 | #include 35 | 36 | // Camera dependencies 37 | #include "cam_list.h" 38 | 39 | namespace qcamera { 40 | 41 | typedef bool (*match_fn_data)(void *data, void *user_data, void *match_data); 42 | typedef void (*release_data_fn)(void* data, void *user_data); 43 | typedef bool (*match_fn)(void *data, void *user_data); 44 | 45 | class QCameraQueue { 46 | public: 47 | QCameraQueue(); 48 | QCameraQueue(release_data_fn data_rel_fn, void *user_data); 49 | virtual ~QCameraQueue(); 50 | void init(); 51 | bool enqueue(void *data); 52 | bool enqueueWithPriority(void *data); 53 | /* This call will put queue into uninitialized state. 54 | * Need to call init() in order to use the queue again */ 55 | void flush(); 56 | void flushNodes(match_fn match); 57 | void flushNodes(match_fn_data match, void *spec_data); 58 | void* dequeue(bool bFromHead = true); 59 | void* dequeue(match_fn_data match, void *spec_data); 60 | void* peek(); 61 | bool isEmpty(); 62 | int getCurrentSize() {return m_size;} 63 | private: 64 | typedef struct { 65 | struct cam_list list; 66 | void* data; 67 | } camera_q_node; 68 | 69 | camera_q_node m_head; // dummy head 70 | int m_size; 71 | bool m_active; 72 | pthread_mutex_t m_lock; 73 | release_data_fn m_dataFn; 74 | void * m_userData; 75 | }; 76 | 77 | }; // namespace qcamera 78 | 79 | #endif /* __QCAMERA_QUEUE_H__ */ 80 | -------------------------------------------------------------------------------- /camera/QCamera2/util/QCameraTrace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. 3 | * Not a Contribution. 4 | * 5 | * Copyright (C) 2012 The Android Open Source Project 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef __QCAMERATRACE_H__ 21 | #define __QCAMERATRACE_H__ 22 | 23 | #include 24 | 25 | #ifdef QCAMERA_REDEFINE_LOG 26 | #define CAM_MODULE CAM_HAL_MODULE 27 | extern "C" { 28 | #include "mm_camera_dbg.h" 29 | } 30 | #endif 31 | 32 | #undef ATRACE_CALL 33 | #undef ATRACE_NAME 34 | #undef ATRACE_BEGIN 35 | #undef ATRACE_INT 36 | #undef ATRACE_END 37 | #undef ATRACE_BEGIN_SNPRINTF 38 | #undef KPI_ATRACE_BEGIN 39 | #undef KPI_ATRACE_END 40 | #undef KPI_ATRACE_INT 41 | #undef ATRACE_TAG 42 | #undef ATRACE_BEGIN_DBG 43 | #undef ATRACE_INT_DBG 44 | #undef ATRACE_END_DBG 45 | 46 | #define KPI_ONLY 1 47 | #define KPI_DBG 2 48 | 49 | #define CAMERA_TRACE_BUF 32 50 | 51 | #define ATRACE_TAG ATRACE_TAG_CAMERA 52 | 53 | //to enable only KPI logs 54 | #define KPI_ATRACE_BEGIN(name) ({\ 55 | if (gKpiDebugLevel >= KPI_ONLY) { \ 56 | atrace_begin(ATRACE_TAG, name); \ 57 | }\ 58 | }) 59 | 60 | #define KPI_ATRACE_END() ({\ 61 | if (gKpiDebugLevel >= KPI_ONLY) { \ 62 | atrace_end(ATRACE_TAG); \ 63 | }\ 64 | }) 65 | 66 | #define KPI_ATRACE_INT(name,val) ({\ 67 | if (gKpiDebugLevel >= KPI_ONLY) { \ 68 | atrace_int(ATRACE_TAG, name, val); \ 69 | }\ 70 | }) 71 | 72 | 73 | #define ATRACE_BEGIN_SNPRINTF(fmt_str, ...) \ 74 | if (gKpiDebugLevel >= KPI_DBG) { \ 75 | char trace_tag[CAMERA_TRACE_BUF]; \ 76 | snprintf(trace_tag, CAMERA_TRACE_BUF, fmt_str, ##__VA_ARGS__); \ 77 | ATRACE_BEGIN(trace_tag); \ 78 | } 79 | 80 | #define ATRACE_BEGIN_DBG(name) ({\ 81 | if (gKpiDebugLevel >= KPI_DBG) { \ 82 | atrace_begin(ATRACE_TAG, name); \ 83 | }\ 84 | }) 85 | 86 | #define ATRACE_END_DBG() ({\ 87 | if (gKpiDebugLevel >= KPI_DBG) { \ 88 | atrace_end(ATRACE_TAG); \ 89 | }\ 90 | }) 91 | 92 | #define ATRACE_INT_DBG(name,val) ({\ 93 | if (gKpiDebugLevel >= KPI_DBG) { \ 94 | atrace_int(ATRACE_TAG, name, val); \ 95 | }\ 96 | }) 97 | 98 | #define ATRACE_BEGIN ATRACE_BEGIN_DBG 99 | #define ATRACE_INT ATRACE_INT_DBG 100 | #define ATRACE_END ATRACE_END_DBG 101 | 102 | #define KPI_ATRACE_NAME(name) qcamera::ScopedTraceKpi ___tracer(ATRACE_TAG, name) 103 | #define ATRACE_NAME(name) qcamera::ScopedTraceDbg ___tracer(ATRACE_TAG, name) 104 | #define KPI_ATRACE_CALL() KPI_ATRACE_NAME(__FUNCTION__) 105 | #define ATRACE_CALL() ATRACE_NAME(__FUNCTION__) 106 | 107 | namespace qcamera { 108 | extern volatile uint32_t gKpiDebugLevel; 109 | class ScopedTraceKpi { 110 | public: 111 | inline ScopedTraceKpi(uint64_t tag, const char *name) 112 | : mTag(tag) { 113 | if (gKpiDebugLevel >= KPI_ONLY) { 114 | atrace_begin(mTag,name); 115 | } 116 | } 117 | 118 | inline ~ScopedTraceKpi() { 119 | if (gKpiDebugLevel >= KPI_ONLY) { 120 | atrace_end(mTag); 121 | } 122 | } 123 | 124 | private: 125 | uint64_t mTag; 126 | }; 127 | 128 | class ScopedTraceDbg { 129 | public: 130 | inline ScopedTraceDbg(uint64_t tag, const char *name) 131 | : mTag(tag) { 132 | if (gKpiDebugLevel >= KPI_DBG) { 133 | atrace_begin(mTag,name); 134 | } 135 | } 136 | 137 | inline ~ScopedTraceDbg() { 138 | if (gKpiDebugLevel >= KPI_DBG) { 139 | atrace_end(mTag); 140 | } 141 | } 142 | 143 | private: 144 | uint64_t mTag; 145 | }; 146 | }; 147 | 148 | extern volatile uint32_t gKpiDebugLevel; 149 | 150 | #endif /* __QCAMREATRACE_H__ */ 151 | -------------------------------------------------------------------------------- /camera/mm-image-codec/Android.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm arm64)) 2 | include $(call all-subdir-makefiles) 3 | endif 4 | -------------------------------------------------------------------------------- /camera/mm-image-codec/qomx_core/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | # ------------------------------------------------------------------------------ 4 | # Make the shared library (libqomx_core) 5 | # ------------------------------------------------------------------------------ 6 | 7 | include $(CLEAR_VARS) 8 | LOCAL_MODULE_TAGS := optional 9 | 10 | LOCAL_CFLAGS := -g -O0 11 | 12 | LOCAL_C_INCLUDES := frameworks/native/include/media/openmax \ 13 | $(LOCAL_PATH)/../qexif 14 | 15 | LOCAL_INC_FILES := qomx_core.h \ 16 | QOMX_JpegExtensions.h 17 | 18 | LOCAL_SRC_FILES := qomx_core.c 19 | 20 | LOCAL_MODULE := libqomx_core 21 | LOCAL_VENDOR_MODULE := true 22 | LOCAL_PRELINK_MODULE := false 23 | LOCAL_SHARED_LIBRARIES := libcutils libdl liblog 24 | 25 | LOCAL_32_BIT_ONLY := true 26 | include $(BUILD_SHARED_LIBRARY) 27 | -------------------------------------------------------------------------------- /camera/mm-image-codec/qomx_core/qomx_core.h: -------------------------------------------------------------------------------- 1 | /*Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above 9 | copyright notice, this list of conditions and the following 10 | disclaimer in the documentation and/or other materials provided 11 | with the distribution. 12 | * Neither the name of The Linux Foundation nor the names of its 13 | contributors may be used to endorse or promote products derived 14 | from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/ 27 | 28 | #ifndef QOMX_CORE_H 29 | #define QOMX_CORE_H 30 | 31 | // To remove (after PanoNative is updated) 32 | #include 33 | 34 | // System dependencies 35 | #include 36 | 37 | // OpenMAX dependencies 38 | #include "OMX_Component.h" 39 | 40 | #define TRUE 1 41 | #define FALSE 0 42 | #define OMX_COMP_MAX_INSTANCES 3 43 | #define OMX_CORE_MAX_ROLES 1 44 | #define OMX_COMP_MAX_NUM 3 45 | #define OMX_SPEC_VERSION 0x00000101 46 | 47 | typedef void *(*get_instance_t)(void); 48 | typedef void *(*create_comp_func_t)(OMX_PTR aobj); 49 | 50 | /** comp_info_t: Structure containing the mapping 51 | * between the library name and the corresponding .so name 52 | * @comp_name: name of the component 53 | @lib_name: Name of the .so library 54 | **/ 55 | typedef struct comp_info_t { 56 | char *comp_name; 57 | char *lib_name; 58 | } comp_info_t; 59 | 60 | /** omx_core_component_t: OMX Component structure 61 | * @handle: array of number of instances of the component 62 | * @roles: array of roles played by the component 63 | * @comp_info: Component information such as libname, 64 | * component name 65 | * @open: Is the component active 66 | * @lib_handle: Library handle after dlopen 67 | * @obj_ptr: Function ptr to get the instance of the component 68 | * @comp_func_ptr: Function ptr to map the functions in the 69 | * OMX handle to its respective function implementation in 70 | * the component 71 | **/ 72 | typedef struct _omx_core_component_t { 73 | OMX_HANDLETYPE *handle[OMX_COMP_MAX_INSTANCES]; //Instance handle 74 | char *roles[OMX_CORE_MAX_ROLES]; //Roles played by the component 75 | char *name; //Component Name 76 | uint8_t open; //Is component active 77 | void *lib_handle; 78 | get_instance_t get_instance; 79 | create_comp_func_t create_comp_func; 80 | char *comp_name; 81 | char *lib_name; 82 | } omx_core_component_t; 83 | 84 | /** omx_core_t: Global structure that contains all the active 85 | * components 86 | * @component: array of active components 87 | * @is_initialized: Flag to check if the OMX core has been 88 | * initialized 89 | * @core_lock: Lock to syncronize the omx core operations 90 | **/ 91 | typedef struct _omx_core_t { 92 | omx_core_component_t component[OMX_COMP_MAX_NUM]; //Array of pointers to components 93 | int comp_cnt; 94 | pthread_mutex_t core_lock; 95 | } omx_core_t; 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /camera/usbcamcore/inc/QCameraMjpegDecode.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. 2 | * 3 | * Redistribution and use in source and binary forms, with or without 4 | * modification, are permitted provided that the following conditions are 5 | * met: 6 | * * Redistributions of source code must retain the above copyright 7 | * notice, this list of conditions and the following disclaimer. 8 | * * Redistributions in binary form must reproduce the above 9 | * copyright notice, this list of conditions and the following 10 | * disclaimer in the documentation and/or other materials provided 11 | * with the distribution. 12 | * * Neither the name of The Linux Foundation nor the names of its 13 | * contributors may be used to endorse or promote products derived 14 | * from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef __QCAMERA_MJPEG_DECODE_H 30 | #define __QCAMERA_MJPEG_DECODE_H 31 | 32 | typedef int MJPEGD_ERR; 33 | #define MJPEGD_NO_ERROR 0 34 | #define MJPEGD_ERROR -1 35 | #define MJPEGD_INSUFFICIENT_MEM -2 36 | 37 | MJPEGD_ERR mjpegDecoderInit(void**); 38 | 39 | MJPEGD_ERR mjpegDecoderDestroy(void* mjpegd); 40 | 41 | MJPEGD_ERR mjpegDecode( 42 | void* mjpegd, 43 | char* mjpegBuffer, 44 | int mjpegBufferSize, 45 | char* outputYptr, 46 | char* outputUVptr, 47 | int outputFormat); 48 | 49 | #endif /* __QCAMERA_MJPEG_DECODE_H */ 50 | -------------------------------------------------------------------------------- /consumerir/Android.bp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2017-2018 The LineageOS 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 | cc_binary { 17 | name: "android.hardware.ir@1.0-service.xiaomi_mido", 18 | relative_install_path: "hw", 19 | defaults: ["hidl_defaults"], 20 | init_rc: ["android.hardware.ir@1.0-service.xiaomi_mido.rc"], 21 | srcs: ["service.cpp", "ConsumerIr.cpp"], 22 | shared_libs: [ 23 | "libbase", 24 | "libhardware", 25 | "libhidlbase", 26 | "libhidltransport", 27 | "libhwbinder", 28 | "libutils", 29 | "android.hardware.ir@1.0", 30 | ], 31 | proprietary: true, 32 | } 33 | -------------------------------------------------------------------------------- /consumerir/ConsumerIr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2018 The LineageOS 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 "ConsumerIrService" 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | #include "ConsumerIr.h" 25 | 26 | namespace android { 27 | namespace hardware { 28 | namespace ir { 29 | namespace V1_0 { 30 | namespace implementation { 31 | 32 | #define LIRC_DEV_PATH "/dev/lirc0" 33 | 34 | static const int dutyCycle = 33; 35 | 36 | static hidl_vec rangeVec{ 37 | {.min = 30000, .max = 60000}, 38 | }; 39 | 40 | static int openLircDev() { 41 | int fd = open(LIRC_DEV_PATH, O_RDWR); 42 | 43 | if (fd < 0) { 44 | LOG(ERROR) << "failed to open " << LIRC_DEV_PATH << ", error " << fd; 45 | } 46 | 47 | return fd; 48 | } 49 | 50 | // Methods from ::android::hardware::ir::V1_0::IConsumerIr follow. 51 | Return ConsumerIr::transmit(int32_t carrierFreq, const hidl_vec& pattern) { 52 | size_t entries = pattern.size(); 53 | int rc; 54 | int lircFd; 55 | 56 | lircFd = openLircDev(); 57 | if (lircFd < 0) { 58 | return lircFd; 59 | } 60 | 61 | rc = ioctl(lircFd, LIRC_SET_SEND_CARRIER, &carrierFreq); 62 | if (rc < 0) { 63 | LOG(ERROR) << "failed to set carrier " << carrierFreq << ", error: " << errno; 64 | goto out_close; 65 | } 66 | 67 | rc = ioctl(lircFd, LIRC_SET_SEND_DUTY_CYCLE, &dutyCycle); 68 | if (rc < 0) { 69 | LOG(ERROR) << "failed to set duty cycle " << dutyCycle << ", error: " << errno; 70 | goto out_close; 71 | } 72 | 73 | if ((entries & 1) != 0) { 74 | rc = write(lircFd, pattern.data(), sizeof(int32_t) * entries); 75 | } else { 76 | rc = write(lircFd, pattern.data(), sizeof(int32_t) * (entries - 1)); 77 | usleep(pattern[entries - 1]); 78 | } 79 | 80 | if (rc < 0) { 81 | LOG(ERROR) << "failed to write pattern " << pattern.size() << ", error: " << errno; 82 | goto out_close; 83 | } 84 | 85 | rc = 0; 86 | 87 | out_close: 88 | close(lircFd); 89 | 90 | return rc == 0; 91 | } 92 | 93 | Return ConsumerIr::getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) { 94 | _hidl_cb(true, rangeVec); 95 | return Void(); 96 | } 97 | 98 | } // namespace implementation 99 | } // namespace V1_0 100 | } // namespace ir 101 | } // namespace hardware 102 | } // namespace android 103 | -------------------------------------------------------------------------------- /consumerir/ConsumerIr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2018 The LineageOS 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_HARDWARE_IR_V1_0_IR_H 18 | #define ANDROID_HARDWARE_IR_V1_0_IR_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | namespace android { 25 | namespace hardware { 26 | namespace ir { 27 | namespace V1_0 { 28 | namespace implementation { 29 | 30 | using ::android::hardware::Return; 31 | using ::android::hardware::Void; 32 | using ::android::hardware::hidl_vec; 33 | using ::android::hardware::ir::V1_0::ConsumerIrFreqRange; 34 | using ::android::hardware::ir::V1_0::IConsumerIr; 35 | 36 | class ConsumerIr : public IConsumerIr { 37 | // Methods from ::android::hardware::ir::V1_0::IConsumerIr follow. 38 | Return transmit(int32_t carrierFreq, const hidl_vec& pattern) override; 39 | Return getCarrierFreqs(getCarrierFreqs_cb _hidl_cb) override; 40 | }; 41 | 42 | } // namespace implementation 43 | } // namespace V1_0 44 | } // namespace ir 45 | } // namespace hardware 46 | } // namespace android 47 | 48 | #endif // ANDROID_HARDWARE_IR_V1_0_IR_H 49 | -------------------------------------------------------------------------------- /consumerir/android.hardware.ir@1.0-service.xiaomi_mido.rc: -------------------------------------------------------------------------------- 1 | service ir-hal-1-0 /vendor/bin/hw/android.hardware.ir@1.0-service.xiaomi_mido 2 | class hal 3 | user system 4 | group system 5 | -------------------------------------------------------------------------------- /consumerir/service.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017-2018 The LineageOS 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 "android.hardware.ir@1.0-service.xiaomi_8996" 18 | 19 | #include 20 | #include 21 | 22 | #include "ConsumerIr.h" 23 | 24 | // libhwbinder: 25 | using android::hardware::configureRpcThreadpool; 26 | using android::hardware::joinRpcThreadpool; 27 | 28 | // Generated HIDL files 29 | using android::hardware::ir::V1_0::IConsumerIr; 30 | using android::hardware::ir::V1_0::implementation::ConsumerIr; 31 | 32 | int main() { 33 | android::sp service = new ConsumerIr(); 34 | 35 | configureRpcThreadpool(1, true /*callerWillJoin*/); 36 | 37 | android::status_t status = service->registerAsService(); 38 | if (status != android::OK) { 39 | LOG(ERROR) << "Cannot register ConsumerIr HAL service"; 40 | return 1; 41 | } 42 | 43 | LOG(INFO) << "ConsumerIr HAL Ready."; 44 | joinRpcThreadpool(); 45 | // Under normal cases, execution will not reach this line. 46 | LOG(ERROR) << "ConsumerIr HAL failed to join thread pool."; 47 | return 1; 48 | } 49 | -------------------------------------------------------------------------------- /device.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2017-2019 The LineageOS 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 | $(call inherit-product, vendor/xiaomi/mido/mido-vendor.mk) 18 | $(call inherit-product, $(SRC_TARGET_DIR)/product/product_launched_with_m.mk) 19 | 20 | # Overlay 21 | DEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/overlay 22 | DEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/overlay-lineage 23 | 24 | # Inherit from msm8953-common 25 | $(call inherit-product, device/xiaomi/msm8953-common/msm8953.mk) 26 | 27 | # Audio configuration 28 | PRODUCT_COPY_FILES += \ 29 | $(LOCAL_PATH)/audio/audio_platform_info.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_platform_info.xml \ 30 | $(LOCAL_PATH)/audio/mixer_paths_mtp.xml:$(TARGET_COPY_OUT_VENDOR)/etc/mixer_paths_mtp.xml 31 | 32 | # Fingerprint 33 | PRODUCT_PACKAGES += \ 34 | android.hardware.biometrics.fingerprint@2.1-service.xiaomi_mido 35 | 36 | PRODUCT_COPY_FILES += \ 37 | frameworks/native/data/etc/android.hardware.fingerprint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.fingerprint.xml 38 | 39 | # Consumerir 40 | PRODUCT_PACKAGES += \ 41 | android.hardware.ir@1.0-service.xiaomi_mido 42 | 43 | PRODUCT_COPY_FILES += \ 44 | frameworks/native/data/etc/android.hardware.consumerir.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.consumerir.xml 45 | 46 | # Properties 47 | -include $(LOCAL_PATH)/prop.mk 48 | 49 | # Ramdisk 50 | PRODUCT_PACKAGES += \ 51 | init.mido.rc \ 52 | init.goodix.sh 53 | 54 | # Sensors 55 | PRODUCT_COPY_FILES += \ 56 | $(LOCAL_PATH)/configs/sensors/sensor_def_qcomdev.conf:$(TARGET_COPY_OUT_VENDOR)/etc/sensors/sensor_def_qcomdev.conf 57 | 58 | # Lineage hardware 59 | PRODUCT_PACKAGES += \ 60 | vendor.lineage.touch@1.0-service.xiaomi_8953 61 | -------------------------------------------------------------------------------- /extract-files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2017 The LineageOS Project 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | set -e 19 | 20 | # Required! 21 | export DEVICE=mido 22 | export DEVICE_COMMON=msm8953-common 23 | export VENDOR=xiaomi 24 | 25 | export DEVICE_BRINGUP_YEAR=2017 26 | 27 | ./../../$VENDOR/$DEVICE_COMMON/extract-files.sh $@ 28 | -------------------------------------------------------------------------------- /lineage.dependencies: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "repository": "android_device_xiaomi_msm8953-common", 4 | "target_path": "device/xiaomi/msm8953-common" 5 | }, 6 | { 7 | "repository": "android_kernel_xiaomi_mido", 8 | "target_path": "kernel/xiaomi/msm8953" 9 | } 10 | ] 11 | -------------------------------------------------------------------------------- /lineage_mido.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2017 The LineageOS 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 | # Inherit from those products. Most specific first. 18 | $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk) 19 | $(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk) 20 | 21 | # Inherit from mido device 22 | $(call inherit-product, device/xiaomi/mido/device.mk) 23 | 24 | # Inherit some common LineageOS stuff. 25 | $(call inherit-product, vendor/lineage/config/common_full_phone.mk) 26 | 27 | # Device identifier. This must come after all inclusions 28 | PRODUCT_DEVICE := mido 29 | PRODUCT_NAME := lineage_mido 30 | PRODUCT_BRAND := Xiaomi 31 | PRODUCT_MODEL := Redmi Note 4 32 | PRODUCT_MANUFACTURER := Xiaomi 33 | TARGET_VENDOR := Xiaomi 34 | BOARD_VENDOR := Xiaomi 35 | 36 | PRODUCT_GMS_CLIENTID_BASE := android-xiaomi 37 | 38 | PRODUCT_BUILD_PROP_OVERRIDES += \ 39 | PRIVATE_BUILD_DESC="mido-user 7.0 NRD90M V9.6.1.0.NCFMIFD release-keys" 40 | 41 | # Set BUILD_FINGERPRINT variable to be picked up by both system and vendor build.prop 42 | BUILD_FINGERPRINT := "xiaomi/mido/mido:7.0/NRD90M/V9.6.1.0.NCFMIFD:user/release-keys" 43 | -------------------------------------------------------------------------------- /lineagehw/src/org/lineageos/hardware/HighTouchSensitivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 The LineagsOs 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 | package org.lineageos.hardware; 18 | 19 | import org.lineageos.internal.util.FileUtils; 20 | 21 | /** 22 | * Glove mode / high touch sensitivity 23 | */ 24 | public class HighTouchSensitivity { 25 | private static final String CONTROL_PATH = "/sys/class/tp_glove/device/glove_enable"; 26 | 27 | public static boolean isSupported() { 28 | return FileUtils.isFileWritable(CONTROL_PATH); 29 | } 30 | 31 | public static boolean isEnabled() { 32 | return FileUtils.readOneLine(CONTROL_PATH).equals("1"); 33 | } 34 | 35 | public static boolean setEnabled(boolean state) { 36 | return FileUtils.writeLine(CONTROL_PATH, state ? "1" : "0"); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | vendor.lineage.touch 4 | hwbinder 5 | 1.0 6 | 7 | IKeyDisabler 8 | default 9 | 10 | 11 | 12 | vendor.qti.hardware.radio.qtiradio 13 | hwbinder 14 | 1.0 15 | 16 | IQtiRadio 17 | slot1 18 | slot2 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /overlay-lineage/lineage-sdk/lineage/res/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 27 | 107 28 | 29 | -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 16 | 17 | 18 | 19 | com.google.android.gms/com.google.android.gms.nearby.messages.service.NearbyMessagesService 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /overlay/frameworks/base/core/res/res/xml/power_profile.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 63 4 | 261 5 | 6 | 200000 7 | 499200 8 | 533333 9 | 800000 10 | 998400 11 | 1094400 12 | 1209600 13 | 14 | 15 | 151 16 | 169 17 | 177 18 | 195 19 | 259 20 | 307 21 | 353 22 | 23 | 1.6 24 | 1.6 25 | 4100 26 | 27 | -------------------------------------------------------------------------------- /overlay/packages/apps/Settings/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 5dp 16 | 50.0% 17 | 29.999996% 18 | 19 | -------------------------------------------------------------------------------- /overlay/packages/apps/Settings/res/values/lineage_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 24 | 0 25 | 26 | -------------------------------------------------------------------------------- /prop.mk: -------------------------------------------------------------------------------- 1 | # Audio 2 | PRODUCT_PROPERTY_OVERRIDES += \ 3 | persist.vendor.audio.fluence.speaker=true \ 4 | persist.vendor.audio.fluence.voicecall=true \ 5 | persist.vendor.audio.fluence.voicerec=false \ 6 | ro.vendor.audio.sdk.fluencetype=fluence 7 | -------------------------------------------------------------------------------- /rootdir/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | # Device Script 4 | include $(CLEAR_VARS) 5 | LOCAL_MODULE := init.mido.rc 6 | LOCAL_MODULE_TAGS := optional eng 7 | LOCAL_MODULE_CLASS := ETC 8 | LOCAL_SRC_FILES := init.mido.rc 9 | LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC)/init 10 | include $(BUILD_PREBUILT) 11 | 12 | include $(CLEAR_VARS) 13 | LOCAL_MODULE := init.goodix.sh 14 | LOCAL_MODULE_TAGS := optional eng 15 | LOCAL_MODULE_CLASS := ETC 16 | LOCAL_SRC_FILES := init.goodix.sh 17 | LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) 18 | include $(BUILD_PREBUILT) 19 | -------------------------------------------------------------------------------- /rootdir/init.goodix.sh: -------------------------------------------------------------------------------- 1 | #! /vendor/bin/sh 2 | 3 | # Copyright (c) 2009-2016, The Linux Foundation. All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # * Redistributions of source code must retain the above copyright 8 | # notice, this list of conditions and the following disclaimer. 9 | # * Redistributions in binary form must reproduce the above copyright 10 | # notice, this list of conditions and the following disclaimer in the 11 | # documentation and/or other materials provided with the distribution. 12 | # * Neither the name of The Linux Foundation nor 13 | # the names of its contributors may be used to endorse or promote 14 | # products derived from this software without specific prior written 15 | # permission. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 21 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 22 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 23 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 24 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 27 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | # 29 | 30 | if [ ! -f /data/system/users/0/settings_fingerprint.xml ]; then 31 | rm -rf /persist/data/gxfp/0_0 32 | fi 33 | -------------------------------------------------------------------------------- /rootdir/init.mido.rc: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009-2012, 2014-2017, The Linux Foundation. All rights reserved. 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # * Redistributions of source code must retain the above copyright 6 | # notice, this list of conditions and the following disclaimer. 7 | # * Redistributions in binary form must reproduce the above copyright 8 | # notice, this list of conditions and the following disclaimer in the 9 | # documentation and/or other materials provided with the distribution. 10 | # * Neither the name of The Linux Foundation nor 11 | # the names of its contributors may be used to endorse or promote 12 | # products derived from this software without specific prior written 13 | # permission. 14 | # 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 19 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 22 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 23 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 25 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | # 27 | 28 | on boot 29 | # Glove Mode 30 | chown system system /sys/class/tp_glove/device/glove_enable 31 | chmod 0660 /sys/class/tp_glove/device/glove_enable 32 | 33 | service goodix_script /vendor/bin/init.goodix.sh 34 | class late_start 35 | user root 36 | oneshot 37 | -------------------------------------------------------------------------------- /sepolicy/genfs_contexts: -------------------------------------------------------------------------------- 1 | # Power 2 | genfscon sysfs /devices/soc/msm-bcl-20/power_supply u:object_r:sysfs_batteryinfo:s0 3 | -------------------------------------------------------------------------------- /sepolicy/private/service_contexts: -------------------------------------------------------------------------------- 1 | goodix.fp u:object_r:gx_fpd_service:s0 2 | android.hardware.fingerprint.IFingerprintCustomDaemon u:object_r:hal_fingerprint_mido_service:s0 3 | -------------------------------------------------------------------------------- /sepolicy/vendor/file_contexts: -------------------------------------------------------------------------------- 1 | # Glove Mode 2 | /sys/class/tp_glove/tp_glove/glove_enable u:object_r:proc_touchpanel:s0 3 | 4 | # Goodix Fingerprint 5 | /(vendor|system/vendor)/bin/gx_fpd u:object_r:gx_fpd_exec:s0 6 | 7 | # Ir 8 | /dev/lirc[0-9]* u:object_r:lirc_device:s0 9 | 10 | # HALs 11 | /(vendor|system/vendor)/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.1-service\.xiaomi_mido u:object_r:hal_fingerprint_mido_exec:s0 12 | /(vendor|system/vendor)/bin/hw/android\.hardware\.ir@1\.0-service\.xiaomi_mido u:object_r:hal_ir_default_exec:s0 13 | -------------------------------------------------------------------------------- /sepolicy/vendor/gx_fpd.te: -------------------------------------------------------------------------------- 1 | type gx_fpd, domain, binder_in_vendor_violators; 2 | typeattribute gx_fpd data_between_core_and_vendor_violators; 3 | type gx_fpd_exec, exec_type, vendor_file_type, file_type; 4 | 5 | # gx_fpd 6 | init_daemon_domain(gx_fpd) 7 | binder_use(gx_fpd) 8 | 9 | # allow HAL module to read dir contents 10 | allow gx_fpd gx_fpd_data_file:file create_file_perms; 11 | 12 | # allow HAL module to read/write/unlink contents of this dir 13 | allow gx_fpd gx_fpd_data_file:dir create_dir_perms; 14 | 15 | #Allow access to goodix device 16 | allow gx_fpd gx_fpd_device:chr_file rw_file_perms; 17 | 18 | #Allow access to tee device 19 | allow gx_fpd tee_device:chr_file rw_file_perms; 20 | 21 | # Allow access to ion device 22 | allow gx_fpd ion_device:chr_file rw_file_perms; 23 | 24 | #allow create socket 25 | allow gx_fpd self:socket create_socket_perms_no_ioctl; 26 | allow gx_fpd self:{ netlink_socket netlink_generic_socket } create_socket_perms_no_ioctl; 27 | 28 | #allow read/write property 29 | set_prop(gx_fpd, system_prop) 30 | 31 | allow gx_fpd gx_fpd_service:service_manager { add find }; 32 | 33 | allow gx_fpd hal_fingerprint_mido:binder { transfer call }; 34 | allow gx_fpd fuse:dir search; 35 | allow gx_fpd fuse:file { getattr open append }; 36 | allow gx_fpd storage_file:dir search; 37 | allow gx_fpd storage_file:lnk_file read; 38 | allow gx_fpd mnt_user_file:dir search; 39 | r_dir_file(gx_fpd, firmware_file) 40 | 41 | #register service in service manager 42 | allow gx_fpd default_android_service:service_manager find; 43 | 44 | add_service(gx_fpd, gx_fpd_service); 45 | -------------------------------------------------------------------------------- /sepolicy/vendor/hal_camera_default.te: -------------------------------------------------------------------------------- 1 | typeattribute hal_camera_default data_between_core_and_vendor_violators; 2 | 3 | allow hal_camera_default camera_data_file:dir search; 4 | allow hal_camera_default camera_socket:sock_file write; 5 | -------------------------------------------------------------------------------- /sepolicy/vendor/hal_fingerprint_mido.te: -------------------------------------------------------------------------------- 1 | type hal_fingerprint_mido, domain, binder_in_vendor_violators; 2 | typeattribute hal_fingerprint_mido data_between_core_and_vendor_violators; 3 | hal_server_domain(hal_fingerprint_mido, hal_fingerprint) 4 | 5 | type hal_fingerprint_mido_exec, exec_type, vendor_file_type, file_type; 6 | binder_use(hal_fingerprint_mido) 7 | init_daemon_domain(hal_fingerprint_mido) 8 | 9 | allow hal_fingerprint_mido gx_fpd:binder { transfer call }; 10 | allow hal_fingerprint_mido gx_fpd_service:service_manager find; 11 | allow hal_fingerprint_mido fingerprint_service:service_manager find; 12 | allow hal_fingerprint_mido fpc_sysfs:file rw_file_perms; 13 | allow hal_fingerprint_mido fpc_sysfs:dir r_dir_perms; 14 | allow hal_fingerprint_mido tee_device:chr_file rw_file_perms; 15 | allow hal_fingerprint_mido uhid_device:chr_file rw_file_perms; 16 | allow hal_fingerprint_mido fpc_data_file:dir rw_dir_perms; 17 | allow hal_fingerprint_mido fpc_data_file:sock_file create_file_perms; 18 | allow hal_fingerprint_mido servicemanager:binder { transfer call }; 19 | allow hal_fingerprint_mido fingerprintd_data_file:dir { write add_name remove_name search}; 20 | allow hal_fingerprint_mido fingerprintd_data_file:file { getattr rename }; 21 | allow hal_fingerprint_mido vfat:file { getattr open read }; 22 | allow hal_fingerprint_mido fingerprintd_data_file:file unlink; 23 | allow hal_fingerprint_mido media_rw_data_file:dir { open read search }; 24 | allow hal_fingerprint_mido mnt_user_file:dir search; 25 | allow hal_fingerprint_mido mnt_user_file:lnk_file read; 26 | allow hal_fingerprint_mido sdcardfs:dir search; 27 | allow hal_fingerprint_mido storage_file:dir search; 28 | allow hal_fingerprint_mido storage_file:lnk_file read; 29 | 30 | set_prop(hal_fingerprint_mido, system_prop) 31 | r_dir_file(hal_fingerprint_mido, firmware_file) 32 | 33 | add_service(hal_fingerprint_mido, hal_fingerprint_mido_service); 34 | 35 | # Need to add auth tokens to KeyStore 36 | use_keystore(hal_fingerprint_mido) 37 | allow hal_fingerprint_mido keystore:keystore_key { add_auth }; 38 | # need to find KeyStore and add self 39 | allow hal_fingerprint_mido hal_fingerprint_mido_service:service_manager { add find }; 40 | 41 | allow hal_fingerprint_mido keystore_service:service_manager find; 42 | 43 | # For permissions checking 44 | binder_call(hal_fingerprint_mido, system_server); 45 | allow hal_fingerprint_mido permission_service:service_manager find; 46 | -------------------------------------------------------------------------------- /sepolicy/vendor/mm-qcamerad.te: -------------------------------------------------------------------------------- 1 | typeattribute mm-qcamerad data_between_core_and_vendor_violators; 2 | 3 | allow mm-qcamerad camera_data_file:sock_file unlink; 4 | -------------------------------------------------------------------------------- /sepolicy/vendor/service.te: -------------------------------------------------------------------------------- 1 | type gx_fpd_service, service_manager_type; 2 | type hal_fingerprint_mido_service, service_manager_type; 3 | -------------------------------------------------------------------------------- /sepolicy/vendor/tee.te: -------------------------------------------------------------------------------- 1 | typeattribute tee data_between_core_and_vendor_violators; 2 | 3 | allow tee fingerprintd_data_file:dir rw_dir_perms; 4 | allow tee fingerprintd_data_file:file create_file_perms; 5 | -------------------------------------------------------------------------------- /setup-makefiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Copyright (C) 2016 The CyanogenMod Project 4 | # Copyright (C) 2017 The LineageOS Project 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | set -e 20 | 21 | # Required! 22 | export DEVICE=mido 23 | export DEVICE_COMMON=msm8953-common 24 | export VENDOR=xiaomi 25 | 26 | export DEVICE_BRINGUP_YEAR=2017 27 | 28 | ./../../$VENDOR/$DEVICE_COMMON/setup-makefiles.sh $@ 29 | --------------------------------------------------------------------------------