├── Android.mk ├── CleanSpec.mk ├── MODULE_LICENSE_BSD ├── QCamera2 ├── Android.mk ├── HAL │ ├── 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 │ ├── test │ │ ├── Android.mk │ │ └── qcamera_test.cpp │ ├── 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 ├── QCamera2Factory.cpp ├── QCamera2Factory.h ├── QCamera2Hal.cpp ├── stack │ ├── Android.mk │ ├── common │ │ ├── cam_intf.h │ │ ├── cam_list.h │ │ ├── cam_queue.h │ │ ├── cam_semaphore.h │ │ ├── cam_types.h │ │ ├── mm_camera_interface.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-camera-test │ │ ├── Android.mk │ │ ├── inc │ │ │ ├── mm_qcamera_app.h │ │ │ ├── mm_qcamera_commands.h │ │ │ ├── mm_qcamera_dbg.h │ │ │ ├── mm_qcamera_main_menu.h │ │ │ └── mm_qcamera_socket.h │ │ └── src │ │ │ ├── mm_qcamera_app.c │ │ │ ├── mm_qcamera_commands.c │ │ │ ├── mm_qcamera_dual_test.c │ │ │ ├── mm_qcamera_main_menu.c │ │ │ ├── mm_qcamera_preview.c │ │ │ ├── mm_qcamera_queue.c │ │ │ ├── mm_qcamera_rdi.c │ │ │ ├── mm_qcamera_reprocess.c │ │ │ ├── mm_qcamera_snapshot.c │ │ │ ├── mm_qcamera_socket.c │ │ │ ├── mm_qcamera_unit_test.c │ │ │ └── mm_qcamera_video.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 └── util │ ├── QCameraBufferMaps.cpp │ ├── QCameraBufferMaps.h │ ├── QCameraCmdThread.cpp │ ├── QCameraCmdThread.h │ ├── QCameraDisplay.cpp │ ├── QCameraDisplay.h │ ├── QCameraFlash.cpp │ ├── QCameraFlash.h │ ├── QCameraPerf.cpp │ ├── QCameraPerf.h │ ├── QCameraQueue.cpp │ ├── QCameraQueue.h │ └── QCameraTrace.h ├── QCameraParameters.h ├── QCamera_Intf.h ├── common.mk ├── 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 /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 += thorium 17 | MM_V4L2_DRIVER_LIST += titanium 18 | MM_V4L2_DRIVER_LIST += msmcobalt 19 | 20 | ifneq (,$(filter $(MM_V4L2_DRIVER_LIST),$(TARGET_BOARD_PLATFORM))) 21 | ifneq ($(strip $(USE_CAMERA_STUB)),true) 22 | ifneq ($(BUILD_TINY_ANDROID),true) 23 | include $(call all-subdir-makefiles) 24 | endif 25 | endif 26 | endif 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /MODULE_LICENSE_BSD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OnePlusOSS/android_hardware_qcom_camera/fab5e9d464852b4c512c78bc92b6578d447e61a7/MODULE_LICENSE_BSD -------------------------------------------------------------------------------- /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_SRC_FILES := \ 8 | util/QCameraCmdThread.cpp \ 9 | util/QCameraQueue.cpp \ 10 | util/QCameraBufferMaps.cpp \ 11 | util/QCameraFlash.cpp \ 12 | util/QCameraPerf.cpp \ 13 | util/QCameraDisplay.cpp \ 14 | QCamera2Hal.cpp \ 15 | QCamera2Factory.cpp 16 | 17 | #HAL 3.0 source 18 | LOCAL_SRC_FILES += \ 19 | HAL3/QCamera3HWI.cpp \ 20 | HAL3/QCamera3Mem.cpp \ 21 | HAL3/QCamera3Stream.cpp \ 22 | HAL3/QCamera3Channel.cpp \ 23 | HAL3/QCamera3VendorTags.cpp \ 24 | HAL3/QCamera3PostProc.cpp \ 25 | HAL3/QCamera3CropRegionMapper.cpp \ 26 | HAL3/QCamera3StreamMem.cpp 27 | 28 | #HAL 1.0 source 29 | LOCAL_SRC_FILES += \ 30 | HAL/QCamera2HWI.cpp \ 31 | HAL/QCameraMuxer.cpp \ 32 | HAL/QCameraMem.cpp \ 33 | HAL/QCameraStateMachine.cpp \ 34 | HAL/QCameraChannel.cpp \ 35 | HAL/QCameraStream.cpp \ 36 | HAL/QCameraPostProc.cpp \ 37 | HAL/QCamera2HWICallbacks.cpp \ 38 | HAL/QCameraParametersIntf.cpp \ 39 | HAL/QCameraParameters.cpp \ 40 | HAL/QCameraThermalAdapter.cpp 41 | 42 | LOCAL_CFLAGS := -Wall -Wextra -Werror 43 | 44 | LOCAL_CFLAGS += -DHAS_MULTIMEDIA_HINTS -D_ANDROID_ 45 | 46 | ifeq ($(TARGET_USES_AOSP),true) 47 | LOCAL_CFLAGS += -DVANILLA_HAL 48 | endif 49 | 50 | #HAL 1.0 Flags 51 | LOCAL_CFLAGS += -DDEFAULT_DENOISE_MODE_ON -DHAL3 -DQCAMERA_REDEFINE_LOG 52 | 53 | LOCAL_C_INCLUDES := \ 54 | $(LOCAL_PATH)/stack/common \ 55 | $(LOCAL_PATH)/stack/mm-camera-interface/inc \ 56 | frameworks/native/include/media/hardware \ 57 | frameworks/native/include/media/openmax \ 58 | hardware/qcom/media/libstagefrighthw \ 59 | system/media/camera/include \ 60 | $(LOCAL_PATH)/../mm-image-codec/qexif \ 61 | $(LOCAL_PATH)/../mm-image-codec/qomx_core \ 62 | $(LOCAL_PATH)/util \ 63 | hardware/qcom/media/mm-core/inc 64 | 65 | #HAL 1.0 Include paths 66 | LOCAL_C_INCLUDES += \ 67 | frameworks/native/include/media/hardware \ 68 | hardware/qcom/camera/QCamera2/HAL 69 | 70 | ifeq ($(TARGET_COMPILE_WITH_MSM_KERNEL),true) 71 | LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include 72 | LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 73 | endif 74 | ifeq ($(TARGET_TS_MAKEUP),true) 75 | LOCAL_CFLAGS += -DTARGET_TS_MAKEUP 76 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/HAL/tsMakeuplib/include 77 | endif 78 | ifneq (,$(filter msm8974 msm8916 msm8226 msm8610 msm8916 apq8084 msm8084 msm8994 msm8992 msm8952 msm8996,$(TARGET_BOARD_PLATFORM))) 79 | LOCAL_CFLAGS += -DVENUS_PRESENT 80 | endif 81 | 82 | ifneq (,$(filter msm8996,$(TARGET_BOARD_PLATFORM))) 83 | LOCAL_CFLAGS += -DUBWC_PRESENT 84 | endif 85 | 86 | #LOCAL_STATIC_LIBRARIES := libqcamera2_util 87 | LOCAL_C_INCLUDES += \ 88 | $(TARGET_OUT_HEADERS)/qcom/display 89 | LOCAL_C_INCLUDES += \ 90 | hardware/qcom/display/libqservice 91 | LOCAL_SHARED_LIBRARIES := libcamera_client liblog libhardware libutils libcutils libdl libsync libgui 92 | LOCAL_SHARED_LIBRARIES += libmmcamera_interface libmmjpeg_interface libui libcamera_metadata 93 | LOCAL_SHARED_LIBRARIES += libqdMetaData libqservice libbinder 94 | ifeq ($(TARGET_TS_MAKEUP),true) 95 | LOCAL_SHARED_LIBRARIES += libts_face_beautify_hal libts_detected_face_hal 96 | endif 97 | 98 | LOCAL_MODULE_RELATIVE_PATH := hw 99 | LOCAL_MODULE := camera.$(TARGET_BOARD_PLATFORM) 100 | LOCAL_CLANG := false 101 | LOCAL_MODULE_TAGS := optional 102 | 103 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 104 | include $(BUILD_SHARED_LIBRARY) 105 | 106 | include $(call first-makefiles-under,$(LOCAL_PATH)) 107 | 108 | endif 109 | -------------------------------------------------------------------------------- /QCamera2/HAL/QCameraAllocator.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2015, The Linux Foundataion. 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 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 | -------------------------------------------------------------------------------- /QCamera2/HAL/QCameraChannel.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2015, The Linux Foundataion. 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_CHANNEL_H__ 31 | #define __QCAMERA_CHANNEL_H__ 32 | 33 | #include 34 | #include 35 | #include "QCameraStream.h" 36 | 37 | extern "C" { 38 | #include 39 | } 40 | 41 | namespace qcamera { 42 | 43 | class QCameraChannel 44 | { 45 | public: 46 | QCameraChannel(uint32_t cam_handle, 47 | mm_camera_ops_t *cam_ops); 48 | QCameraChannel(); 49 | virtual ~QCameraChannel(); 50 | virtual int32_t init(mm_camera_channel_attr_t *attr, 51 | mm_camera_buf_notify_t dataCB, // data CB for channel data 52 | void *userData); 53 | // Owner of memory is transferred from the caller to the caller with this call. 54 | virtual int32_t addStream(QCameraAllocator& allocator, 55 | QCameraHeapMemory *streamInfoBuf, QCameraHeapMemory *miscBuf, 56 | uint8_t minStreamBufnum, cam_padding_info_t *paddingInfo, 57 | stream_cb_routine stream_cb, void *userdata, bool bDynAllocBuf, 58 | bool bDeffAlloc = false, cam_rotation_t online_rotation = ROTATE_0); 59 | virtual int32_t linkStream(QCameraChannel *ch, QCameraStream *stream); 60 | virtual int32_t start(); 61 | virtual int32_t stop(); 62 | virtual int32_t bufDone(mm_camera_super_buf_t *recvd_frame); 63 | virtual int32_t processZoomDone(preview_stream_ops_t *previewWindow, 64 | cam_crop_data_t &crop_info); 65 | QCameraStream *getStreamByHandle(uint32_t streamHandle); 66 | uint32_t getMyHandle() const {return m_handle;}; 67 | uint32_t getNumOfStreams() const {return (uint32_t) mStreams.size();}; 68 | QCameraStream *getStreamByIndex(uint32_t index); 69 | QCameraStream *getStreamByServerID(uint32_t serverID); 70 | int32_t UpdateStreamBasedParameters(QCameraParametersIntf ¶m); 71 | void deleteChannel(); 72 | int32_t setStreamSyncCB (cam_stream_type_t stream_type, 73 | stream_cb_routine stream_cb); 74 | 75 | protected: 76 | uint32_t m_camHandle; 77 | mm_camera_ops_t *m_camOps; 78 | bool m_bIsActive; 79 | bool m_bAllowDynBufAlloc; // if buf allocation can be in two steps 80 | 81 | uint32_t m_handle; 82 | Vector mStreams; 83 | mm_camera_buf_notify_t mDataCB; 84 | void *mUserData; 85 | }; 86 | 87 | // burst pic channel: i.e. zsl burst mode 88 | class QCameraPicChannel : public QCameraChannel 89 | { 90 | public: 91 | QCameraPicChannel(uint32_t cam_handle, 92 | mm_camera_ops_t *cam_ops); 93 | QCameraPicChannel(); 94 | virtual ~QCameraPicChannel(); 95 | int32_t takePicture(mm_camera_req_buf_t *buf); 96 | int32_t cancelPicture(); 97 | int32_t stopAdvancedCapture(mm_camera_advanced_capture_t type); 98 | int32_t startAdvancedCapture(mm_camera_advanced_capture_t type, 99 | cam_capture_frame_config_t *config = NULL); 100 | int32_t flushSuperbuffer(uint32_t frame_idx); 101 | }; 102 | 103 | // video channel class 104 | class QCameraVideoChannel : public QCameraChannel 105 | { 106 | public: 107 | QCameraVideoChannel(uint32_t cam_handle, 108 | mm_camera_ops_t *cam_ops); 109 | QCameraVideoChannel(); 110 | virtual ~QCameraVideoChannel(); 111 | int32_t releaseFrame(const void *opaque, bool isMetaData); 112 | }; 113 | 114 | // reprocess channel class 115 | class QCameraReprocessChannel : public QCameraChannel 116 | { 117 | public: 118 | QCameraReprocessChannel(uint32_t cam_handle, 119 | mm_camera_ops_t *cam_ops); 120 | QCameraReprocessChannel(); 121 | virtual ~QCameraReprocessChannel(); 122 | int32_t addReprocStreamsFromSource(QCameraAllocator& allocator, 123 | cam_pp_feature_config_t &config, 124 | QCameraChannel *pSrcChannel, 125 | uint8_t minStreamBufNum, 126 | uint8_t burstNum, 127 | cam_padding_info_t *paddingInfo, 128 | QCameraParametersIntf ¶m, 129 | bool contStream, 130 | bool offline); 131 | // online reprocess 132 | int32_t doReprocess(mm_camera_super_buf_t *frame, 133 | QCameraParametersIntf ¶m, QCameraStream *pMetaStream, 134 | uint8_t meta_buf_index); 135 | 136 | // offline reprocess 137 | int32_t doReprocess(int buf_fd, size_t buf_length, int32_t &ret_val); 138 | 139 | int32_t doReprocessOffline(mm_camera_super_buf_t *frame, 140 | mm_camera_buf_def_t *meta_buf); 141 | 142 | int32_t stop(); 143 | QCameraChannel *getSrcChannel(){return m_pSrcChannel;}; 144 | 145 | private: 146 | QCameraStream *getStreamBySrouceHandle(uint32_t srcHandle); 147 | 148 | typedef struct { 149 | QCameraStream *stream; 150 | cam_mapping_buf_type type; 151 | uint32_t index; 152 | } OfflineBuffer; 153 | 154 | uint32_t mSrcStreamHandles[MAX_STREAM_NUM_IN_BUNDLE]; 155 | QCameraChannel *m_pSrcChannel; // ptr to source channel for reprocess 156 | android::List mOfflineBuffers; 157 | 158 | }; 159 | 160 | }; // namespace qcamera 161 | 162 | #endif /* __QCAMERA_CHANNEL_H__ */ 163 | -------------------------------------------------------------------------------- /QCamera2/HAL/QCameraThermalAdapter.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013-2015, The Linux Foundataion. 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 | #define LOG_TAG "QCameraThermalAdapter" 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include "QCamera2HWI.h" 37 | #include "QCameraThermalAdapter.h" 38 | 39 | using namespace android; 40 | 41 | namespace qcamera { 42 | 43 | 44 | QCameraThermalAdapter& QCameraThermalAdapter::getInstance() 45 | { 46 | static QCameraThermalAdapter instance; 47 | return instance; 48 | } 49 | 50 | QCameraThermalAdapter::QCameraThermalAdapter() : 51 | mCallback(NULL), 52 | mHandle(NULL), 53 | mRegister(NULL), 54 | mUnregister(NULL), 55 | mCameraHandle(0), 56 | mCamcorderHandle(0) 57 | { 58 | } 59 | 60 | int QCameraThermalAdapter::init(QCameraThermalCallback *thermalCb) 61 | { 62 | const char *error = NULL; 63 | int rc = NO_ERROR; 64 | 65 | LOGD("E"); 66 | mHandle = dlopen("/vendor/lib/libthermalclient.so", RTLD_NOW); 67 | if (!mHandle) { 68 | error = dlerror(); 69 | LOGE("dlopen failed with error %s", 70 | error ? error : ""); 71 | rc = UNKNOWN_ERROR; 72 | goto error; 73 | } 74 | *(void **)&mRegister = dlsym(mHandle, "thermal_client_register_callback"); 75 | if (!mRegister) { 76 | error = dlerror(); 77 | LOGE("dlsym failed with error code %s", 78 | error ? error: ""); 79 | rc = UNKNOWN_ERROR; 80 | goto error2; 81 | } 82 | *(void **)&mUnregister = dlsym(mHandle, "thermal_client_unregister_callback"); 83 | if (!mUnregister) { 84 | error = dlerror(); 85 | LOGE("dlsym failed with error code %s", 86 | error ? error: ""); 87 | rc = UNKNOWN_ERROR; 88 | goto error2; 89 | } 90 | 91 | mCallback = thermalCb; 92 | 93 | // Register camera and camcorder callbacks 94 | mCameraHandle = mRegister(mStrCamera, thermalCallback, NULL); 95 | if (mCameraHandle < 0) { 96 | LOGE("thermal_client_register_callback failed %d", 97 | mCameraHandle); 98 | rc = UNKNOWN_ERROR; 99 | goto error2; 100 | } 101 | mCamcorderHandle = mRegister(mStrCamcorder, thermalCallback, NULL); 102 | if (mCamcorderHandle < 0) { 103 | LOGE("thermal_client_register_callback failed %d", 104 | mCamcorderHandle); 105 | rc = UNKNOWN_ERROR; 106 | goto error3; 107 | } 108 | 109 | LOGD("X"); 110 | return rc; 111 | 112 | error3: 113 | mCamcorderHandle = 0; 114 | mUnregister(mCameraHandle); 115 | error2: 116 | mCameraHandle = 0; 117 | dlclose(mHandle); 118 | mHandle = NULL; 119 | error: 120 | LOGD("X"); 121 | return rc; 122 | } 123 | 124 | void QCameraThermalAdapter::deinit() 125 | { 126 | LOGD("E"); 127 | if (mUnregister) { 128 | if (mCameraHandle) { 129 | mUnregister(mCameraHandle); 130 | mCameraHandle = 0; 131 | } 132 | if (mCamcorderHandle) { 133 | mUnregister(mCamcorderHandle); 134 | mCamcorderHandle = 0; 135 | } 136 | } 137 | if (mHandle) 138 | dlclose(mHandle); 139 | 140 | mHandle = NULL; 141 | mRegister = NULL; 142 | mUnregister = NULL; 143 | mCallback = NULL; 144 | LOGD("X"); 145 | } 146 | 147 | char QCameraThermalAdapter::mStrCamera[] = "camera"; 148 | char QCameraThermalAdapter::mStrCamcorder[] = "camcorder"; 149 | 150 | int QCameraThermalAdapter::thermalCallback(int level, 151 | void *userdata, void *data) 152 | { 153 | int rc = 0; 154 | LOGD("E"); 155 | QCameraThermalCallback *mcb = getInstance().mCallback; 156 | 157 | if (mcb) { 158 | mcb->setThermalLevel((qcamera_thermal_level_enum_t) level); 159 | rc = mcb->thermalEvtHandle(mcb->getThermalLevel(), userdata, data); 160 | } 161 | LOGD("X"); 162 | return rc; 163 | } 164 | 165 | qcamera_thermal_level_enum_t *QCameraThermalCallback::getThermalLevel() { 166 | return &mLevel; 167 | } 168 | 169 | void QCameraThermalCallback::setThermalLevel(qcamera_thermal_level_enum_t level) { 170 | mLevel = level; 171 | } 172 | }; //namespace qcamera 173 | -------------------------------------------------------------------------------- /QCamera2/HAL/QCameraThermalAdapter.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, The Linux Foundataion. 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 | -------------------------------------------------------------------------------- /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 | hardware/qcom/camera/QCamera2/stack/common \ 41 | frameworks/av/include/media/stagefright \ 42 | frameworks/native/include/media/openmax \ 43 | $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include 44 | 45 | LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 46 | 47 | LOCAL_MODULE:= camera_test 48 | LOCAL_MODULE_TAGS:= tests 49 | 50 | LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter 51 | LOCAL_CFLAGS += -O0 52 | 53 | ifeq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) >= 20 ))" ))) 54 | 55 | LOCAL_CFLAGS += -DUSE_SDK_20_OR_HIGHER 56 | 57 | ifeq ($(TARGET_USES_AOSP),true) 58 | LOCAL_CFLAGS += -DVANILLA_HAL 59 | endif 60 | 61 | endif 62 | 63 | #include $(BUILD_EXECUTABLE) 64 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /QCamera2/HAL/wrapper/QualcommCamera.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2011-2013, 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 | 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 | -------------------------------------------------------------------------------- /QCamera2/HAL3/QCamera3CropRegionMapper.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, The Linux Foundataion. 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 | #include 34 | #include 35 | #include "QCamera3HALHeader.h" 36 | 37 | using namespace android; 38 | 39 | namespace qcamera { 40 | 41 | class QCamera3CropRegionMapper { 42 | public: 43 | QCamera3CropRegionMapper(); 44 | virtual ~QCamera3CropRegionMapper(); 45 | 46 | void update(uint32_t active_array_w, uint32_t active_array_h, 47 | uint32_t sensor_w, uint32_t sensor_h); 48 | void toActiveArray(int32_t& crop_left, int32_t& crop_top, 49 | int32_t& crop_width, int32_t& crop_height); 50 | void toSensor(int32_t& crop_left, int32_t& crop_top, 51 | int32_t& crop_width, int32_t& crop_height); 52 | void toActiveArray(uint32_t& x, uint32_t& y); 53 | void toSensor(uint32_t& x, uint32_t& y); 54 | 55 | private: 56 | /* sensor output size */ 57 | int32_t mSensorW, mSensorH; 58 | int32_t mActiveArrayW, mActiveArrayH; 59 | 60 | void boundToSize(int32_t& left, int32_t& top, int32_t& width, 61 | int32_t& height, int32_t bound_w, int32_t bound_h); 62 | }; 63 | 64 | }; // namespace qcamera 65 | 66 | #endif /* __QCAMERA3CROPREGIONMAPPER_H__ */ 67 | -------------------------------------------------------------------------------- /QCamera2/HAL3/QCamera3HALHeader.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013-2015, The Linux Foundataion. 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 | extern "C" { 33 | #include 34 | #include 35 | } 36 | 37 | using namespace android; 38 | 39 | namespace qcamera { 40 | 41 | #define MAX(a, b) ((a) > (b) ? (a) : (b)) 42 | #define MIN(a, b) ((a) < (b) ? (a) : (b)) 43 | 44 | #define IS_USAGE_ZSL(usage) (((usage) & (GRALLOC_USAGE_HW_CAMERA_ZSL)) \ 45 | == (GRALLOC_USAGE_HW_CAMERA_ZSL)) 46 | 47 | class QCamera3Channel; 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 | -------------------------------------------------------------------------------- /QCamera2/HAL3/QCamera3Mem.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2015, The Linux Foundataion. 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 | #include 33 | #include 34 | 35 | extern "C" { 36 | #include 37 | #include 38 | #include 39 | } 40 | 41 | using namespace android; 42 | 43 | namespace qcamera { 44 | 45 | // Base class for all memory types. Abstract. 46 | class QCamera3Memory { 47 | 48 | public: 49 | int cleanCache(uint32_t index) 50 | { 51 | return cacheOps(index, ION_IOC_CLEAN_CACHES); 52 | } 53 | int invalidateCache(uint32_t index) 54 | { 55 | return cacheOps(index, ION_IOC_INV_CACHES); 56 | } 57 | int cleanInvalidateCache(uint32_t index) 58 | { 59 | return cacheOps(index, ION_IOC_CLEAN_INV_CACHES); 60 | } 61 | int getFd(uint32_t index); 62 | ssize_t getSize(uint32_t index); 63 | uint32_t getCnt(); 64 | 65 | virtual int cacheOps(uint32_t index, unsigned int cmd) = 0; 66 | virtual int getMatchBufIndex(void *object) = 0; 67 | virtual void *getPtr(uint32_t index) = 0; 68 | 69 | virtual int32_t markFrameNumber(uint32_t index, uint32_t frameNumber) = 0; 70 | virtual int32_t getFrameNumber(uint32_t index) = 0; 71 | virtual int32_t getBufferIndex(uint32_t frameNumber) = 0; 72 | 73 | QCamera3Memory(); 74 | virtual ~QCamera3Memory(); 75 | 76 | int32_t getBufDef(const cam_frame_len_offset_t &offset, 77 | mm_camera_buf_def_t &bufDef, uint32_t index); 78 | 79 | protected: 80 | struct QCamera3MemInfo { 81 | int fd; 82 | int main_ion_fd; 83 | ion_user_handle_t handle; 84 | size_t size; 85 | }; 86 | 87 | int cacheOpsInternal(uint32_t index, unsigned int cmd, void *vaddr); 88 | virtual void *getPtrLocked(uint32_t index) = 0; 89 | 90 | uint32_t mBufferCount; 91 | struct QCamera3MemInfo mMemInfo[MM_CAMERA_MAX_NUM_FRAMES]; 92 | void *mPtr[MM_CAMERA_MAX_NUM_FRAMES]; 93 | int32_t mCurrentFrameNumbers[MM_CAMERA_MAX_NUM_FRAMES]; 94 | Mutex mLock; 95 | }; 96 | 97 | // Internal heap memory is used for memories used internally 98 | // They are allocated from /dev/ion. Examples are: capabilities, 99 | // parameters, metadata, and internal YUV data for jpeg encoding. 100 | class QCamera3HeapMemory : public QCamera3Memory { 101 | public: 102 | QCamera3HeapMemory(uint32_t maxCnt); 103 | virtual ~QCamera3HeapMemory(); 104 | 105 | int allocate(size_t size); 106 | int allocateOne(size_t size); 107 | void deallocate(); 108 | 109 | virtual int cacheOps(uint32_t index, unsigned int cmd); 110 | virtual int getMatchBufIndex(void *object); 111 | virtual void *getPtr(uint32_t index); 112 | 113 | virtual int32_t markFrameNumber(uint32_t index, uint32_t frameNumber); 114 | virtual int32_t getFrameNumber(uint32_t index); 115 | virtual int32_t getBufferIndex(uint32_t frameNumber); 116 | 117 | protected: 118 | virtual void *getPtrLocked(uint32_t index); 119 | private: 120 | int allocOneBuffer(struct QCamera3MemInfo &memInfo, 121 | unsigned int heap_id, size_t size); 122 | void deallocOneBuffer(struct QCamera3MemInfo &memInfo); 123 | bool mQueueAll; 124 | uint32_t mMaxCnt; 125 | }; 126 | 127 | // Gralloc Memory shared with frameworks 128 | class QCamera3GrallocMemory : public QCamera3Memory { 129 | public: 130 | QCamera3GrallocMemory(uint32_t startIdx); 131 | virtual ~QCamera3GrallocMemory(); 132 | 133 | int registerBuffer(buffer_handle_t *buffer, cam_stream_type_t type); 134 | int32_t unregisterBuffer(size_t idx); 135 | void unregisterBuffers(); 136 | virtual int cacheOps(uint32_t index, unsigned int cmd); 137 | virtual int getMatchBufIndex(void *object); 138 | virtual void *getPtr(uint32_t index); 139 | 140 | virtual int32_t markFrameNumber(uint32_t index, uint32_t frameNumber); 141 | virtual int32_t getFrameNumber(uint32_t index); 142 | virtual int32_t getBufferIndex(uint32_t frameNumber); 143 | 144 | void *getBufferHandle(uint32_t index); 145 | protected: 146 | virtual void *getPtrLocked(uint32_t index); 147 | private: 148 | int32_t unregisterBufferLocked(size_t idx); 149 | int32_t getFreeIndexLocked(); 150 | buffer_handle_t *mBufferHandle[MM_CAMERA_MAX_NUM_FRAMES]; 151 | struct private_handle_t *mPrivateHandle[MM_CAMERA_MAX_NUM_FRAMES]; 152 | 153 | uint32_t mStartIdx; 154 | }; 155 | }; 156 | #endif 157 | -------------------------------------------------------------------------------- /QCamera2/HAL3/QCamera3PostProc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2015, The Linux Foundataion. 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_POSTPROC_H__ 31 | #define __QCamera3_POSTPROC_H__ 32 | 33 | extern "C" { 34 | #include 35 | #include 36 | } 37 | #include 38 | //#include "QCamera3HWI.h" 39 | #include "QCameraQueue.h" 40 | #include "QCameraCmdThread.h" 41 | #include "QCamera3HALHeader.h" 42 | 43 | namespace qcamera { 44 | 45 | class QCamera3Exif; 46 | class QCamera3Channel; 47 | class QCamera3ProcessingChannel; 48 | class QCamera3PicChannel; 49 | class QCamera3ReprocessChannel; 50 | class QCamera3Stream; 51 | class QCamera3Memory; 52 | class QCamera3StreamMem; 53 | 54 | typedef struct { 55 | camera3_stream_buffer_t src_frame;// source frame 56 | mm_camera_buf_def_t metadata_buffer; 57 | mm_camera_buf_def_t input_buffer; 58 | reprocess_config_t reproc_config; 59 | buffer_handle_t *output_buffer; 60 | uint32_t frameNumber; 61 | } qcamera_fwk_input_pp_data_t; 62 | 63 | typedef struct { 64 | uint32_t jobId; // job ID 65 | uint32_t client_hdl; // handle of jpeg client (obtained when open jpeg) 66 | mm_camera_super_buf_t *src_frame;// source frame (need to be returned back to kernel after done) 67 | mm_camera_super_buf_t *src_reproc_frame; // original source frame for reproc if not NULL 68 | qcamera_fwk_input_pp_data_t *fwk_frame; // source framework buffer 69 | qcamera_fwk_input_pp_data_t *fwk_src_buffer; // original framework source frame for reproc 70 | QCamera3Exif *pJpegExifObj; 71 | metadata_buffer_t *metadata; 72 | mm_camera_super_buf_t *src_metadata; 73 | jpeg_settings_t *jpeg_settings; 74 | } qcamera_hal3_jpeg_data_t; 75 | 76 | typedef struct { 77 | uint32_t jobId; // job ID 78 | mm_camera_super_buf_t *src_frame;// source frame (need to be returned back to kernel after done) 79 | qcamera_fwk_input_pp_data_t *fwk_src_frame;// source frame 80 | metadata_buffer_t *metadata; 81 | jpeg_settings_t *jpeg_settings; 82 | mm_camera_super_buf_t *src_metadata; 83 | } qcamera_hal3_pp_data_t; 84 | 85 | typedef struct { 86 | mm_camera_super_buf_t *input; 87 | buffer_handle_t *output; 88 | uint32_t frameNumber; 89 | } qcamera_hal3_pp_buffer_t; 90 | 91 | #define MAX_HAL3_EXIF_TABLE_ENTRIES 23 92 | class QCamera3Exif 93 | { 94 | public: 95 | QCamera3Exif(); 96 | virtual ~QCamera3Exif(); 97 | 98 | int32_t addEntry(exif_tag_id_t tagid, 99 | exif_tag_type_t type, 100 | uint32_t count, 101 | void *data); 102 | uint32_t getNumOfEntries() {return m_nNumEntries;}; 103 | QEXIF_INFO_DATA *getEntries() {return m_Entries;}; 104 | 105 | private: 106 | QEXIF_INFO_DATA m_Entries[MAX_HAL3_EXIF_TABLE_ENTRIES]; // exif tags for JPEG encoder 107 | uint32_t m_nNumEntries; // number of valid entries 108 | }; 109 | 110 | class QCamera3PostProcessor 111 | { 112 | public: 113 | QCamera3PostProcessor(QCamera3ProcessingChannel *ch_ctrl); 114 | virtual ~QCamera3PostProcessor(); 115 | 116 | int32_t init(QCamera3StreamMem *mMemory, 117 | uint32_t postprocess_mask); 118 | int32_t initJpeg(jpeg_encode_callback_t jpeg_cb, 119 | cam_dimension_t *m_max_pic_dim, 120 | void *user_data); 121 | int32_t deinit(); 122 | int32_t start(const reprocess_config_t &config); 123 | int32_t stop(); 124 | int32_t flush(); 125 | int32_t processData(qcamera_fwk_input_pp_data_t *frame); 126 | int32_t processData(mm_camera_super_buf_t *input, 127 | buffer_handle_t *output, uint32_t frameNumber); 128 | int32_t processData(mm_camera_super_buf_t *input); 129 | int32_t processPPData(mm_camera_super_buf_t *frame); 130 | int32_t processPPMetadata(mm_camera_super_buf_t *reproc_meta); 131 | int32_t processJpegSettingData(jpeg_settings_t *jpeg_settings); 132 | qcamera_hal3_pp_data_t *dequeuePPJob(uint32_t frameNumber); 133 | qcamera_hal3_jpeg_data_t *findJpegJobByJobId(uint32_t jobId); 134 | void releaseJpegJobData(qcamera_hal3_jpeg_data_t *job); 135 | int32_t releaseOfflineBuffers(bool all); 136 | void releasePPJobData(qcamera_hal3_pp_data_t *job); 137 | 138 | private: 139 | int32_t sendEvtNotify(int32_t msg_type, int32_t ext1, int32_t ext2); 140 | mm_jpeg_color_format getColorfmtFromImgFmt(cam_format_t img_fmt); 141 | mm_jpeg_format_t getJpegImgTypeFromImgFmt(cam_format_t img_fmt); 142 | int32_t getJpegEncodeConfig(mm_jpeg_encode_params_t& encode_parm, 143 | QCamera3Stream *main_stream, 144 | jpeg_settings_t *jpeg_settings); 145 | int32_t getFWKJpegEncodeConfig(mm_jpeg_encode_params_t& encode_parm, 146 | qcamera_fwk_input_pp_data_t *frame, 147 | jpeg_settings_t *jpeg_settings); 148 | QCamera3Exif * getExifData(metadata_buffer_t *metadata, 149 | jpeg_settings_t *jpeg_settings); 150 | int32_t encodeData(qcamera_hal3_jpeg_data_t *jpeg_job_data, 151 | uint8_t &needNewSess); 152 | int32_t encodeFWKData(qcamera_hal3_jpeg_data_t *jpeg_job_data, 153 | uint8_t &needNewSess); 154 | void releaseSuperBuf(mm_camera_super_buf_t *super_buf); 155 | static void releaseNotifyData(void *user_data, void *cookie); 156 | int32_t processRawImageImpl(mm_camera_super_buf_t *recvd_frame); 157 | 158 | static void releaseJpegData(void *data, void *user_data); 159 | static void releasePPInputData(void *data, void *user_data); 160 | static void releaseMetadata(void *data, void *user_data); 161 | static void releaseOngoingPPData(void *data, void *user_data); 162 | 163 | static void *dataProcessRoutine(void *data); 164 | 165 | private: 166 | QCamera3ProcessingChannel *m_parent; 167 | jpeg_encode_callback_t mJpegCB; 168 | void * mJpegUserData; 169 | mm_jpeg_ops_t mJpegHandle; 170 | uint32_t mJpegClientHandle; 171 | uint32_t mJpegSessionId; 172 | uint32_t mPostProcMask; 173 | 174 | uint32_t m_bThumbnailNeeded; 175 | QCamera3StreamMem *mOutputMem; 176 | QCamera3ReprocessChannel * m_pReprocChannel; 177 | 178 | QCameraQueue m_inputPPQ; // input queue for postproc 179 | QCameraQueue m_inputFWKPPQ; // framework input queue for postproc 180 | QCameraQueue m_ongoingPPQ; // ongoing postproc queue 181 | QCameraQueue m_inputJpegQ; // input jpeg job queue 182 | QCameraQueue m_ongoingJpegQ; // ongoing jpeg job queue 183 | QCameraQueue m_inputRawQ; // input raw job queue 184 | QCameraQueue m_inputMetaQ; // input meta queue 185 | QCameraQueue m_jpegSettingsQ; // input jpeg setting queue 186 | QCameraCmdThread m_dataProcTh; // thread for data processing 187 | 188 | pthread_mutex_t mReprocJobLock; 189 | }; 190 | 191 | }; // namespace qcamera 192 | 193 | #endif /* __QCamera3_POSTPROC_H__ */ 194 | -------------------------------------------------------------------------------- /QCamera2/HAL3/QCamera3Stream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2015, The Linux Foundataion. 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_STREAM_H__ 31 | #define __QCAMERA3_STREAM_H__ 32 | 33 | #include 34 | #include "utils/Mutex.h" 35 | #include "QCameraCmdThread.h" 36 | #include "QCamera3Mem.h" 37 | #include "QCamera3StreamMem.h" 38 | 39 | extern "C" { 40 | #include 41 | } 42 | 43 | namespace qcamera { 44 | 45 | class QCamera3Stream; 46 | class QCamera3Channel; 47 | 48 | typedef void (*hal3_stream_cb_routine)(mm_camera_super_buf_t *frame, 49 | QCamera3Stream *stream, 50 | void *userdata); 51 | 52 | class QCamera3Stream 53 | { 54 | public: 55 | QCamera3Stream(uint32_t camHandle, 56 | uint32_t chId, 57 | mm_camera_ops_t *camOps, 58 | cam_padding_info_t *paddingInfo, 59 | QCamera3Channel *channel); 60 | virtual ~QCamera3Stream(); 61 | virtual int32_t init(cam_stream_type_t streamType, 62 | cam_format_t streamFormat, 63 | cam_dimension_t streamDim, 64 | cam_rotation_t streamRotation, 65 | cam_stream_reproc_config_t* reprocess_config, 66 | uint8_t minStreamBufNum, 67 | uint32_t postprocess_mask, 68 | cam_is_type_t is_type, 69 | uint32_t batchSize, 70 | hal3_stream_cb_routine stream_cb, 71 | void *userdata); 72 | virtual int32_t bufDone(uint32_t index); 73 | virtual int32_t bufRelease(int32_t index); 74 | virtual int32_t processDataNotify(mm_camera_super_buf_t *bufs); 75 | virtual int32_t start(); 76 | virtual int32_t stop(); 77 | virtual int32_t queueBatchBuf(); 78 | 79 | static void dataNotifyCB(mm_camera_super_buf_t *recvd_frame, void *userdata); 80 | static void *dataProcRoutine(void *data); 81 | uint32_t getMyHandle() const {return mHandle;} 82 | cam_stream_type_t getMyType() const; 83 | int32_t getFrameOffset(cam_frame_len_offset_t &offset); 84 | int32_t getFrameDimension(cam_dimension_t &dim); 85 | int32_t getFormat(cam_format_t &fmt); 86 | QCamera3StreamMem *getStreamBufs() {return mStreamBufs;}; 87 | uint32_t getMyServerID(); 88 | 89 | int32_t mapBuf(uint8_t buf_type, uint32_t buf_idx, 90 | int32_t plane_idx, int fd, size_t size); 91 | int32_t unmapBuf(uint8_t buf_type, uint32_t buf_idx, int32_t plane_idx); 92 | int32_t setParameter(cam_stream_parm_buffer_t ¶m); 93 | cam_stream_info_t* getStreamInfo() const {return mStreamInfo; }; 94 | 95 | static void releaseFrameData(void *data, void *user_data); 96 | 97 | private: 98 | uint32_t mCamHandle; 99 | uint32_t mChannelHandle; 100 | uint32_t mHandle; // stream handle from mm-camera-interface 101 | mm_camera_ops_t *mCamOps; 102 | cam_stream_info_t *mStreamInfo; // ptr to stream info buf 103 | mm_camera_stream_mem_vtbl_t mMemVtbl; 104 | mm_camera_map_unmap_ops_tbl_t *mMemOps; 105 | uint8_t mNumBufs; 106 | hal3_stream_cb_routine mDataCB; 107 | void *mUserData; 108 | 109 | QCameraQueue mDataQ; 110 | QCameraCmdThread mProcTh; // thread for dataCB 111 | 112 | QCamera3HeapMemory *mStreamInfoBuf; 113 | QCamera3StreamMem *mStreamBufs; 114 | mm_camera_buf_def_t *mBufDefs; 115 | cam_frame_len_offset_t mFrameLenOffset; 116 | cam_padding_info_t mPaddingInfo; 117 | QCamera3Channel *mChannel; 118 | Mutex mLock; //Lock controlling access to 'mBufDefs' 119 | 120 | uint32_t mBatchSize; // 0: No batch, non-0: Number of imaage bufs in a batch 121 | uint8_t mNumBatchBufs; //Number of batch buffers which can hold image bufs 122 | QCamera3HeapMemory *mStreamBatchBufs; //Pointer to batch buffers memory 123 | mm_camera_buf_def_t *mBatchBufDefs; //Pointer to array of batch bufDefs 124 | mm_camera_buf_def_t *mCurrentBatchBufDef; //batch buffer in progress during 125 | //aggregation 126 | uint32_t mBufsStaged; //Number of image buffers aggregated into 127 | //currentBatchBufDef 128 | QCameraQueue mFreeBatchBufQ; //Buffer queue containing empty batch buffers 129 | 130 | static int32_t get_bufs( 131 | cam_frame_len_offset_t *offset, 132 | uint8_t *num_bufs, 133 | uint8_t **initial_reg_flag, 134 | mm_camera_buf_def_t **bufs, 135 | mm_camera_map_unmap_ops_tbl_t *ops_tbl, 136 | void *user_data); 137 | static int32_t put_bufs( 138 | mm_camera_map_unmap_ops_tbl_t *ops_tbl, 139 | void *user_data); 140 | static int32_t invalidate_buf(uint32_t index, void *user_data); 141 | static int32_t clean_invalidate_buf(uint32_t index, void *user_data); 142 | 143 | int32_t getBufs(cam_frame_len_offset_t *offset, 144 | uint8_t *num_bufs, 145 | uint8_t **initial_reg_flag, 146 | mm_camera_buf_def_t **bufs, 147 | mm_camera_map_unmap_ops_tbl_t *ops_tbl); 148 | int32_t putBufs(mm_camera_map_unmap_ops_tbl_t *ops_tbl); 149 | int32_t invalidateBuf(uint32_t index); 150 | int32_t cleanInvalidateBuf(uint32_t index); 151 | int32_t getBatchBufs( 152 | uint8_t *num_bufs, uint8_t **initial_reg_flag, 153 | mm_camera_buf_def_t **bufs, 154 | mm_camera_map_unmap_ops_tbl_t *ops_tbl); 155 | int32_t putBatchBufs(mm_camera_map_unmap_ops_tbl_t *ops_tbl); 156 | int32_t getBatchBufDef(mm_camera_buf_def_t& batchBufDef, 157 | int32_t index); 158 | int32_t aggregateBufToBatch(mm_camera_buf_def_t& bufDef); 159 | int32_t handleBatchBuffer(mm_camera_super_buf_t *superBuf); 160 | 161 | static const char* mStreamNames[CAM_STREAM_TYPE_MAX]; 162 | void flushFreeBatchBufQ(); 163 | }; 164 | 165 | }; // namespace qcamera 166 | 167 | #endif /* __QCAMERA3_STREAM_H__ */ 168 | -------------------------------------------------------------------------------- /QCamera2/HAL3/QCamera3StreamMem.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2015, The Linux Foundataion. 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 | #include 34 | #include 35 | #include "QCamera3Mem.h" 36 | 37 | extern "C" { 38 | #include 39 | #include 40 | #include 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 | -------------------------------------------------------------------------------- /QCamera2/HAL3/QCamera3VendorTags.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2014-2015, 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 __QCAMERA3VENDORTAGS_H__ 31 | #define __QCAMERA3VENDORTAGS_H__ 32 | 33 | namespace qcamera { 34 | 35 | enum qcamera3_ext_section { 36 | QCAMERA3_PRIVATEDATA = VENDOR_SECTION, 37 | QCAMERA3_CDS, 38 | QCAMERA3_OPAQUE_RAW, 39 | QCAMERA3_CROP, 40 | QCAMERA3_TUNING_META_DATA, 41 | QCAMERA3_TEMPORAL_DENOISE, 42 | QCAMERA3_AV_TIMER, 43 | QCAMERA3_SENSOR_META_DATA, 44 | NEXUS_EXPERIMENTAL_2015, 45 | QCAMERA3_SECTIONS_END 46 | }; 47 | 48 | enum qcamera3_ext_section_ranges { 49 | QCAMERA3_PRIVATEDATA_START = QCAMERA3_PRIVATEDATA << 16, 50 | QCAMERA3_CDS_START = QCAMERA3_CDS << 16, 51 | QCAMERA3_OPAQUE_RAW_START = QCAMERA3_OPAQUE_RAW << 16, 52 | QCAMERA3_CROP_START = QCAMERA3_CROP << 16, 53 | QCAMERA3_TUNING_META_DATA_START = QCAMERA3_TUNING_META_DATA << 16, 54 | QCAMERA3_TEMPORAL_DENOISE_START = QCAMERA3_TEMPORAL_DENOISE << 16, 55 | QCAMERA3_AV_TIMER_START = QCAMERA3_AV_TIMER << 16, 56 | QCAMERA3_SENSOR_META_DATA_START = QCAMERA3_SENSOR_META_DATA << 16, 57 | NEXUS_EXPERIMENTAL_2015_START = NEXUS_EXPERIMENTAL_2015 <<16 58 | }; 59 | 60 | enum qcamera3_ext_tags { 61 | QCAMERA3_PRIVATEDATA_REPROCESS = QCAMERA3_PRIVATEDATA_START, 62 | QCAMERA3_PRIVATEDATA_END, 63 | QCAMERA3_CDS_MODE = QCAMERA3_CDS_START, 64 | QCAMERA3_CDS_INFO, 65 | QCAMERA3_CDS_END, 66 | 67 | //Property Name: org.codeaurora.qcamera3.opaque_raw.opaque_raw_strides 68 | // 69 | //Type: int32 * n * 3 [public] 70 | // 71 | //Description: Distance in bytes from the beginning of one row of opaque 72 | //raw image data to the beginning of next row. 73 | // 74 | //Details: The strides are listed as (raw_width, raw_height, stride) 75 | //triplets. For each supported raw size, there will be a stride associated 76 | //with it. 77 | QCAMERA3_OPAQUE_RAW_STRIDES = QCAMERA3_OPAQUE_RAW_START, 78 | 79 | //Property Name: org.codeaurora.qcamera3.opaque_raw.opaque_raw_format 80 | // 81 | //Type: byte(enum) [public] 82 | // * LEGACY - The legacy raw format where 8, 10, or 12-bit 83 | // raw data is packed into a 64-bit word. 84 | // * MIPI - raw format matching the data packing described 85 | // in MIPI CSI-2 specification. In memory, the data 86 | // is constructed by packing sequentially received pixels 87 | // into least significant parts of the words first. 88 | // Within each pixel, the least significant bits are also 89 | // placed towards the least significant part of the word. 90 | // 91 | //Details: Lay out of opaque raw data in memory is decided by two factors: 92 | // opaque_raw_format and bit depth (implied by whiteLevel). Below 93 | // list illustrates their relationship: 94 | // LEGACY8: P7(7:0) P6(7:0) P5(7:0) P4(7:0) P3(7:0) P2(7:0) P1(7:0) P0(7:0) 95 | // 8 pixels occupy 8 bytes, no padding needed 96 | // min_stride = CEILING8(raw_width) 97 | // LEGACY10: 0000 P5(9:0) P4(9:0) P3(9:0) P2(9:0) P1(9:0) P0(9:0) 98 | // 6 pixels occupy 8 bytes, 4 bits padding at MSB 99 | // min_stride = (raw_width+5)/6 * 8 100 | // LEGACY12: 0000 P4(11:0) P3(11:0) P2(11:0) P1(11:0) P0(11:0) 101 | // 5 pixels occupy 8 bytes, 4 bits padding at MSB 102 | // min_stride = (raw_width+4)/5 * 8 103 | // MIPI8: P0(7:0) 104 | // 1 pixel occupy 1 byte 105 | // min_stride = raw_width 106 | // MIPI10: P3(1:0) P2(1:0) P1(1:0) P0(1:0) P3(9:2) P2(9:2) P1(9:2) P0(9:2) 107 | // 4 pixels occupy 5 bytes 108 | // min_stride = (raw_width+3)/4 * 5 109 | // MIPI12: P1(3:0) P0(3:0) P1(11:4) P0(11:4) 110 | // 2 pixels occupy 3 bytes 111 | // min_stride = (raw_width+1)/2 * 3 112 | //Note that opaque_raw_stride needs to be at least the required minimum 113 | //stride from the table above. ISP hardware may need more generous stride 114 | //setting. For example, for LEGACY8, the actual stride may be 115 | //CEILING16(raw_width) due to bus burst length requirement. 116 | QCAMERA3_OPAQUE_RAW_FORMAT, 117 | QCAMERA3_OPAQUE_RAW_END, 118 | 119 | QCAMERA3_CROP_COUNT_REPROCESS = QCAMERA3_CROP_START, 120 | QCAMERA3_CROP_REPROCESS, 121 | QCAMERA3_CROP_ROI_MAP_REPROCESS, 122 | QCAMERA3_CROP_END, 123 | 124 | QCAMERA3_TUNING_META_DATA_BLOB = QCAMERA3_TUNING_META_DATA_START, 125 | QCAMERA3_TUNING_META_DATA_END, 126 | 127 | QCAMERA3_TEMPORAL_DENOISE_ENABLE = QCAMERA3_TEMPORAL_DENOISE_START, 128 | QCAMERA3_TEMPORAL_DENOISE_PROCESS_TYPE, 129 | QCAMERA3_TEMPORAL_DENOISE_END, 130 | 131 | QCAMERA3_USE_AV_TIMER = QCAMERA3_AV_TIMER_START, 132 | QCAMERA3_AV_TIMER_END, 133 | 134 | QCAMERA3_SENSOR_DYNAMIC_BLACK_LEVEL_PATTERN = QCAMERA3_SENSOR_META_DATA_START, 135 | QCAMERA3_SENSOR_META_DATA_END, 136 | 137 | NEXUS_EXPERIMENTAL_2015_SENSOR_DYNAMIC_BLACK_LEVEL = NEXUS_EXPERIMENTAL_2015_START, 138 | NEXUS_EXPERIMENTAL_2015_SENSOR_INFO_OPTICALLY_SHIELDED_REGIONS, 139 | NEXUS_EXPERIMENTAL_2015_END 140 | }; 141 | 142 | // QCAMERA3_OPAQUE_RAW_FORMAT 143 | typedef enum qcamera3_ext_opaque_raw_format { 144 | QCAMERA3_OPAQUE_RAW_FORMAT_LEGACY, 145 | QCAMERA3_OPAQUE_RAW_FORMAT_MIPI 146 | } qcamera3_ext_opaque_raw_format_t; 147 | 148 | class QCamera3VendorTags { 149 | 150 | public: 151 | static void get_vendor_tag_ops(vendor_tag_ops_t* ops); 152 | static int get_tag_count( 153 | const vendor_tag_ops_t *ops); 154 | static void get_all_tags( 155 | const vendor_tag_ops_t *ops, 156 | uint32_t *tag_array); 157 | static const char* get_section_name( 158 | const vendor_tag_ops_t *ops, 159 | uint32_t tag); 160 | static const char* get_tag_name( 161 | const vendor_tag_ops_t *ops, 162 | uint32_t tag); 163 | static int get_tag_type( 164 | const vendor_tag_ops_t *ops, 165 | uint32_t tag); 166 | 167 | static const vendor_tag_ops_t *Ops; 168 | }; 169 | 170 | }; // namespace qcamera 171 | 172 | #endif /* __QCAMERA3VENDORTAGS_H__ */ 173 | -------------------------------------------------------------------------------- /QCamera2/QCamera2Factory.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2015, The Linux Foundataion. 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 | #include 34 | #include 35 | #include 36 | 37 | namespace qcamera { 38 | 39 | typedef struct { 40 | uint32_t cameraId; 41 | uint32_t device_version; 42 | } hal_desc; 43 | 44 | class QCamera2Factory 45 | { 46 | public: 47 | QCamera2Factory(); 48 | virtual ~QCamera2Factory(); 49 | 50 | static int get_number_of_cameras(); 51 | static int get_camera_info(int camera_id, struct camera_info *info); 52 | static int set_callbacks(const camera_module_callbacks_t *callbacks); 53 | static int open_legacy(const struct hw_module_t* module, 54 | const char* id, uint32_t halVersion, struct hw_device_t** device); 55 | static int set_torch_mode(const char* camera_id, bool on); 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 | -------------------------------------------------------------------------------- /QCamera2/QCamera2Hal.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2015, The Linux Foundataion. 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 | #include "QCamera2Factory.h" 31 | #include "HAL3/QCamera3VendorTags.h" 32 | 33 | static hw_module_t camera_common = { 34 | tag: HARDWARE_MODULE_TAG, 35 | module_api_version: CAMERA_MODULE_API_VERSION_2_4, 36 | hal_api_version: HARDWARE_HAL_API_VERSION, 37 | id: CAMERA_HARDWARE_MODULE_ID, 38 | name: "QCamera Module", 39 | author: "Qualcomm Innovation Center Inc", 40 | methods: &qcamera::QCamera2Factory::mModuleMethods, 41 | dso: NULL, 42 | reserved: {0} 43 | }; 44 | 45 | camera_module_t HAL_MODULE_INFO_SYM = { 46 | common: camera_common, 47 | get_number_of_cameras: qcamera::QCamera2Factory::get_number_of_cameras, 48 | get_camera_info: qcamera::QCamera2Factory::get_camera_info, 49 | set_callbacks: qcamera::QCamera2Factory::set_callbacks, 50 | get_vendor_tag_ops: qcamera::QCamera3VendorTags::get_vendor_tag_ops, 51 | open_legacy: qcamera::QCamera2Factory::open_legacy, 52 | set_torch_mode: qcamera::QCamera2Factory::set_torch_mode, 53 | init : NULL, 54 | reserved: {0} 55 | }; 56 | -------------------------------------------------------------------------------- /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 | include $(LOCAL_PATH)/mm-camera-test/Android.mk 6 | -------------------------------------------------------------------------------- /QCamera2/stack/common/cam_intf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OnePlusOSS/android_hardware_qcom_camera/fab5e9d464852b4c512c78bc92b6578d447e61a7/QCamera2/stack/common/cam_intf.h -------------------------------------------------------------------------------- /QCamera2/stack/common/cam_list.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 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 | 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 | #include 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 | -------------------------------------------------------------------------------- /QCamera2/stack/common/cam_queue.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 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 | 30 | #include "cam_list.h" 31 | 32 | typedef struct { 33 | struct cam_list list; 34 | void *data; 35 | } cam_node_t; 36 | 37 | typedef struct { 38 | cam_node_t head; /* dummy head */ 39 | uint32_t size; 40 | pthread_mutex_t lock; 41 | } cam_queue_t; 42 | 43 | static inline int32_t cam_queue_init(cam_queue_t *queue) 44 | { 45 | pthread_mutex_init(&queue->lock, NULL); 46 | cam_list_init(&queue->head.list); 47 | queue->size = 0; 48 | return 0; 49 | } 50 | 51 | static inline int32_t cam_queue_enq(cam_queue_t *queue, void *data) 52 | { 53 | cam_node_t *node = 54 | (cam_node_t *)malloc(sizeof(cam_node_t)); 55 | if (NULL == node) { 56 | return -1; 57 | } 58 | 59 | memset(node, 0, sizeof(cam_node_t)); 60 | node->data = data; 61 | 62 | pthread_mutex_lock(&queue->lock); 63 | cam_list_add_tail_node(&node->list, &queue->head.list); 64 | queue->size++; 65 | pthread_mutex_unlock(&queue->lock); 66 | 67 | return 0; 68 | } 69 | 70 | static inline void *cam_queue_deq(cam_queue_t *queue) 71 | { 72 | cam_node_t *node = NULL; 73 | void *data = NULL; 74 | struct cam_list *head = NULL; 75 | struct cam_list *pos = NULL; 76 | 77 | pthread_mutex_lock(&queue->lock); 78 | head = &queue->head.list; 79 | pos = head->next; 80 | if (pos != head) { 81 | node = member_of(pos, cam_node_t, list); 82 | cam_list_del_node(&node->list); 83 | queue->size--; 84 | } 85 | pthread_mutex_unlock(&queue->lock); 86 | 87 | if (NULL != node) { 88 | data = node->data; 89 | free(node); 90 | } 91 | 92 | return data; 93 | } 94 | 95 | static inline int32_t cam_queue_flush(cam_queue_t *queue) 96 | { 97 | cam_node_t *node = NULL; 98 | struct cam_list *head = NULL; 99 | struct cam_list *pos = NULL; 100 | 101 | pthread_mutex_lock(&queue->lock); 102 | head = &queue->head.list; 103 | pos = head->next; 104 | 105 | while(pos != head) { 106 | node = member_of(pos, cam_node_t, list); 107 | pos = pos->next; 108 | cam_list_del_node(&node->list); 109 | queue->size--; 110 | 111 | /* TODO later to consider ptr inside data */ 112 | /* for now we only assume there is no ptr inside data 113 | * so we free data directly */ 114 | if (NULL != node->data) { 115 | free(node->data); 116 | } 117 | free(node); 118 | 119 | } 120 | queue->size = 0; 121 | pthread_mutex_unlock(&queue->lock); 122 | return 0; 123 | } 124 | 125 | static inline int32_t cam_queue_deinit(cam_queue_t *queue) 126 | { 127 | cam_queue_flush(queue); 128 | pthread_mutex_destroy(&queue->lock); 129 | return 0; 130 | } 131 | -------------------------------------------------------------------------------- /QCamera2/stack/common/cam_semaphore.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 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 | 30 | #ifndef __QCAMERA_SEMAPHORE_H__ 31 | #define __QCAMERA_SEMAPHORE_H__ 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /* Implement semaphore with mutex and conditional variable. 38 | * Reason being, POSIX semaphore on Android are not used or 39 | * well tested. 40 | */ 41 | 42 | typedef struct { 43 | int val; 44 | pthread_mutex_t mutex; 45 | pthread_cond_t cond; 46 | } cam_semaphore_t; 47 | 48 | static inline void cam_sem_init(cam_semaphore_t *s, int n) 49 | { 50 | pthread_mutex_init(&(s->mutex), NULL); 51 | pthread_cond_init(&(s->cond), NULL); 52 | s->val = n; 53 | } 54 | 55 | static inline void cam_sem_post(cam_semaphore_t *s) 56 | { 57 | pthread_mutex_lock(&(s->mutex)); 58 | s->val++; 59 | pthread_cond_signal(&(s->cond)); 60 | pthread_mutex_unlock(&(s->mutex)); 61 | } 62 | 63 | static inline int cam_sem_wait(cam_semaphore_t *s) 64 | { 65 | int rc = 0; 66 | pthread_mutex_lock(&(s->mutex)); 67 | while (s->val == 0) 68 | rc = pthread_cond_wait(&(s->cond), &(s->mutex)); 69 | s->val--; 70 | pthread_mutex_unlock(&(s->mutex)); 71 | return rc; 72 | } 73 | 74 | static inline void cam_sem_destroy(cam_semaphore_t *s) 75 | { 76 | pthread_mutex_destroy(&(s->mutex)); 77 | pthread_cond_destroy(&(s->cond)); 78 | s->val = 0; 79 | } 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* __QCAMERA_SEMAPHORE_H__ */ 86 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-camera-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 | MM_CAM_FILES := \ 8 | src/mm_camera_interface.c \ 9 | src/mm_camera.c \ 10 | src/mm_camera_channel.c \ 11 | src/mm_camera_stream.c \ 12 | src/mm_camera_thread.c \ 13 | src/mm_camera_sock.c 14 | 15 | ifeq ($(strip $(TARGET_USES_ION)),true) 16 | LOCAL_CFLAGS += -DUSE_ION 17 | endif 18 | 19 | ifneq (,$(filter msm8974 msm8916 msm8226 msm8610 msm8916 apq8084 msm8084 msm8994 msm8992 msm8952 msm8996,$(TARGET_BOARD_PLATFORM))) 20 | LOCAL_CFLAGS += -DVENUS_PRESENT 21 | endif 22 | 23 | ifneq (,$(filter msm8996,$(TARGET_BOARD_PLATFORM))) 24 | LOCAL_CFLAGS += -DUBWC_PRESENT 25 | endif 26 | 27 | LOCAL_CFLAGS += -D_ANDROID_ -DQCAMERA_REDEFINE_LOG 28 | LOCAL_COPY_HEADERS_TO := mm-camera-interface 29 | LOCAL_COPY_HEADERS += ../common/cam_intf.h 30 | LOCAL_COPY_HEADERS += ../common/cam_types.h 31 | 32 | LOCAL_C_INCLUDES := \ 33 | $(LOCAL_PATH)/inc \ 34 | $(LOCAL_PATH)/../common \ 35 | system/media/camera/include 36 | 37 | LOCAL_CFLAGS += -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID 38 | LOCAL_C_INCLUDES+= $(kernel_includes) 39 | LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) 40 | 41 | LOCAL_C_INCLUDES += hardware/qcom/media/mm-core/inc 42 | 43 | 44 | ifneq (1,$(filter 1,$(shell echo "$$(( $(PLATFORM_SDK_VERSION) >= 17 ))" ))) 45 | LOCAL_CFLAGS += -include bionic/libc/kernel/common/linux/socket.h 46 | LOCAL_CFLAGS += -include bionic/libc/kernel/common/linux/un.h 47 | endif 48 | 49 | LOCAL_CFLAGS += -Wall -Wextra -Werror 50 | 51 | LOCAL_SRC_FILES := $(MM_CAM_FILES) 52 | 53 | LOCAL_MODULE := libmmcamera_interface 54 | LOCAL_CLANG := false 55 | LOCAL_PRELINK_MODULE := false 56 | LOCAL_SHARED_LIBRARIES := libdl libcutils liblog 57 | LOCAL_MODULE_TAGS := optional 58 | 59 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 60 | include $(BUILD_SHARED_LIBRARY) 61 | 62 | LOCAL_PATH := $(OLD_LOCAL_PATH) 63 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-camera-interface/inc/mm_camera_dbg.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, 2014, 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 | #include 34 | 35 | #ifdef QCAMERA_REDEFINE_LOG 36 | 37 | #include "cam_types.h" 38 | 39 | typedef enum { 40 | CAM_NO_MODULE, 41 | CAM_HAL_MODULE, 42 | CAM_MCI_MODULE, 43 | CAM_JPEG_MODULE, 44 | CAM_LAST_MODULE 45 | } cam_modules_t; 46 | 47 | extern int g_cam_log[CAM_LAST_MODULE][CAM_GLBL_DBG_INFO + 1]; 48 | 49 | #undef CLOGx 50 | #define CLOGx(module, level, fmt, args...) \ 51 | {\ 52 | if (g_cam_log[module][level]) { \ 53 | mm_camera_debug_log(module, level, __func__, __LINE__, fmt, ##args); \ 54 | }\ 55 | } 56 | 57 | #undef CLOGI 58 | #define CLOGI(module, fmt, args...) \ 59 | CLOGx(module, CAM_GLBL_DBG_INFO, fmt, ##args) 60 | #undef CLOGD 61 | #define CLOGD(module, fmt, args...) \ 62 | CLOGx(module, CAM_GLBL_DBG_DEBUG, fmt, ##args) 63 | #undef CLOGL 64 | #define CLOGL(module, fmt, args...) \ 65 | CLOGx(module, CAM_GLBL_DBG_LOW, fmt, ##args) 66 | #undef CLOGW 67 | #define CLOGW(module, fmt, args...) \ 68 | CLOGx(module, CAM_GLBL_DBG_WARN, fmt, ##args) 69 | #undef CLOGH 70 | #define CLOGH(module, fmt, args...) \ 71 | CLOGx(module, CAM_GLBL_DBG_HIGH, fmt, ##args) 72 | #undef CLOGE 73 | #define CLOGE(module, fmt, args...) \ 74 | CLOGx(module, CAM_GLBL_DBG_ERR, fmt, ##args) 75 | 76 | #ifndef CAM_MODULE 77 | #define CAM_MODULE CAM_MCI_MODULE 78 | #endif 79 | 80 | #undef LOGD 81 | #define LOGD(fmt, args...) CLOGD(CAM_MODULE, fmt, ##args) 82 | #undef LOGL 83 | #define LOGL(fmt, args...) CLOGL(CAM_MODULE, fmt, ##args) 84 | #undef LOGW 85 | #define LOGW(fmt, args...) CLOGW(CAM_MODULE, fmt, ##args) 86 | #undef LOGH 87 | #define LOGH(fmt, args...) CLOGH(CAM_MODULE, fmt, ##args) 88 | #undef LOGE 89 | #define LOGE(fmt, args...) CLOGE(CAM_MODULE, fmt, ##args) 90 | #undef LOGI 91 | #define LOGI(fmt, args...) CLOGI(CAM_MODULE, fmt, ##args) 92 | 93 | /* reads and updates camera logging properties */ 94 | void mm_camera_set_dbg_log_properties(void); 95 | 96 | /* generic logger function */ 97 | void mm_camera_debug_log(const cam_modules_t module, 98 | const cam_global_debug_level_t level, 99 | const char *func, const int line, const char *fmt, ...); 100 | 101 | #else 102 | 103 | #undef LOGD 104 | #define LOGD(fmt, args...) ALOGD(fmt, ##args) 105 | #undef LOGL 106 | #define LOGL(fmt, args...) ALOGD(fmt, ##args) 107 | #undef LOGW 108 | #define LOGW(fmt, args...) ALOGW(fmt, ##args) 109 | #undef LOGH 110 | #define LOGH(fmt, args...) ALOGD(fmt, ##args) 111 | #undef LOGE 112 | #define LOGE(fmt, args...) ALOGE(fmt, ##args) 113 | #undef LOGI 114 | #define LOGI(fmt, args...) ALOGV(fmt, ##args) 115 | 116 | #endif 117 | 118 | #endif /* __MM_CAMERA_DBG_H__ */ 119 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-camera-interface/inc/mm_camera_sock.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2014, 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 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "cam_types.h" 39 | 40 | typedef enum { 41 | MM_CAMERA_SOCK_TYPE_UDP, 42 | MM_CAMERA_SOCK_TYPE_TCP, 43 | } mm_camera_sock_type_t; 44 | 45 | typedef union { 46 | struct sockaddr addr; 47 | struct sockaddr_un addr_un; 48 | } mm_camera_sock_addr_t; 49 | 50 | int mm_camera_socket_create(int cam_id, mm_camera_sock_type_t sock_type); 51 | 52 | int mm_camera_socket_sendmsg( 53 | int fd, 54 | void *msg, 55 | size_t buf_size, 56 | int sendfd); 57 | 58 | int mm_camera_socket_bundle_sendmsg( 59 | int fd, 60 | void *msg, 61 | size_t buf_size, 62 | int sendfds[CAM_MAX_NUM_BUFS_PER_STREAM], 63 | int num_fds); 64 | 65 | int mm_camera_socket_recvmsg( 66 | int fd, 67 | void *msg, 68 | uint32_t buf_size, 69 | int *rcvdfd); 70 | 71 | void mm_camera_socket_close(int fd); 72 | 73 | #endif /*__MM_CAMERA_SOCKET_H__*/ 74 | 75 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-camera-test/Android.mk: -------------------------------------------------------------------------------- 1 | OLD_LOCAL_PATH := $(LOCAL_PATH) 2 | LOCAL_PATH:=$(call my-dir) 3 | 4 | # Build command line test app: mm-qcamera-app 5 | include $(LOCAL_PATH)/../../../common.mk 6 | include $(CLEAR_VARS) 7 | 8 | LOCAL_CFLAGS:= \ 9 | -DAMSS_VERSION=$(AMSS_VERSION) \ 10 | $(mmcamera_debug_defines) \ 11 | $(mmcamera_debug_cflags) \ 12 | $(USE_SERVER_TREE) 13 | 14 | ifeq ($(strip $(TARGET_USES_ION)),true) 15 | LOCAL_CFLAGS += -DUSE_ION 16 | endif 17 | 18 | LOCAL_CFLAGS += -D_ANDROID_ -DQCAMERA_REDEFINE_LOG 19 | 20 | LOCAL_SRC_FILES:= \ 21 | src/mm_qcamera_main_menu.c \ 22 | src/mm_qcamera_app.c \ 23 | src/mm_qcamera_unit_test.c \ 24 | src/mm_qcamera_video.c \ 25 | src/mm_qcamera_preview.c \ 26 | src/mm_qcamera_snapshot.c \ 27 | src/mm_qcamera_rdi.c \ 28 | src/mm_qcamera_reprocess.c\ 29 | src/mm_qcamera_queue.c \ 30 | src/mm_qcamera_socket.c \ 31 | src/mm_qcamera_commands.c 32 | # src/mm_qcamera_dual_test.c \ 33 | 34 | LOCAL_C_INCLUDES:=$(LOCAL_PATH)/inc 35 | LOCAL_C_INCLUDES+= \ 36 | frameworks/native/include/media/openmax \ 37 | $(LOCAL_PATH)/../common \ 38 | $(LOCAL_PATH)/../../../mm-image-codec/qexif \ 39 | $(LOCAL_PATH)/../../../mm-image-codec/qomx_core \ 40 | $(LOCAL_PATH)/../mm-camera-interface/inc \ 41 | 42 | LOCAL_C_INCLUDES+= $(kernel_includes) 43 | LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) 44 | 45 | LOCAL_CFLAGS += -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID 46 | ifeq ($(TARGET_BOARD_PLATFORM),msm8974) 47 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 48 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 49 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 50 | else ifeq ($(filter $(TARGET_BOARD_PLATFORM), apq8084 msm8084),$(TARGET_BOARD_PLATFORM)) 51 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 52 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 53 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 54 | else ifeq ($(TARGET_BOARD_PLATFORM),msm8994) 55 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 56 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 57 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 58 | else ifeq ($(TARGET_BOARD_PLATFORM),msm8916 msm8952) 59 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 60 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 61 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 62 | else ifeq ($(TARGET_BOARD_PLATFORM),msm8226) 63 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 64 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 65 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 66 | else ifeq ($(TARGET_BOARD_PLATFORM),msm8610) 67 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 68 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 69 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 70 | else ifeq ($(TARGET_BOARD_PLATFORM),msm8960) 71 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 72 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 73 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 74 | else ifneq (,$(filter msm8660,$(TARGET_BOARD_PLATFORM))) 75 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID # EBI 76 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 77 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 78 | else 79 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=GRALLOC_USAGE_PRIVATE_UNCACHED #uncached 80 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_CAMERA_HEAP_ID 81 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 82 | endif 83 | LOCAL_CFLAGS += -Wall -Wextra -Werror 84 | 85 | LOCAL_SHARED_LIBRARIES:= \ 86 | libcutils libdl libmmcamera_interface 87 | 88 | LOCAL_MODULE_TAGS := optional 89 | 90 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 91 | 92 | LOCAL_MODULE:= mm-qcamera-app 93 | LOCAL_CLANG := false 94 | 95 | include $(BUILD_EXECUTABLE) 96 | 97 | # Build tuning library 98 | include $(CLEAR_VARS) 99 | 100 | LOCAL_CFLAGS:= \ 101 | -DAMSS_VERSION=$(AMSS_VERSION) \ 102 | $(mmcamera_debug_defines) \ 103 | $(mmcamera_debug_cflags) \ 104 | $(USE_SERVER_TREE) 105 | 106 | ifeq ($(strip $(TARGET_USES_ION)),true) 107 | LOCAL_CFLAGS += -DUSE_ION 108 | endif 109 | 110 | LOCAL_CFLAGS += -D_ANDROID_ -DQCAMERA_REDEFINE_LOG 111 | 112 | LOCAL_SRC_FILES:= \ 113 | src/mm_qcamera_main_menu.c \ 114 | src/mm_qcamera_app.c \ 115 | src/mm_qcamera_unit_test.c \ 116 | src/mm_qcamera_video.c \ 117 | src/mm_qcamera_preview.c \ 118 | src/mm_qcamera_snapshot.c \ 119 | src/mm_qcamera_rdi.c \ 120 | src/mm_qcamera_reprocess.c\ 121 | src/mm_qcamera_queue.c \ 122 | src/mm_qcamera_socket.c \ 123 | src/mm_qcamera_commands.c 124 | # src/mm_qcamera_dual_test.c \ 125 | 126 | LOCAL_C_INCLUDES:=$(LOCAL_PATH)/inc 127 | LOCAL_C_INCLUDES+= \ 128 | frameworks/native/include/media/openmax \ 129 | $(LOCAL_PATH)/../common \ 130 | $(LOCAL_PATH)/../../../mm-image-codec/qexif \ 131 | $(LOCAL_PATH)/../../../mm-image-codec/qomx_core \ 132 | $(LOCAL_PATH)/../mm-camera-interface/inc \ 133 | 134 | LOCAL_C_INCLUDES+= $(kernel_includes) 135 | LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) 136 | 137 | LOCAL_CFLAGS += -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID 138 | ifeq ($(TARGET_BOARD_PLATFORM),msm8974) 139 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 140 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 141 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 142 | else ifeq ($(filter $(TARGET_BOARD_PLATFORM), apq8084 msm8084),$(TARGET_BOARD_PLATFORM)) 143 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 144 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 145 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 146 | else ifeq ($(TARGET_BOARD_PLATFORM),msm8994) 147 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 148 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 149 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 150 | else ifeq ($(TARGET_BOARD_PLATFORM),msm8916 msm8952) 151 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 152 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 153 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 154 | else ifeq ($(TARGET_BOARD_PLATFORM),msm8226) 155 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 156 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 157 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 158 | else ifeq ($(TARGET_BOARD_PLATFORM),msm8610) 159 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 160 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 161 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 162 | else ifeq ($(TARGET_BOARD_PLATFORM),msm8960) 163 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID 164 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 165 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 166 | else ifneq (,$(filter msm8660,$(TARGET_BOARD_PLATFORM))) 167 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID # EBI 168 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 169 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 170 | else 171 | LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=GRALLOC_USAGE_PRIVATE_UNCACHED #uncached 172 | LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_CAMERA_HEAP_ID 173 | LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 174 | endif 175 | LOCAL_CFLAGS += -Wall -Wextra -Werror 176 | 177 | LOCAL_SHARED_LIBRARIES:= \ 178 | libcutils libdl libmmcamera_interface 179 | 180 | LOCAL_MODULE_TAGS := optional 181 | 182 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 183 | 184 | LOCAL_MODULE:= libmm-qcamera 185 | LOCAL_CLANG := false 186 | 187 | include $(BUILD_SHARED_LIBRARY) 188 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-camera-test/inc/mm_qcamera_commands.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, 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_QCAMERA_COMMANDS_H__ 31 | #define __MM_QCAMERA_COMMANDS_H__ 32 | 33 | #include "mm_qcamera_socket.h" 34 | #include "mm_qcamera_app.h" 35 | 36 | int tuneserver_close_cam(mm_camera_lib_handle *lib_handle); 37 | int tuneserver_stop_cam(mm_camera_lib_handle *lib_handle); 38 | int tuneserver_open_cam(mm_camera_lib_handle *lib_handle); 39 | 40 | int tuneserver_initialize_tuningp(void * ctrl, int client_socket_id, 41 | char *send_buf, uint32_t send_len); 42 | int tuneserver_deinitialize_tuningp(void * ctrl, int client_socket_id, 43 | char *send_buf, uint32_t send_len); 44 | int tuneserver_process_get_list_cmd(void * ctrl, void *recv_cmd, 45 | char *send_buf, uint32_t send_len); 46 | int tuneserver_process_misc_cmd(void * ctrl, void *recv_cmd, 47 | char *send_buf, uint32_t send_len); 48 | int tuneserver_process_get_params_cmd(void * ctrl, void *recv_cmd, 49 | char *send_buf, uint32_t send_len); 50 | int tuneserver_process_set_params_cmd(void * ctrl, void *recv_cmd, 51 | char *send_buf, uint32_t send_len); 52 | 53 | int tuneserver_initialize_prevtuningp(void * ctrl, 54 | int pr_client_socket_id, cam_dimension_t dimension, 55 | char **send_buf, uint32_t *send_len); 56 | int tuneserver_deinitialize_prevtuningp(void * ctrl, 57 | char **send_buf, uint32_t *send_len); 58 | int tuneserver_preview_getinfo(void * ctrl, 59 | char **send_buf, uint32_t *send_len); 60 | int tuneserver_preview_getchunksize(void * ctrl, 61 | char **send_buf, uint32_t *send_len); 62 | int tuneserver_preview_getframe(void * ctrl, 63 | char **send_buf, uint32_t *send_len); 64 | int tuneserver_preview_unsupported(void * ctrl, 65 | char **send_buf, uint32_t *send_len); 66 | 67 | #endif /*__MM_QCAMERA_COMMANDS_H__*/ 68 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-camera-test/inc/mm_qcamera_dbg.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 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 | 30 | #ifndef __MM_QCAMERA_DBG_H__ 31 | #define __MM_QCAMERA_DBG_H__ 32 | 33 | #ifdef QCAMERA_REDEFINE_LOG 34 | #define CAM_MODULE CAM_HAL_MODULE 35 | #include "mm_camera_dbg.h" 36 | #endif 37 | 38 | #endif /* __MM_QCAMERA_DBG_H__ */ 39 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-camera-test/inc/mm_qcamera_socket.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013-2014, 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_QCAMERA_SOCKET_H__ 31 | #define __MM_QCAMERA_SOCKET_H__ 32 | 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 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | #undef __FD_SET 53 | #define __FD_SET(fd, fdsetp) \ 54 | (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] |= (1LU<<((fd) & 31))) 55 | 56 | #undef __FD_CLR 57 | #define __FD_CLR(fd, fdsetp) \ 58 | (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] &= ~(1LU<<((fd) & 31))) 59 | 60 | #undef __FD_ISSET 61 | #define __FD_ISSET(fd, fdsetp) \ 62 | ((((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] & (1LU<<((fd) & 31))) != 0) 63 | 64 | #undef __FD_ZERO 65 | #define __FD_ZERO(fdsetp) \ 66 | (memset (fdsetp, 0, sizeof (*(fd_set *)(fdsetp)))) 67 | 68 | #define TUNESERVER_MAX_RECV 2048 69 | #define TUNESERVER_MAX(a, b) (((a) > (b)) ? (a) : (b)) 70 | 71 | #define TUNESERVER_GET_LIST 1014 72 | #define TUNESERVER_GET_PARMS 1015 73 | #define TUNESERVER_SET_PARMS 1016 74 | #define TUNESERVER_MISC_CMDS 1021 75 | 76 | #define TUNE_PREV_GET_INFO 0x0001 77 | #define TUNE_PREV_CH_CNK_SIZE 0x0002 78 | #define TUNE_PREV_GET_PREV_FRAME 0x0003 79 | #define TUNE_PREV_GET_JPG_SNAP 0x0004 80 | #define TUNE_PREV_GET_RAW_SNAP 0x0005 81 | #define TUNE_PREV_GET_RAW_PREV 0x0006 82 | 83 | typedef struct { 84 | char data[128]; 85 | } tuneserver_misc_cmd; 86 | 87 | typedef enum { 88 | TUNESERVER_RECV_COMMAND = 1, 89 | TUNESERVER_RECV_PAYLOAD_SIZE, 90 | TUNESERVER_RECV_PAYLOAD, 91 | TUNESERVER_RECV_RESPONSE, 92 | TUNESERVERER_RECV_INVALID, 93 | } tuneserver_recv_cmd_t; 94 | 95 | typedef struct { 96 | uint16_t current_cmd; 97 | tuneserver_recv_cmd_t next_recv_code; 98 | uint32_t next_recv_len; 99 | void *recv_buf; 100 | uint32_t recv_len; 101 | uint32_t send_len; 102 | void *send_buf; 103 | } tuneserver_protocol_t; 104 | 105 | typedef enum { 106 | TUNE_PREV_RECV_COMMAND = 1, 107 | TUNE_PREV_RECV_NEWCNKSIZE, 108 | TUNE_PREV_RECV_INVALID 109 | } tune_prev_cmd_t; 110 | 111 | typedef struct _eztune_preview_protocol_t { 112 | uint16_t current_cmd; 113 | tune_prev_cmd_t next_recv_code; 114 | uint32_t next_recv_len; 115 | int32_t send_len; 116 | char* send_buf; 117 | uint32_t send_buf_size; 118 | uint32_t new_cnk_size; 119 | uint32_t new_cmd_available; 120 | } prserver_protocol_t; 121 | 122 | typedef union { 123 | struct sockaddr addr; 124 | struct sockaddr_in addr_in; 125 | } mm_qcamera_sock_addr_t; 126 | 127 | int eztune_server_start(void *lib_handle); 128 | 129 | #endif /*__MM_QCAMERA_SOCKET_H__*/ 130 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-camera-test/src/mm_qcamera_queue.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, The Linux Foundataion. 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 | #include "mm_qcamera_dbg.h" 31 | #include "mm_qcamera_app.h" 32 | 33 | int mm_camera_queue_init(mm_camera_queue_t *queue, 34 | release_data_fn data_rel_fn, 35 | void *user_data) 36 | { 37 | if ( NULL == queue ) { 38 | return -1; 39 | } 40 | 41 | pthread_mutex_init(&queue->m_lock, NULL); 42 | cam_list_init(&queue->m_head.list); 43 | queue->m_size = 0; 44 | queue->m_dataFn = data_rel_fn; 45 | queue->m_userData = user_data; 46 | 47 | return MM_CAMERA_OK; 48 | } 49 | 50 | int mm_qcamera_queue_release(mm_camera_queue_t *queue) 51 | { 52 | if ( NULL == queue ) { 53 | return -1; 54 | } 55 | 56 | mm_qcamera_queue_flush(queue); 57 | pthread_mutex_destroy(&queue->m_lock); 58 | 59 | return MM_CAMERA_OK; 60 | } 61 | 62 | int mm_qcamera_queue_isempty(mm_camera_queue_t *queue) 63 | { 64 | if ( NULL == queue ) { 65 | return 0; 66 | } 67 | 68 | int flag = 1; 69 | pthread_mutex_lock(&queue->m_lock); 70 | if (queue->m_size > 0) { 71 | flag = 0; 72 | } 73 | pthread_mutex_unlock(&queue->m_lock); 74 | 75 | return flag; 76 | } 77 | 78 | int mm_qcamera_queue_enqueue(mm_camera_queue_t *queue, void *data) 79 | { 80 | if ( NULL == queue ) { 81 | return -1; 82 | } 83 | 84 | camera_q_node *node = 85 | (camera_q_node *)malloc(sizeof(camera_q_node)); 86 | if (NULL == node) { 87 | LOGE(" No memory for camera_q_node"); 88 | return 0; 89 | } 90 | 91 | memset(node, 0, sizeof(camera_q_node)); 92 | node->data = data; 93 | 94 | pthread_mutex_lock(&queue->m_lock); 95 | cam_list_add_tail_node(&node->list, &queue->m_head.list); 96 | queue->m_size++; 97 | pthread_mutex_unlock(&queue->m_lock); 98 | 99 | return 1; 100 | } 101 | 102 | void* mm_qcamera_queue_dequeue(mm_camera_queue_t *queue, int bFromHead) 103 | { 104 | if ( NULL == queue ) { 105 | return NULL; 106 | } 107 | 108 | camera_q_node* node = NULL; 109 | void* data = NULL; 110 | struct cam_list *head = NULL; 111 | struct cam_list *pos = NULL; 112 | 113 | pthread_mutex_lock(&queue->m_lock); 114 | head = &queue->m_head.list; 115 | if (bFromHead) { 116 | pos = head->next; 117 | } else { 118 | pos = head->prev; 119 | } 120 | if (pos != head) { 121 | node = member_of(pos, camera_q_node, list); 122 | cam_list_del_node(&node->list); 123 | queue->m_size--; 124 | } 125 | pthread_mutex_unlock(&queue->m_lock); 126 | 127 | if (NULL != node) { 128 | data = node->data; 129 | free(node); 130 | } 131 | 132 | return data; 133 | } 134 | 135 | void mm_qcamera_queue_flush(mm_camera_queue_t *queue) 136 | { 137 | camera_q_node* node = NULL; 138 | struct cam_list *head = NULL; 139 | struct cam_list *pos = NULL; 140 | 141 | if ( NULL == queue ) { 142 | return; 143 | } 144 | 145 | pthread_mutex_lock(&queue->m_lock); 146 | head = &queue->m_head.list; 147 | pos = head->next; 148 | 149 | while(pos != head) { 150 | node = member_of(pos, camera_q_node, list); 151 | pos = pos->next; 152 | cam_list_del_node(&node->list); 153 | queue->m_size--; 154 | 155 | if (NULL != node->data) { 156 | if (queue->m_dataFn) { 157 | queue->m_dataFn(node->data, queue->m_userData); 158 | } 159 | free(node->data); 160 | } 161 | free(node); 162 | 163 | } 164 | queue->m_size = 0; 165 | pthread_mutex_unlock(&queue->m_lock); 166 | } 167 | 168 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-jpeg-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 -Werror -Wno-unused-parameter 11 | 12 | LOCAL_C_INCLUDES+= $(kernel_includes) 13 | LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) 14 | 15 | LOCAL_C_INCLUDES += \ 16 | frameworks/native/include/media/openmax \ 17 | $(LOCAL_PATH)/inc \ 18 | $(LOCAL_PATH)/../mm-camera-interface/inc \ 19 | $(LOCAL_PATH)/../common \ 20 | $(LOCAL_PATH)/../../../ \ 21 | $(LOCAL_PATH)/../../../mm-image-codec/qexif \ 22 | $(LOCAL_PATH)/../../../mm-image-codec/qomx_core 23 | ifeq ($(strip $(TARGET_USES_ION)),true) 24 | LOCAL_CFLAGS += -DUSE_ION 25 | endif 26 | 27 | ifneq (,$(filter msm8610,$(TARGET_BOARD_PLATFORM))) 28 | LOCAL_CFLAGS+= -DLOAD_ADSP_RPC_LIB 29 | endif 30 | 31 | DUAL_JPEG_TARGET_LIST := msm8974 32 | DUAL_JPEG_TARGET_LIST += msm8994 33 | 34 | ifneq (,$(filter $(DUAL_JPEG_TARGET_LIST),$(TARGET_BOARD_PLATFORM))) 35 | LOCAL_CFLAGS+= -DMM_JPEG_CONCURRENT_SESSIONS_COUNT=2 36 | else 37 | LOCAL_CFLAGS+= -DMM_JPEG_CONCURRENT_SESSIONS_COUNT=1 38 | endif 39 | 40 | JPEG_PIPELINE_TARGET_LIST := msm8994 41 | JPEG_PIPELINE_TARGET_LIST += msm8992 42 | JPEG_PIPELINE_TARGET_LIST += msm8996 43 | 44 | ifneq (,$(filter $(JPEG_PIPELINE_TARGET_LIST),$(TARGET_BOARD_PLATFORM))) 45 | LOCAL_CFLAGS+= -DMM_JPEG_USE_PIPELINE 46 | endif 47 | 48 | LOCAL_SRC_FILES := \ 49 | src/mm_jpeg_queue.c \ 50 | src/mm_jpeg_exif.c \ 51 | src/mm_jpeg.c \ 52 | src/mm_jpeg_interface.c \ 53 | src/mm_jpeg_ionbuf.c \ 54 | src/mm_jpegdec_interface.c \ 55 | src/mm_jpegdec.c \ 56 | src/mm_jpeg_mpo_composer.c 57 | 58 | LOCAL_MODULE := libmmjpeg_interface 59 | LOCAL_CLANG := false 60 | LOCAL_PRELINK_MODULE := false 61 | LOCAL_SHARED_LIBRARIES := libdl libcutils liblog libqomx_core libmmcamera_interface 62 | LOCAL_MODULE_TAGS := optional 63 | 64 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 65 | include $(BUILD_SHARED_LIBRARY) 66 | 67 | LOCAL_PATH := $(OLD_LOCAL_PATH) 68 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_dbg.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2015, 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 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_inlines.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013, 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 | #include "mm_jpeg.h" 34 | 35 | /** mm_jpeg_get_session: 36 | * 37 | * Arguments: 38 | * @my_obj: jpeg object 39 | * @client_idx: client index 40 | * 41 | * Return: 42 | * job index 43 | * 44 | * Description: 45 | * Get job index by client id 46 | * 47 | **/ 48 | static inline mm_jpeg_job_session_t *mm_jpeg_get_session(mm_jpeg_obj *my_obj, uint32_t job_id) 49 | { 50 | mm_jpeg_job_session_t *p_session = NULL; 51 | int client_idx = GET_CLIENT_IDX(job_id); 52 | int session_idx= GET_SESSION_IDX(job_id); 53 | 54 | LOGD("client_idx %d session_idx %d", 55 | client_idx, session_idx); 56 | if ((session_idx >= MM_JPEG_MAX_SESSION) || 57 | (client_idx >= MAX_JPEG_CLIENT_NUM)) { 58 | LOGE("invalid job id %x", 59 | job_id); 60 | return NULL; 61 | } 62 | pthread_mutex_lock(&my_obj->clnt_mgr[client_idx].lock); 63 | p_session = &my_obj->clnt_mgr[client_idx].session[session_idx]; 64 | pthread_mutex_unlock(&my_obj->clnt_mgr[client_idx].lock); 65 | return p_session; 66 | } 67 | 68 | /** mm_jpeg_get_job_idx: 69 | * 70 | * Arguments: 71 | * @my_obj: jpeg object 72 | * @client_idx: client index 73 | * 74 | * Return: 75 | * job index 76 | * 77 | * Description: 78 | * Get job index by client id 79 | * 80 | **/ 81 | static inline int mm_jpeg_get_new_session_idx(mm_jpeg_obj *my_obj, int client_idx, 82 | mm_jpeg_job_session_t **pp_session) 83 | { 84 | int i = 0; 85 | int index = -1; 86 | for (i = 0; i < MM_JPEG_MAX_SESSION; i++) { 87 | pthread_mutex_lock(&my_obj->clnt_mgr[client_idx].lock); 88 | if (!my_obj->clnt_mgr[client_idx].session[i].active) { 89 | *pp_session = &my_obj->clnt_mgr[client_idx].session[i]; 90 | my_obj->clnt_mgr[client_idx].session[i].active = OMX_TRUE; 91 | index = i; 92 | pthread_mutex_unlock(&my_obj->clnt_mgr[client_idx].lock); 93 | break; 94 | } 95 | pthread_mutex_unlock(&my_obj->clnt_mgr[client_idx].lock); 96 | } 97 | return index; 98 | } 99 | 100 | /** mm_jpeg_get_job_idx: 101 | * 102 | * Arguments: 103 | * @my_obj: jpeg object 104 | * @client_idx: client index 105 | * 106 | * Return: 107 | * job index 108 | * 109 | * Description: 110 | * Get job index by client id 111 | * 112 | **/ 113 | static inline void mm_jpeg_remove_session_idx(mm_jpeg_obj *my_obj, uint32_t job_id) 114 | { 115 | int client_idx = GET_CLIENT_IDX(job_id); 116 | int session_idx= GET_SESSION_IDX(job_id); 117 | LOGD("client_idx %d session_idx %d", 118 | client_idx, session_idx); 119 | pthread_mutex_lock(&my_obj->clnt_mgr[client_idx].lock); 120 | my_obj->clnt_mgr[client_idx].session[session_idx].active = OMX_FALSE; 121 | pthread_mutex_unlock(&my_obj->clnt_mgr[client_idx].lock); 122 | } 123 | 124 | 125 | 126 | #endif /* MM_JPEG_INLINES_H_ */ 127 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_ionbuf.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013-2014, 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 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include "mm_jpeg_dbg.h" 41 | 42 | typedef struct { 43 | struct ion_fd_data ion_info_fd; 44 | struct ion_allocation_data alloc; 45 | int p_pmem_fd; 46 | size_t size; 47 | int ion_fd; 48 | uint8_t *addr; 49 | } buffer_t; 50 | 51 | /** buffer_allocate: 52 | * 53 | * Arguments: 54 | * @p_buffer: ION buffer 55 | * 56 | * Return: 57 | * buffer address 58 | * 59 | * Description: 60 | * allocates ION buffer 61 | * 62 | **/ 63 | void* buffer_allocate(buffer_t *p_buffer, int cached); 64 | 65 | /** buffer_deallocate: 66 | * 67 | * Arguments: 68 | * @p_buffer: ION buffer 69 | * 70 | * Return: 71 | * error val 72 | * 73 | * Description: 74 | * deallocates ION buffer 75 | * 76 | **/ 77 | int buffer_deallocate(buffer_t *p_buffer); 78 | 79 | /** buffer_invalidate: 80 | * 81 | * Arguments: 82 | * @p_buffer: ION buffer 83 | * 84 | * Return: 85 | * error val 86 | * 87 | * Description: 88 | * Invalidates the cached buffer 89 | * 90 | **/ 91 | int buffer_invalidate(buffer_t *p_buffer); 92 | 93 | #endif 94 | 95 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-jpeg-interface/inc/mm_jpeg_mpo.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, 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 | #include 34 | #include "mm_jpeg_interface.h" 35 | #include 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 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_ionbuf.c: -------------------------------------------------------------------------------- 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 | #include "mm_jpeg_ionbuf.h" 31 | #include 32 | #include 33 | #include 34 | 35 | /** buffer_allocate: 36 | * 37 | * Arguments: 38 | * @p_buffer: ION buffer 39 | * 40 | * Return: 41 | * buffer address 42 | * 43 | * Description: 44 | * allocates ION buffer 45 | * 46 | **/ 47 | void *buffer_allocate(buffer_t *p_buffer, int cached) 48 | { 49 | void *l_buffer = NULL; 50 | 51 | int lrc = 0; 52 | struct ion_handle_data lhandle_data; 53 | 54 | p_buffer->alloc.len = p_buffer->size; 55 | p_buffer->alloc.align = 4096; 56 | p_buffer->alloc.flags = (cached) ? ION_FLAG_CACHED : 0; 57 | p_buffer->alloc.heap_id_mask = 0x1 << ION_IOMMU_HEAP_ID; 58 | 59 | p_buffer->ion_fd = open("/dev/ion", O_RDONLY); 60 | if(p_buffer->ion_fd < 0) { 61 | LOGE("Ion open failed"); 62 | goto ION_ALLOC_FAILED; 63 | } 64 | 65 | /* Make it page size aligned */ 66 | p_buffer->alloc.len = (p_buffer->alloc.len + 4095U) & (~4095U); 67 | lrc = ioctl(p_buffer->ion_fd, ION_IOC_ALLOC, &p_buffer->alloc); 68 | if (lrc < 0) { 69 | LOGE("ION allocation failed len %zu", 70 | p_buffer->alloc.len); 71 | goto ION_ALLOC_FAILED; 72 | } 73 | 74 | p_buffer->ion_info_fd.handle = p_buffer->alloc.handle; 75 | lrc = ioctl(p_buffer->ion_fd, ION_IOC_SHARE, 76 | &p_buffer->ion_info_fd); 77 | if (lrc < 0) { 78 | LOGE("ION map failed %s", strerror(errno)); 79 | goto ION_MAP_FAILED; 80 | } 81 | 82 | p_buffer->p_pmem_fd = p_buffer->ion_info_fd.fd; 83 | 84 | l_buffer = mmap(NULL, p_buffer->alloc.len, PROT_READ | PROT_WRITE, 85 | MAP_SHARED,p_buffer->p_pmem_fd, 0); 86 | 87 | if (l_buffer == MAP_FAILED) { 88 | LOGE("ION_MMAP_FAILED: %s (%d)", 89 | strerror(errno), errno); 90 | goto ION_MAP_FAILED; 91 | } 92 | 93 | return l_buffer; 94 | 95 | ION_MAP_FAILED: 96 | lhandle_data.handle = p_buffer->ion_info_fd.handle; 97 | ioctl(p_buffer->ion_fd, ION_IOC_FREE, &lhandle_data); 98 | return NULL; 99 | ION_ALLOC_FAILED: 100 | return NULL; 101 | 102 | } 103 | 104 | /** buffer_deallocate: 105 | * 106 | * Arguments: 107 | * @p_buffer: ION buffer 108 | * 109 | * Return: 110 | * buffer address 111 | * 112 | * Description: 113 | * deallocates ION buffer 114 | * 115 | **/ 116 | int buffer_deallocate(buffer_t *p_buffer) 117 | { 118 | int lrc = 0; 119 | size_t lsize = (p_buffer->size + 4095U) & (~4095U); 120 | 121 | struct ion_handle_data lhandle_data; 122 | lrc = munmap(p_buffer->addr, lsize); 123 | 124 | close(p_buffer->ion_info_fd.fd); 125 | 126 | lhandle_data.handle = p_buffer->ion_info_fd.handle; 127 | ioctl(p_buffer->ion_fd, ION_IOC_FREE, &lhandle_data); 128 | 129 | close(p_buffer->ion_fd); 130 | return lrc; 131 | } 132 | 133 | /** buffer_invalidate: 134 | * 135 | * Arguments: 136 | * @p_buffer: ION buffer 137 | * 138 | * Return: 139 | * error val 140 | * 141 | * Description: 142 | * Invalidates the cached buffer 143 | * 144 | **/ 145 | int buffer_invalidate(buffer_t *p_buffer) 146 | { 147 | int lrc = 0; 148 | struct ion_flush_data cache_inv_data; 149 | struct ion_custom_data custom_data; 150 | 151 | memset(&cache_inv_data, 0, sizeof(cache_inv_data)); 152 | memset(&custom_data, 0, sizeof(custom_data)); 153 | cache_inv_data.vaddr = p_buffer->addr; 154 | cache_inv_data.fd = p_buffer->ion_info_fd.fd; 155 | cache_inv_data.handle = p_buffer->ion_info_fd.handle; 156 | cache_inv_data.length = (unsigned int)p_buffer->size; 157 | custom_data.cmd = (unsigned int)ION_IOC_INV_CACHES; 158 | custom_data.arg = (unsigned long)&cache_inv_data; 159 | 160 | lrc = ioctl(p_buffer->ion_fd, ION_IOC_CUSTOM, &custom_data); 161 | if (lrc < 0) 162 | LOGW("Cache Invalidate failed: %s\n", strerror(errno)); 163 | 164 | return lrc; 165 | } 166 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-jpeg-interface/src/mm_jpeg_queue.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2014, 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 | #include 31 | #include "mm_jpeg_dbg.h" 32 | #include "mm_jpeg.h" 33 | 34 | int32_t mm_jpeg_queue_init(mm_jpeg_queue_t* queue) 35 | { 36 | pthread_mutex_init(&queue->lock, NULL); 37 | cam_list_init(&queue->head.list); 38 | queue->size = 0; 39 | return 0; 40 | } 41 | 42 | int32_t mm_jpeg_queue_enq(mm_jpeg_queue_t* queue, mm_jpeg_q_data_t data) 43 | { 44 | mm_jpeg_q_node_t* node = 45 | (mm_jpeg_q_node_t *)malloc(sizeof(mm_jpeg_q_node_t)); 46 | if (NULL == node) { 47 | LOGE("No memory for mm_jpeg_q_node_t"); 48 | return -1; 49 | } 50 | 51 | memset(node, 0, sizeof(mm_jpeg_q_node_t)); 52 | node->data = data; 53 | 54 | pthread_mutex_lock(&queue->lock); 55 | cam_list_add_tail_node(&node->list, &queue->head.list); 56 | queue->size++; 57 | pthread_mutex_unlock(&queue->lock); 58 | 59 | return 0; 60 | 61 | } 62 | 63 | int32_t mm_jpeg_queue_enq_head(mm_jpeg_queue_t* queue, mm_jpeg_q_data_t data) 64 | { 65 | struct cam_list *head = NULL; 66 | struct cam_list *pos = NULL; 67 | mm_jpeg_q_node_t* node = 68 | (mm_jpeg_q_node_t *)malloc(sizeof(mm_jpeg_q_node_t)); 69 | if (NULL == node) { 70 | LOGE("No memory for mm_jpeg_q_node_t"); 71 | return -1; 72 | } 73 | 74 | memset(node, 0, sizeof(mm_jpeg_q_node_t)); 75 | node->data = data; 76 | 77 | head = &queue->head.list; 78 | pos = head->next; 79 | 80 | pthread_mutex_lock(&queue->lock); 81 | cam_list_insert_before_node(&node->list, pos); 82 | queue->size++; 83 | pthread_mutex_unlock(&queue->lock); 84 | 85 | return 0; 86 | } 87 | 88 | mm_jpeg_q_data_t mm_jpeg_queue_deq(mm_jpeg_queue_t* queue) 89 | { 90 | mm_jpeg_q_data_t data; 91 | mm_jpeg_q_node_t* node = NULL; 92 | struct cam_list *head = NULL; 93 | struct cam_list *pos = NULL; 94 | 95 | memset(&data, 0, sizeof(data)); 96 | 97 | pthread_mutex_lock(&queue->lock); 98 | head = &queue->head.list; 99 | pos = head->next; 100 | if (pos != head) { 101 | node = member_of(pos, mm_jpeg_q_node_t, list); 102 | cam_list_del_node(&node->list); 103 | queue->size--; 104 | } 105 | pthread_mutex_unlock(&queue->lock); 106 | 107 | if (NULL != node) { 108 | data = node->data; 109 | free(node); 110 | } 111 | 112 | return data; 113 | } 114 | 115 | uint32_t mm_jpeg_queue_get_size(mm_jpeg_queue_t* queue) 116 | { 117 | uint32_t size = 0; 118 | 119 | pthread_mutex_lock(&queue->lock); 120 | size = queue->size; 121 | pthread_mutex_unlock(&queue->lock); 122 | 123 | return size; 124 | 125 | } 126 | 127 | int32_t mm_jpeg_queue_deinit(mm_jpeg_queue_t* queue) 128 | { 129 | mm_jpeg_queue_flush(queue); 130 | pthread_mutex_destroy(&queue->lock); 131 | return 0; 132 | } 133 | 134 | int32_t mm_jpeg_queue_flush(mm_jpeg_queue_t* queue) 135 | { 136 | mm_jpeg_q_node_t* node = NULL; 137 | struct cam_list *head = NULL; 138 | struct cam_list *pos = NULL; 139 | 140 | pthread_mutex_lock(&queue->lock); 141 | head = &queue->head.list; 142 | pos = head->next; 143 | 144 | while(pos != head) { 145 | node = member_of(pos, mm_jpeg_q_node_t, list); 146 | cam_list_del_node(&node->list); 147 | queue->size--; 148 | 149 | /* for now we only assume there is no ptr inside data 150 | * so we free data directly */ 151 | if (NULL != node->data.p) { 152 | free(node->data.p); 153 | } 154 | free(node); 155 | pos = pos->next; 156 | } 157 | queue->size = 0; 158 | pthread_mutex_unlock(&queue->lock); 159 | return 0; 160 | } 161 | 162 | mm_jpeg_q_data_t mm_jpeg_queue_peek(mm_jpeg_queue_t* queue) 163 | { 164 | mm_jpeg_q_data_t data; 165 | mm_jpeg_q_node_t* node = NULL; 166 | struct cam_list *head = NULL; 167 | struct cam_list *pos = NULL; 168 | 169 | memset(&data, 0, sizeof(data)); 170 | 171 | pthread_mutex_lock(&queue->lock); 172 | head = &queue->head.list; 173 | pos = head->next; 174 | if (pos != head) { 175 | node = member_of(pos, mm_jpeg_q_node_t, list); 176 | } 177 | pthread_mutex_unlock(&queue->lock); 178 | 179 | if (NULL != node) { 180 | data = node->data; 181 | } 182 | return data; 183 | } 184 | -------------------------------------------------------------------------------- /QCamera2/stack/mm-jpeg-interface/src/mm_jpegdec_interface.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013-2014, 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 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "mm_jpeg_dbg.h" 38 | #include "mm_jpeg_interface.h" 39 | #include "mm_jpeg.h" 40 | 41 | static pthread_mutex_t g_dec_intf_lock = PTHREAD_MUTEX_INITIALIZER; 42 | 43 | static mm_jpeg_obj* g_jpegdec_obj = NULL; 44 | 45 | /** mm_jpeg_intf_start_job: 46 | * 47 | * Arguments: 48 | * @client_hdl: client handle 49 | * @job: jpeg job object 50 | * @jobId: job id 51 | * 52 | * Return: 53 | * 0 success, failure otherwise 54 | * 55 | * Description: 56 | * start the jpeg job 57 | * 58 | **/ 59 | static int32_t mm_jpegdec_intf_start_job(mm_jpeg_job_t* job, uint32_t* job_id) 60 | { 61 | int32_t rc = -1; 62 | 63 | if (NULL == job || 64 | NULL == job_id) { 65 | LOGE("invalid parameters for job or jobId"); 66 | return rc; 67 | } 68 | 69 | pthread_mutex_lock(&g_dec_intf_lock); 70 | if (NULL == g_jpegdec_obj) { 71 | /* mm_jpeg obj not exists, return error */ 72 | LOGE("mm_jpeg is not opened yet"); 73 | pthread_mutex_unlock(&g_dec_intf_lock); 74 | return rc; 75 | } 76 | rc = mm_jpegdec_start_decode_job(g_jpegdec_obj, job, job_id); 77 | pthread_mutex_unlock(&g_dec_intf_lock); 78 | return rc; 79 | } 80 | 81 | /** mm_jpeg_intf_create_session: 82 | * 83 | * Arguments: 84 | * @client_hdl: client handle 85 | * @p_params: encode parameters 86 | * @p_session_id: session id 87 | * 88 | * Return: 89 | * 0 success, failure otherwise 90 | * 91 | * Description: 92 | * Create new jpeg session 93 | * 94 | **/ 95 | static int32_t mm_jpegdec_intf_create_session(uint32_t client_hdl, 96 | mm_jpeg_decode_params_t *p_params, 97 | uint32_t *p_session_id) 98 | { 99 | int32_t rc = -1; 100 | 101 | if (0 == client_hdl || NULL == p_params || NULL == p_session_id) { 102 | LOGE("invalid client_hdl or jobId"); 103 | return rc; 104 | } 105 | 106 | pthread_mutex_lock(&g_dec_intf_lock); 107 | if (NULL == g_jpegdec_obj) { 108 | /* mm_jpeg obj not exists, return error */ 109 | LOGE("mm_jpeg is not opened yet"); 110 | pthread_mutex_unlock(&g_dec_intf_lock); 111 | return rc; 112 | } 113 | 114 | rc = mm_jpegdec_create_session(g_jpegdec_obj, client_hdl, p_params, p_session_id); 115 | pthread_mutex_unlock(&g_dec_intf_lock); 116 | return rc; 117 | } 118 | 119 | /** mm_jpeg_intf_destroy_session: 120 | * 121 | * Arguments: 122 | * @session_id: session id 123 | * 124 | * Return: 125 | * 0 success, failure otherwise 126 | * 127 | * Description: 128 | * Destroy jpeg session 129 | * 130 | **/ 131 | static int32_t mm_jpegdec_intf_destroy_session(uint32_t session_id) 132 | { 133 | int32_t rc = -1; 134 | 135 | if (0 == session_id) { 136 | LOGE("invalid client_hdl or jobId"); 137 | return rc; 138 | } 139 | 140 | pthread_mutex_lock(&g_dec_intf_lock); 141 | if (NULL == g_jpegdec_obj) { 142 | /* mm_jpeg obj not exists, return error */ 143 | LOGE("mm_jpeg is not opened yet"); 144 | pthread_mutex_unlock(&g_dec_intf_lock); 145 | return rc; 146 | } 147 | 148 | rc = mm_jpegdec_destroy_session_by_id(g_jpegdec_obj, session_id); 149 | pthread_mutex_unlock(&g_dec_intf_lock); 150 | return rc; 151 | } 152 | 153 | /** mm_jpegdec_intf_abort_job: 154 | * 155 | * Arguments: 156 | * @jobId: job id 157 | * 158 | * Return: 159 | * 0 success, failure otherwise 160 | * 161 | * Description: 162 | * Abort the jpeg job 163 | * 164 | **/ 165 | static int32_t mm_jpegdec_intf_abort_job(uint32_t job_id) 166 | { 167 | int32_t rc = -1; 168 | 169 | if (0 == job_id) { 170 | LOGE("invalid jobId"); 171 | return rc; 172 | } 173 | 174 | pthread_mutex_lock(&g_dec_intf_lock); 175 | if (NULL == g_jpegdec_obj) { 176 | /* mm_jpeg obj not exists, return error */ 177 | LOGE("mm_jpeg is not opened yet"); 178 | pthread_mutex_unlock(&g_dec_intf_lock); 179 | return rc; 180 | } 181 | 182 | rc = mm_jpegdec_abort_job(g_jpegdec_obj, job_id); 183 | pthread_mutex_unlock(&g_dec_intf_lock); 184 | return rc; 185 | } 186 | 187 | /** mm_jpeg_intf_close: 188 | * 189 | * Arguments: 190 | * @client_hdl: client handle 191 | * 192 | * Return: 193 | * 0 success, failure otherwise 194 | * 195 | * Description: 196 | * Close the jpeg job 197 | * 198 | **/ 199 | static int32_t mm_jpegdec_intf_close(uint32_t client_hdl) 200 | { 201 | int32_t rc = -1; 202 | 203 | if (0 == client_hdl) { 204 | LOGE("invalid client_hdl"); 205 | return rc; 206 | } 207 | 208 | pthread_mutex_lock(&g_dec_intf_lock); 209 | if (NULL == g_jpegdec_obj) { 210 | /* mm_jpeg obj not exists, return error */ 211 | LOGE("mm_jpeg is not opened yet"); 212 | pthread_mutex_unlock(&g_dec_intf_lock); 213 | return rc; 214 | } 215 | 216 | rc = mm_jpeg_close(g_jpegdec_obj, client_hdl); 217 | g_jpegdec_obj->num_clients--; 218 | if(0 == rc) { 219 | if (0 == g_jpegdec_obj->num_clients) { 220 | /* No client, close jpeg internally */ 221 | rc = mm_jpegdec_deinit(g_jpegdec_obj); 222 | free(g_jpegdec_obj); 223 | g_jpegdec_obj = NULL; 224 | } 225 | } 226 | 227 | pthread_mutex_unlock(&g_dec_intf_lock); 228 | return rc; 229 | } 230 | 231 | 232 | 233 | /** jpegdec_open: 234 | * 235 | * Arguments: 236 | * @ops: ops table pointer 237 | * 238 | * Return: 239 | * 0 failure, success otherwise 240 | * 241 | * Description: 242 | * Open a jpeg client 243 | * 244 | **/ 245 | uint32_t jpegdec_open(mm_jpegdec_ops_t *ops) 246 | { 247 | int32_t rc = 0; 248 | uint32_t clnt_hdl = 0; 249 | mm_jpeg_obj* jpeg_obj = NULL; 250 | 251 | pthread_mutex_lock(&g_dec_intf_lock); 252 | /* first time open */ 253 | if(NULL == g_jpegdec_obj) { 254 | jpeg_obj = (mm_jpeg_obj *)malloc(sizeof(mm_jpeg_obj)); 255 | if(NULL == jpeg_obj) { 256 | LOGE("no mem"); 257 | pthread_mutex_unlock(&g_dec_intf_lock); 258 | return clnt_hdl; 259 | } 260 | 261 | /* initialize jpeg obj */ 262 | memset(jpeg_obj, 0, sizeof(mm_jpeg_obj)); 263 | rc = mm_jpegdec_init(jpeg_obj); 264 | if(0 != rc) { 265 | LOGE("mm_jpeg_init err = %d", rc); 266 | free(jpeg_obj); 267 | pthread_mutex_unlock(&g_dec_intf_lock); 268 | return clnt_hdl; 269 | } 270 | 271 | /* remember in global variable */ 272 | g_jpegdec_obj = jpeg_obj; 273 | } 274 | 275 | /* open new client */ 276 | clnt_hdl = mm_jpeg_new_client(g_jpegdec_obj); 277 | if (clnt_hdl > 0) { 278 | /* valid client */ 279 | if (NULL != ops) { 280 | /* fill in ops tbl if ptr not NULL */ 281 | ops->start_job = mm_jpegdec_intf_start_job; 282 | ops->abort_job = mm_jpegdec_intf_abort_job; 283 | ops->create_session = mm_jpegdec_intf_create_session; 284 | ops->destroy_session = mm_jpegdec_intf_destroy_session; 285 | ops->close = mm_jpegdec_intf_close; 286 | } 287 | } else { 288 | /* failed new client */ 289 | LOGE("mm_jpeg_new_client failed"); 290 | 291 | if (0 == g_jpegdec_obj->num_clients) { 292 | /* no client, close jpeg */ 293 | mm_jpegdec_deinit(g_jpegdec_obj); 294 | free(g_jpegdec_obj); 295 | g_jpegdec_obj = NULL; 296 | } 297 | } 298 | 299 | pthread_mutex_unlock(&g_dec_intf_lock); 300 | return clnt_hdl; 301 | } 302 | 303 | 304 | 305 | -------------------------------------------------------------------------------- /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 $(LOCAL_PATH)/../../common.mk 6 | include $(CLEAR_VARS) 7 | LOCAL_PATH := $(MM_JPEG_TEST_PATH) 8 | LOCAL_MODULE_TAGS := optional 9 | 10 | LOCAL_CFLAGS := -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID 11 | LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter 12 | LOCAL_CFLAGS += -D_ANDROID_ -DQCAMERA_REDEFINE_LOG 13 | 14 | ifeq ($(strip $(TARGET_USES_ION)),true) 15 | LOCAL_CFLAGS += -DUSE_ION 16 | endif 17 | 18 | OMX_HEADER_DIR := frameworks/native/include/media/openmax 19 | OMX_CORE_DIR := hardware/qcom/camera/mm-image-codec 20 | 21 | LOCAL_C_INCLUDES := $(MM_JPEG_TEST_PATH) 22 | LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../inc 23 | LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../../common 24 | LOCAL_C_INCLUDES += $(OMX_HEADER_DIR) 25 | LOCAL_C_INCLUDES += $(OMX_CORE_DIR)/qexif 26 | LOCAL_C_INCLUDES += $(OMX_CORE_DIR)/qomx_core 27 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../mm-camera-interface/inc \ 28 | 29 | 30 | LOCAL_C_INCLUDES+= $(kernel_includes) 31 | LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) 32 | 33 | LOCAL_SRC_FILES := mm_jpeg_test.c 34 | 35 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 36 | LOCAL_MODULE := mm-jpeg-interface-test 37 | LOCAL_PRELINK_MODULE := false 38 | LOCAL_SHARED_LIBRARIES := libcutils libdl libmmjpeg_interface libmmcamera_interface 39 | 40 | include $(BUILD_EXECUTABLE) 41 | 42 | 43 | 44 | #decoder int test 45 | 46 | include $(CLEAR_VARS) 47 | LOCAL_PATH := $(MM_JPEG_TEST_PATH) 48 | LOCAL_MODULE_TAGS := optional 49 | 50 | LOCAL_CFLAGS := -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID 51 | LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter 52 | 53 | LOCAL_CFLAGS += -D_ANDROID_ -DQCAMERA_REDEFINE_LOG 54 | 55 | ifeq ($(strip $(TARGET_USES_ION)),true) 56 | LOCAL_CFLAGS += -DUSE_ION 57 | endif 58 | 59 | OMX_HEADER_DIR := frameworks/native/include/media/openmax 60 | OMX_CORE_DIR := hardware/qcom/camera/mm-image-codec 61 | 62 | LOCAL_C_INCLUDES := $(MM_JPEG_TEST_PATH) 63 | LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../inc 64 | LOCAL_C_INCLUDES += $(MM_JPEG_TEST_PATH)/../../common 65 | LOCAL_C_INCLUDES += $(OMX_HEADER_DIR) 66 | LOCAL_C_INCLUDES += $(OMX_CORE_DIR)/qexif 67 | LOCAL_C_INCLUDES += $(OMX_CORE_DIR)/qomx_core 68 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../mm-camera-interface/inc \ 69 | 70 | LOCAL_C_INCLUDES+= $(kernel_includes) 71 | LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) 72 | 73 | LOCAL_SRC_FILES := mm_jpegdec_test.c 74 | 75 | LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) 76 | LOCAL_MODULE := mm-jpegdec-interface-test 77 | LOCAL_PRELINK_MODULE := false 78 | LOCAL_SHARED_LIBRARIES := libcutils libdl libmmjpeg_interface libmmcamera_interface 79 | 80 | include $(BUILD_EXECUTABLE) 81 | 82 | LOCAL_PATH := $(OLD_LOCAL_PATH) 83 | -------------------------------------------------------------------------------- /QCamera2/util/QCameraBufferMaps.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, 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 | #include "cam_types.h" 34 | 35 | namespace qcamera { 36 | 37 | class QCameraBufferMaps { 38 | public: 39 | QCameraBufferMaps(); 40 | QCameraBufferMaps(const QCameraBufferMaps& pBufferMaps); 41 | QCameraBufferMaps(const cam_buf_map_type_list& pBufMapList); 42 | QCameraBufferMaps(cam_mapping_buf_type pType, 43 | uint32_t pStreamId, 44 | uint32_t pFrameIndex, 45 | int32_t pPlaneIndex, 46 | uint32_t pCookie, 47 | int32_t pFd, 48 | size_t pSize); 49 | 50 | ~QCameraBufferMaps(); 51 | 52 | QCameraBufferMaps& operator=(const QCameraBufferMaps& pBufferMaps); 53 | 54 | uint32_t enqueue(cam_mapping_buf_type pType, 55 | uint32_t pStreamId, 56 | uint32_t pFrameIndex, 57 | int32_t pPlaneIndex, 58 | uint32_t pCookie, 59 | int32_t pFd, 60 | size_t pSize); 61 | 62 | uint32_t getCamBufMapList(cam_buf_map_type_list& pBufMapList) const; 63 | 64 | static uint32_t makeSingletonBufMapList(cam_mapping_buf_type pType, 65 | uint32_t pStreamId, 66 | uint32_t pFrameIndex, 67 | int32_t pPlaneIndex, 68 | uint32_t pCookie, 69 | int32_t pFd, 70 | size_t pSize, 71 | cam_buf_map_type_list& pBufMapList); 72 | 73 | private: 74 | cam_buf_map_type_list mBufMapList; 75 | }; 76 | 77 | }; // namespace qcamera 78 | #endif /* __QCAMERA_BUFFERMAPS_H__ */ 79 | 80 | -------------------------------------------------------------------------------- /QCamera2/util/QCameraCmdThread.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2015, The Linux Foundataion. 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 | #include 31 | #include 32 | #include 33 | #include "QCameraCmdThread.h" 34 | #include "QCameraTrace.h" 35 | using namespace android; 36 | 37 | namespace qcamera { 38 | 39 | /*=========================================================================== 40 | * FUNCTION : QCameraCmdThread 41 | * 42 | * DESCRIPTION: default constructor of QCameraCmdThread 43 | * 44 | * PARAMETERS : None 45 | * 46 | * RETURN : None 47 | *==========================================================================*/ 48 | QCameraCmdThread::QCameraCmdThread() : 49 | cmd_queue() 50 | { 51 | cmd_pid = 0; 52 | cam_sem_init(&sync_sem, 0); 53 | cam_sem_init(&cmd_sem, 0); 54 | } 55 | 56 | /*=========================================================================== 57 | * FUNCTION : ~QCameraCmdThread 58 | * 59 | * DESCRIPTION: deconstructor of QCameraCmdThread 60 | * 61 | * PARAMETERS : None 62 | * 63 | * RETURN : None 64 | *==========================================================================*/ 65 | QCameraCmdThread::~QCameraCmdThread() 66 | { 67 | cam_sem_destroy(&sync_sem); 68 | cam_sem_destroy(&cmd_sem); 69 | } 70 | 71 | /*=========================================================================== 72 | * FUNCTION : launch 73 | * 74 | * DESCRIPTION: launch Cmd Thread 75 | * 76 | * PARAMETERS : 77 | * @start_routine : thread routine function ptr 78 | * @user_data : user data ptr 79 | * 80 | * RETURN : int32_t type of status 81 | * NO_ERROR -- success 82 | * none-zero failure code 83 | *==========================================================================*/ 84 | int32_t QCameraCmdThread::launch(void *(*start_routine)(void *), 85 | void* user_data) 86 | { 87 | /* launch the thread */ 88 | pthread_create(&cmd_pid, 89 | NULL, 90 | start_routine, 91 | user_data); 92 | return NO_ERROR; 93 | } 94 | 95 | /*=========================================================================== 96 | * FUNCTION : setName 97 | * 98 | * DESCRIPTION: name the cmd thread 99 | * 100 | * PARAMETERS : 101 | * @name : desired name for the thread 102 | * 103 | * RETURN : int32_t type of status 104 | * NO_ERROR -- success 105 | * none-zero failure code 106 | *==========================================================================*/ 107 | int32_t QCameraCmdThread::setName(const char* name) 108 | { 109 | /* name the thread */ 110 | prctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0); 111 | return NO_ERROR; 112 | } 113 | 114 | /*=========================================================================== 115 | * FUNCTION : sendCmd 116 | * 117 | * DESCRIPTION: send a command to the Cmd Thread 118 | * 119 | * PARAMETERS : 120 | * @cmd : command to be executed. 121 | * @sync_cmd: flag to indicate if this is a synchorinzed cmd. If true, this call 122 | * will wait until signal is set after the command is completed. 123 | * @priority: flag to indicate if this is a cmd with priority. If true, the cmd 124 | * will be enqueued to the head with priority. 125 | * 126 | * RETURN : int32_t type of status 127 | * NO_ERROR -- success 128 | * none-zero failure code 129 | *==========================================================================*/ 130 | int32_t QCameraCmdThread::sendCmd(camera_cmd_type_t cmd, uint8_t sync_cmd, uint8_t priority) 131 | { 132 | camera_cmd_t *node = (camera_cmd_t *)malloc(sizeof(camera_cmd_t)); 133 | if (NULL == node) { 134 | LOGE("No memory for camera_cmd_t"); 135 | return NO_MEMORY; 136 | } 137 | memset(node, 0, sizeof(camera_cmd_t)); 138 | node->cmd = cmd; 139 | 140 | if (priority) { 141 | if (!cmd_queue.enqueueWithPriority((void *)node)) { 142 | free(node); 143 | node = NULL; 144 | } 145 | } else { 146 | if (!cmd_queue.enqueue((void *)node)) { 147 | free(node); 148 | node = NULL; 149 | } 150 | } 151 | cam_sem_post(&cmd_sem); 152 | 153 | /* if is a sync call, need to wait until it returns */ 154 | if (sync_cmd) { 155 | cam_sem_wait(&sync_sem); 156 | } 157 | return NO_ERROR; 158 | } 159 | 160 | /*=========================================================================== 161 | * FUNCTION : getCmd 162 | * 163 | * DESCRIPTION: dequeue a cmommand from cmd queue 164 | * 165 | * PARAMETERS : None 166 | * 167 | * RETURN : cmd dequeued 168 | *==========================================================================*/ 169 | camera_cmd_type_t QCameraCmdThread::getCmd() 170 | { 171 | camera_cmd_type_t cmd = CAMERA_CMD_TYPE_NONE; 172 | camera_cmd_t *node = (camera_cmd_t *)cmd_queue.dequeue(); 173 | if (NULL == node) { 174 | LOGD("No notify avail"); 175 | return CAMERA_CMD_TYPE_NONE; 176 | } else { 177 | cmd = node->cmd; 178 | free(node); 179 | } 180 | return cmd; 181 | } 182 | 183 | /*=========================================================================== 184 | * FUNCTION : exit 185 | * 186 | * DESCRIPTION: exit the CMD thread 187 | * 188 | * PARAMETERS : None 189 | * 190 | * RETURN : int32_t type of status 191 | * NO_ERROR -- success 192 | * none-zero failure code 193 | *==========================================================================*/ 194 | int32_t QCameraCmdThread::exit() 195 | { 196 | int32_t rc = NO_ERROR; 197 | 198 | if (cmd_pid == 0) { 199 | return rc; 200 | } 201 | 202 | rc = sendCmd(CAMERA_CMD_TYPE_EXIT, 0, 1); 203 | if (NO_ERROR != rc) { 204 | LOGE("Error during exit, rc = %d", rc); 205 | return rc; 206 | } 207 | 208 | /* wait until cmd thread exits */ 209 | if (pthread_join(cmd_pid, NULL) != 0) { 210 | LOGD("pthread dead already\n"); 211 | } 212 | cmd_pid = 0; 213 | return rc; 214 | } 215 | 216 | }; // namespace qcamera 217 | -------------------------------------------------------------------------------- /QCamera2/util/QCameraCmdThread.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012, The Linux Foundataion. 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 | #include 34 | #include 35 | 36 | #include "cam_types.h" 37 | #include "QCameraQueue.h" 38 | 39 | namespace qcamera { 40 | 41 | typedef enum 42 | { 43 | CAMERA_CMD_TYPE_NONE, 44 | CAMERA_CMD_TYPE_START_DATA_PROC, 45 | CAMERA_CMD_TYPE_STOP_DATA_PROC, 46 | CAMERA_CMD_TYPE_DO_NEXT_JOB, 47 | CAMERA_CMD_TYPE_EXIT, 48 | CAMERA_CMD_TYPE_MAX 49 | } camera_cmd_type_t; 50 | 51 | typedef struct { 52 | camera_cmd_type_t cmd; 53 | } camera_cmd_t; 54 | 55 | class QCameraCmdThread { 56 | public: 57 | QCameraCmdThread(); 58 | ~QCameraCmdThread(); 59 | 60 | int32_t launch(void *(*start_routine)(void *), void* user_data); 61 | int32_t setName(const char* name); 62 | int32_t exit(); 63 | int32_t sendCmd(camera_cmd_type_t cmd, uint8_t sync_cmd, uint8_t priority); 64 | camera_cmd_type_t getCmd(); 65 | 66 | QCameraQueue cmd_queue; /* cmd queue */ 67 | pthread_t cmd_pid; /* cmd thread ID */ 68 | cam_semaphore_t cmd_sem; /* semaphore for cmd thread */ 69 | cam_semaphore_t sync_sem; /* semaphore for synchronized call signal */ 70 | }; 71 | 72 | }; // namespace qcamera 73 | 74 | #endif /* __QCAMERA_CMD_THREAD_H__ */ 75 | -------------------------------------------------------------------------------- /QCamera2/util/QCameraDisplay.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, 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 6 40 | 41 | class QCameraDisplay { 42 | public: 43 | QCameraDisplay(); 44 | ~QCameraDisplay(); 45 | static int vsyncEventReceiverCamera(int fd, int events, void* data); 46 | static void* vsyncThreadCamera(void * data); 47 | void computeAverageVsyncInterval(nsecs_t currentVsyncTimeStamp); 48 | nsecs_t computePresentationTimeStamp(nsecs_t frameTimeStamp); 49 | 50 | private: 51 | pthread_t mVsyncThreadCameraHandle; 52 | nsecs_t mVsyncTimeStamp; 53 | nsecs_t mAvgVsyncInterval; 54 | nsecs_t mOldTimeStamp; 55 | nsecs_t mVsyncIntervalHistory[CAMERA_NUM_VSYNC_INTERVAL_HISTORY]; 56 | nsecs_t mVsyncHistoryIndex; 57 | nsecs_t mAdditionalVsyncOffsetForWiggle; 58 | uint32_t mThreadExit; 59 | // Tunable property. Increasing this will increase the frame delay and will loose 60 | // the real time display. 61 | uint32_t mNum_vsync_from_vfe_isr_to_presentation_timestamp; 62 | // Tunable property. Set the time stamp x ms prior to expected vsync so that 63 | // it will be picked in that vsync 64 | uint32_t mSet_timestamp_num_ms_prior_to_vsync; 65 | // Tunable property for filtering timestamp wiggle when VFE ISR crosses 66 | // over MDP ISR over a period. Typical scenario is VFE is running at 67 | // 30.2 fps vs display running at 60 fps. 68 | uint32_t mVfe_and_mdp_freq_wiggle_filter_max_ms; 69 | uint32_t mVfe_and_mdp_freq_wiggle_filter_min_ms; 70 | 71 | android::DisplayEventReceiver mDisplayEventReceiver; 72 | }; 73 | 74 | }; // namespace qcamera 75 | 76 | #endif /* __QCAMERADISPLAY_H__ */ 77 | -------------------------------------------------------------------------------- /QCamera2/util/QCameraFlash.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, The Linux Foundataion. 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 | #include 34 | 35 | extern "C" { 36 | #include 37 | } 38 | 39 | namespace qcamera { 40 | 41 | #define QCAMERA_TORCH_CURRENT_VALUE 200 42 | 43 | class QCameraFlash { 44 | public: 45 | static QCameraFlash& getInstance(); 46 | 47 | int32_t registerCallbacks(const camera_module_callbacks_t* callbacks); 48 | int32_t initFlash(const int camera_id); 49 | int32_t setFlashMode(const int camera_id, const bool on); 50 | int32_t deinitFlash(const int camera_id); 51 | int32_t reserveFlashForCamera(const int camera_id); 52 | int32_t releaseFlashFromCamera(const int camera_id); 53 | 54 | private: 55 | QCameraFlash(); 56 | virtual ~QCameraFlash(); 57 | QCameraFlash(const QCameraFlash&); 58 | QCameraFlash& operator=(const QCameraFlash&); 59 | 60 | const camera_module_callbacks_t *m_callbacks; 61 | int32_t m_flashFds[MM_CAMERA_MAX_NUM_SENSORS]; 62 | bool m_flashOn[MM_CAMERA_MAX_NUM_SENSORS]; 63 | bool m_cameraOpen[MM_CAMERA_MAX_NUM_SENSORS]; 64 | }; 65 | 66 | }; // namespace qcamera 67 | 68 | #endif /* __QCAMERA_FLASH_H__ */ 69 | -------------------------------------------------------------------------------- /QCamera2/util/QCameraPerf.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2015, The Linux Foundataion. 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 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | typedef enum { 39 | ALL_CORES_ONLINE = 0x7FE, 40 | ALL_CPUS_PWR_CLPS_DIS = 0x101, 41 | CPU0_MIN_FREQ_TURBO_MAX = 0x2FE, 42 | CPU4_MIN_FREQ_TURBO_MAX = 0x1FFE, 43 | }perf_lock_params_t; 44 | 45 | /* Time related macros */ 46 | #define ONE_SEC 1000 47 | typedef int64_t nsecs_t; 48 | #define NSEC_PER_SEC 1000000000LLU 49 | 50 | using namespace android; 51 | 52 | namespace qcamera { 53 | 54 | class QCameraPerfLock { 55 | public: 56 | QCameraPerfLock(); 57 | ~QCameraPerfLock(); 58 | 59 | void lock_init(); 60 | void lock_deinit(); 61 | int32_t lock_rel(); 62 | int32_t lock_acq(); 63 | int32_t lock_acq_timed(int32_t timer_val); 64 | int32_t lock_rel_timed(); 65 | bool isTimerReset(); 66 | void powerHintInternal(power_hint_t hint, bool enable); 67 | void powerHint(power_hint_t hint, bool enable); 68 | bool isPerfLockTimedAcquired() { return (0 <= mPerfLockHandleTimed); } 69 | 70 | private: 71 | int32_t (*perf_lock_acq)(int, int, int[], int); 72 | int32_t (*perf_lock_rel)(int); 73 | void startTimer(uint32_t timer_val); 74 | void resetTimer(); 75 | void *mDlHandle; 76 | uint32_t mPerfLockEnable; 77 | Mutex mLock; 78 | int32_t mPerfLockHandle; // Performance lock library handle 79 | int32_t mPerfLockHandleTimed; // Performance lock library handle 80 | power_module_t *m_pPowerModule; // power module Handle 81 | power_hint_t mCurrentPowerHint; 82 | bool mCurrentPowerHintEnable; 83 | uint32_t mTimerSet; 84 | uint32_t mPerfLockTimeout; 85 | nsecs_t mStartTimeofLock; 86 | List mActivePowerHints; // Active/enabled power hints list 87 | }; 88 | 89 | }; // namespace qcamera 90 | 91 | #endif /* __QCAMREAPERF_H__ */ 92 | -------------------------------------------------------------------------------- /QCamera2/util/QCameraQueue.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2015, 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 | #include 34 | #include "cam_list.h" 35 | 36 | namespace qcamera { 37 | 38 | typedef bool (*match_fn_data)(void *data, void *user_data, void *match_data); 39 | typedef void (*release_data_fn)(void* data, void *user_data); 40 | typedef bool (*match_fn)(void *data, void *user_data); 41 | 42 | class QCameraQueue { 43 | public: 44 | QCameraQueue(); 45 | QCameraQueue(release_data_fn data_rel_fn, void *user_data); 46 | virtual ~QCameraQueue(); 47 | void init(); 48 | bool enqueue(void *data); 49 | bool enqueueWithPriority(void *data); 50 | /* This call will put queue into uninitialized state. 51 | * Need to call init() in order to use the queue again */ 52 | void flush(); 53 | void flushNodes(match_fn match); 54 | void flushNodes(match_fn_data match, void *spec_data); 55 | void* dequeue(bool bFromHead = true); 56 | void* dequeue(match_fn_data match, void *spec_data); 57 | void* peek(); 58 | bool isEmpty(); 59 | int getCurrentSize() {return m_size;} 60 | private: 61 | typedef struct { 62 | struct cam_list list; 63 | void* data; 64 | } camera_q_node; 65 | 66 | camera_q_node m_head; // dummy head 67 | int m_size; 68 | bool m_active; 69 | pthread_mutex_t m_lock; 70 | release_data_fn m_dataFn; 71 | void * m_userData; 72 | }; 73 | 74 | }; // namespace qcamera 75 | 76 | #endif /* __QCAMERA_QUEUE_H__ */ 77 | -------------------------------------------------------------------------------- /QCamera2/util/QCameraTrace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, 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 | -------------------------------------------------------------------------------- /common.mk: -------------------------------------------------------------------------------- 1 | common_deps := 2 | kernel_includes := 3 | 4 | ifeq ($(call is-vendor-board-platform,QCOM),true) 5 | ifeq ($(TARGET_COMPILE_WITH_MSM_KERNEL),true) 6 | common_deps += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr 7 | kernel_includes += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include 8 | endif 9 | endif 10 | -------------------------------------------------------------------------------- /mm-image-codec/Android.mk: -------------------------------------------------------------------------------- 1 | ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm arm64)) 2 | include $(call all-subdir-makefiles) 3 | endif 4 | -------------------------------------------------------------------------------- /mm-image-codec/qexif/qmpo.h: -------------------------------------------------------------------------------- 1 | /*Copyright (c) 2015, 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 __QMPO_H__ 29 | #define __QMPO_H__ 30 | 31 | #include 32 | #include 33 | 34 | //Length of MPO header fields 35 | #define MP_APP2_FIELD_LENGTH_BYTES 2 36 | #define MP_FORMAT_IDENTIFIER_BYTES 4 37 | #define MP_ENDIAN_BYTES 4 38 | #define MP_HEADER_OFFSET_TO_FIRST_IFD_BYTES 4 39 | #define MP_INDEX_COUNT_BYTES 2 40 | #define MP_INDEX_VERSION_BYTES 12 41 | #define MP_INDEX_NUMBER_OF_IMAGES_BYTES 12 42 | #define MP_INDEX_ENTRY_BYTES 12 43 | #define MP_INDEX_IMAGE_UNIQUE_ID_LIST_BYTES 12 44 | #define MP_INDEX_TOTAL_CAPURED_FRAMES 12 45 | #define MP_INDEX_OFFSET_OF_NEXT_IFD_BYTES 4 46 | #define MP_INDEX_ENTRY_VALUE_BYTES 16 47 | #define MP_INDEX_ENTRY_INDIVIDUAL_IMAGE_ATTRIBUTE_BYTES 4 48 | #define MP_INDEX_ENTRY_INDIVIDUAL_IMAGE_SIZE_BYTES 4 49 | #define MP_INDEX_ENTRY_INDIVIDUAL_IMAGE_DATA_OFFSET_BYTES 4 50 | #define MP_ATTRIBUTE_COUNT_BYTES 2 51 | #define MP_ATTRIBUTE_OFFSET_OF_NEXT_IFD_BYTES 4 52 | #define MP_TAG_BYTES 12 53 | #define MP_INDIVIDUAL_IMAGE_ID_BYTES 33 54 | #define MP_INDEX_IFD_START 2 55 | 56 | #define MPO_BIG_ENDIAN 0x4D4D002A 57 | #define MPO_LITTLE_ENDIAN 0x49492A00 58 | 59 | /* MPO Dependent Type */ 60 | typedef enum 61 | { 62 | NON_DEPENDENT_IMAGE = 0x00000000, // Non dependent image 63 | DEPENDENT_CHILD_IMAGE = 0x40000000, // Dependent child image flag 64 | DEPENDENT_PARENT_IMAGE = 0x80000000, // Dependent parent image flag 65 | DEPENDENT_MASK = 0xc0000000, // Dependent mask 66 | DEPENDENT_MAX, 67 | } qmpo_dependent_t; 68 | 69 | /* MPO Representative Type */ 70 | typedef enum 71 | { 72 | NOT_REPRESENTATIVE_IMAGE = 0x00000000, // Not a representative image 73 | REPRESENTATIVE_IMAGE = 0x20000000, // Representative image flag 74 | REPRESENTATIVE_MASK = 0x20000000, // Representative mask 75 | REPRESENTATIVE_MAX, 76 | } qmpo_representative_t; 77 | 78 | /* MPO Image Data Format Type */ 79 | typedef enum 80 | { 81 | JPEG = 0x00000000, // Image is in JPEG format 82 | NON_JPEG = 0x07000000, // Image is not JPEG 83 | IMAGE_DATA_FORMAT_MASK = 0x07000000, // Image mask 84 | IMAGE_DATA_FORMAT_MAX, 85 | } qmpo_image_data_format_t; 86 | 87 | /* MPO Type */ 88 | typedef enum 89 | { 90 | UNDEFINED = 0x00000000, // MP types undefined 91 | LARGE_TN_CLASS_1 = 0x00010001, // Large thumbnail class 1 image 92 | LARGE_TN_CLASS_2 = 0x00010002, // Large thumbnail class 2 image 93 | MULTI_VIEW_PANORAMA = 0x00020001, // Multi-view Panorama image 94 | MULTI_VIEW_DISPARITY = 0x00020002, // Multi-view Disparity image 95 | MULTI_VIEW_MULTI_ANGLE = 0x00020003, // Multi-view Multi-angle image 96 | BASELINE_PRIMARY = 0x00030000, // Baseline MP Primary image 97 | TYPE_MASK = 0x00ffffff, // Type mask 98 | TYPE_MAX, 99 | } qmpo_type_t; 100 | 101 | // MP Format Version 102 | // Use MPOTAGTYPE_MP_F_VERSION as the exif_tag_type (EXIF_UNDEFINED) 103 | // Count should be 4 104 | #define _ID_MP_F_VERSION_FIRST 0xb000 105 | #define MPOTAGID_MP_F_VERSION_FIRST CONSTRUCT_TAGID(MP_F_VERSION_FIRST, _ID_MP_F_VERSION_FIRST) 106 | #define MPOTAGTYPE_MP_F_VERSION_FIRST EXIF_UNDEFINED 107 | 108 | // Number of Images 109 | // Use MPOTAGTYPE_NUMBER_OF_IMAGES as the exif_tag_type (EXIF_LONG) 110 | // Count should be 1 111 | #define _ID_NUMBER_OF_IMAGES 0xb001 112 | #define MPOTAGID_NUMBER_OF_IMAGES CONSTRUCT_TAGID(NUMBER_OF_IMAGES, _ID_NUMBER_OF_IMAGES) 113 | #define MPOTAGTYPE_NUMBER_OF_IMAGES EXIF_LONG 114 | 115 | // MP Entry 116 | // Use MPOTAGTYPE_MP_ENTRY as the exif_tag_type (EXIF_UNDEFINED) 117 | // Count should be 16 x NumberOfImages 118 | #define _ID_MP_ENTRY 0xb002 119 | #define MPOTAGID_MP_ENTRY CONSTRUCT_TAGID(MP_ENTRY, _ID_MP_ENTRY) 120 | #define MPOTAGTYPE_MP_ENTRY EXIF_UNDEFINED 121 | 122 | // Individual Image Unique ID List 123 | // Use MPOTAGTYPE_IMAGE_UID_LIST as the exif_tag_type (EXIF_UNDEFINED) 124 | // Count should be 33 x NumberOfImages 125 | #define _ID_IMAGE_UID_LIST 0xb003 126 | #define MPOTAGID_IMAGE_UID_LIST CONSTRUCT_TAGID(IMAGE_UID_LIST, _ID_IMAGE_UID_LIST) 127 | #define MPOTAGTYPE_IMAGE_UID_LIST EXIF_UNDEFINED 128 | 129 | // Total Number of Camptured Frames 130 | // Use MPOTAGTYPE_TOTAL_FRAMES as the exif_tag_type (EXIF_LONG) 131 | // Count should be 1 132 | #define _ID_TOTAL_FRAMES 0xb004 133 | #define MPOTAGID_TOTAL_FRAMES CONSTRUCT_TAGID(TOTAL_FRAMES, _ID_TOTAL_FRAMES) 134 | #define MPOTAGTYPE_TOTAL_FRAMES EXIF_LONG 135 | 136 | // MP Format Version 137 | // Use MPOTAGTYPE_MP_F_VERSION as the exif_tag_type (EXIF_UNDEFINED) 138 | // Count should be 4 139 | #define _ID_MP_F_VERSION 0xb000 140 | #define MPOTAGID_MP_F_VERSION CONSTRUCT_TAGID(MP_F_VERSION, _ID_MP_F_VERSION) 141 | #define MPOTAGTYPE_MP_F_VERSION EXIF_UNDEFINED 142 | 143 | // MP Individual Image Number 144 | // Use MPOTAGTYPE_MP_INDIVIDUAL_NUM as the exif_tag_type (EXIF_LONG) 145 | // Count should be 1 146 | #define _ID_MP_INDIVIDUAL_NUM 0xb101 147 | #define MPOTAGID_MP_INDIVIDUAL_NUM CONSTRUCT_TAGID(MP_INDIVIDUAL_NUM, _ID_MP_INDIVIDUAL_NUM) 148 | #define MPOTAGTYPE_MP_INDIVIDUAL_NUM EXIF_LONG 149 | 150 | #endif 151 | -------------------------------------------------------------------------------- /mm-image-codec/qomx_core/Android.mk: -------------------------------------------------------------------------------- 1 | OMX_CORE_PATH := $(call my-dir) 2 | 3 | # ------------------------------------------------------------------------------ 4 | # Make the shared library (libqomx_core) 5 | # ------------------------------------------------------------------------------ 6 | 7 | include $(CLEAR_VARS) 8 | LOCAL_PATH := $(OMX_CORE_PATH) 9 | LOCAL_MODULE_TAGS := optional 10 | 11 | omx_core_defines:= -Werror \ 12 | -g -O0 13 | 14 | LOCAL_CFLAGS := $(omx_core_defines) 15 | 16 | OMX_HEADER_DIR := frameworks/native/include/media/openmax 17 | 18 | LOCAL_C_INCLUDES := $(OMX_HEADER_DIR) 19 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../qexif 20 | 21 | LOCAL_SRC_FILES := qomx_core.c 22 | 23 | LOCAL_MODULE := libqomx_core 24 | LOCAL_PRELINK_MODULE := false 25 | LOCAL_SHARED_LIBRARIES := libcutils libdl 26 | 27 | LOCAL_32_BIT_ONLY := true 28 | include $(BUILD_SHARED_LIBRARY) 29 | -------------------------------------------------------------------------------- /mm-image-codec/qomx_core/qomx_core.h: -------------------------------------------------------------------------------- 1 | /*Copyright (c) 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 | #ifndef QOMX_CORE_H 29 | #define QOMX_CORE_H 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /usbcamcore/inc/QCameraUsbParm.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 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 ANDROID_HARDWARE_QCAMERA_USB_PARM_H 30 | #define ANDROID_HARDWARE_QCAMERA_USB_PARM_H 31 | 32 | 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 49 | #include 50 | #include 51 | #include 52 | } //extern C 53 | 54 | //Error codes 55 | #define NOT_FOUND -1 56 | 57 | /****************************************************************************** 58 | * Macro definitions 59 | ******************************************************************************/ 60 | /* enum definitions for picture formats */ 61 | static const int PICTURE_FORMAT_JPEG = 1; 62 | static const int PICTURE_FORMAT_RAW = 2; 63 | 64 | /* Default preview width in pixels */ 65 | #define DEFAULT_USBCAM_PRVW_WD 1280//640 66 | 67 | /* Default preview height in pixels */ 68 | #define DEFAULT_USBCAM_PRVW_HT 720//480 69 | 70 | /* Default picture format */ 71 | #define DEFAULT_USBCAM_PICT_FMT PICTURE_FORMAT_JPEG 72 | 73 | /* Default picture width in pixels */ 74 | #define DEFAULT_USBCAM_PICT_WD 640 75 | 76 | /* Default picture height in pixels */ 77 | #define DEFAULT_USBCAM_PICT_HT 480 78 | 79 | /* Default picture JPEG quality 0-100 */ 80 | #define DEFAULT_USBCAM_PICT_QLTY 85 81 | 82 | /* Default thumbnail width in pixels */ 83 | #define DEFAULT_USBCAM_THUMBNAIL_WD 432 84 | 85 | /* Default thumbnail height in pixels */ 86 | #define DEFAULT_USBCAM_THUMBNAIL_HT 288 87 | 88 | /* Default thumbnail JPEG quality 0-100 */ 89 | #define DEFAULT_USBCAM_THUMBNAIL_QLTY 85 90 | 91 | /* Default preview format */ 92 | #define DEFAULT_USBCAM_PRVW_FMT HAL_PIXEL_FORMAT_YCrCb_420_SP 93 | 94 | /* minimum of the default preview fps range in milli-Hz */ 95 | #define MIN_PREV_FPS 5000 96 | 97 | /* maximum of the default preview fps range in milli-Hz */ 98 | #define MAX_PREV_FPS 121000 99 | 100 | //for histogram stats 101 | #define HISTOGRAM_STATS_SIZE 257 102 | #define NUM_HISTOGRAM_BUFFERS 3 103 | 104 | namespace android { 105 | 106 | /****************************************************************************** 107 | * Structure definitions 108 | ******************************************************************************/ 109 | typedef struct { 110 | uint32_t aspect_ratio; 111 | uint32_t width; 112 | uint32_t height; 113 | } thumbnail_size_type; 114 | 115 | /****************************************************************************** 116 | * Function: usbCamInitDefaultParameters 117 | * Description: This function sets default parameters to camera HAL context 118 | * 119 | * Input parameters: 120 | * camHal - camera HAL handle 121 | * 122 | * Return values: 123 | * 0 No error 124 | * -1 Error 125 | * 126 | * Notes: none 127 | *****************************************************************************/ 128 | int usbCamInitDefaultParameters(camera_hardware_t *camHal); 129 | 130 | /****************************************************************************** 131 | * Function: usbCamSetParameters 132 | * Description: This function parses the parameter string and stores the 133 | * parameters in the camera HAL handle 134 | * 135 | * Input parameters: 136 | * camHal - camera HAL handle 137 | * params - pointer to parameter string 138 | * 139 | * Return values: 140 | * 0 Success 141 | * -1 Error 142 | * Notes: none 143 | *****************************************************************************/ 144 | int usbCamSetParameters(camera_hardware_t *camHal, const char *params); 145 | 146 | /****************************************************************************** 147 | * Function: usbCamGetParameters 148 | * Description: This function allocates memory for parameter string, 149 | * composes and returns the parameter string 150 | * 151 | * Input parameters: 152 | * camHal - camera HAL handle 153 | * 154 | * Return values: 155 | * Address to the parameter string 156 | * 157 | * Notes: none 158 | *****************************************************************************/ 159 | char* usbCamGetParameters(camera_hardware_t *camHal); 160 | 161 | /****************************************************************************** 162 | * Function: usbCamPutParameters 163 | * Description: This function frees the memory allocated for parameter string 164 | * 165 | * Input parameters: 166 | * camHal - camera HAL handle 167 | * parms - Parameter string 168 | * 169 | * Return values: 170 | * 0 Success 171 | * -1 Error 172 | * Notes: none 173 | *****************************************************************************/ 174 | void usbCamPutParameters(camera_hardware_t *camHal, char *parms); 175 | 176 | }; // namespace android 177 | 178 | #endif /* ANDROID_HARDWARE_QCAMERA_USB_PARM_H */ 179 | --------------------------------------------------------------------------------