diff options
Diffstat (limited to 'camera/QCamera2/stack/mm-camera-test')
18 files changed, 0 insertions, 12780 deletions
diff --git a/camera/QCamera2/stack/mm-camera-test/Android.mk b/camera/QCamera2/stack/mm-camera-test/Android.mk deleted file mode 100644 index 0ea22e0..0000000 --- a/camera/QCamera2/stack/mm-camera-test/Android.mk +++ /dev/null @@ -1,193 +0,0 @@ -OLD_LOCAL_PATH := $(LOCAL_PATH) -LOCAL_PATH:=$(call my-dir) - -# Build command line test app: mm-qcamera-app -include $(LOCAL_PATH)/../../../common.mk -include $(CLEAR_VARS) - -LOCAL_CFLAGS:= \ - -DAMSS_VERSION=$(AMSS_VERSION) \ - $(mmcamera_debug_defines) \ - $(mmcamera_debug_cflags) \ - $(USE_SERVER_TREE) - -ifeq ($(strip $(TARGET_USES_ION)),true) -LOCAL_CFLAGS += -DUSE_ION -endif - -LOCAL_CFLAGS += -D_ANDROID_ -DQCAMERA_REDEFINE_LOG - -# System header file path prefix -LOCAL_CFLAGS += -DSYSTEM_HEADER_PREFIX=sys - -LOCAL_SRC_FILES:= \ - src/mm_qcamera_main_menu.c \ - src/mm_qcamera_app.c \ - src/mm_qcamera_unit_test.c \ - src/mm_qcamera_video.c \ - src/mm_qcamera_preview.c \ - src/mm_qcamera_snapshot.c \ - src/mm_qcamera_rdi.c \ - src/mm_qcamera_reprocess.c\ - src/mm_qcamera_queue.c \ - src/mm_qcamera_socket.c \ - src/mm_qcamera_commands.c -# src/mm_qcamera_dual_test.c \ - -LOCAL_C_INCLUDES:=$(LOCAL_PATH)/inc -LOCAL_C_INCLUDES+= \ - frameworks/native/include/media/openmax \ - $(LOCAL_PATH)/../common \ - $(LOCAL_PATH)/../mm-camera-interface/inc \ - $(LOCAL_PATH)/../../../mm-image-codec/qexif \ - $(LOCAL_PATH)/../../../mm-image-codec/qomx_core - -LOCAL_C_INCLUDES+= $(kernel_includes) -LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) - -LOCAL_CFLAGS += -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID -ifeq ($(TARGET_BOARD_PLATFORM),msm8974) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(filter $(TARGET_BOARD_PLATFORM), apq8084 msm8084),$(TARGET_BOARD_PLATFORM)) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(TARGET_BOARD_PLATFORM),msm8994) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(TARGET_BOARD_PLATFORM),msm8916 msm8952 msm8937 msm8953) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(TARGET_BOARD_PLATFORM),msm8226) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(TARGET_BOARD_PLATFORM),msm8610) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(TARGET_BOARD_PLATFORM),msm8960) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 -else ifneq (,$(filter msm8660,$(TARGET_BOARD_PLATFORM))) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID # EBI - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 -else - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=GRALLOC_USAGE_PRIVATE_UNCACHED #uncached - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_CAMERA_HEAP_ID - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 -endif -LOCAL_CFLAGS += -Wall -Wextra -Werror - -LOCAL_SHARED_LIBRARIES:= \ - libcutils libdl libmmcamera_interface - -LOCAL_MODULE_TAGS := optional - -LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) - -LOCAL_MODULE:= mm-qcamera-app - -include $(BUILD_EXECUTABLE) - -# Build tuning library -include $(CLEAR_VARS) - -LOCAL_CFLAGS:= \ - -DAMSS_VERSION=$(AMSS_VERSION) \ - $(mmcamera_debug_defines) \ - $(mmcamera_debug_cflags) \ - $(USE_SERVER_TREE) - -ifeq ($(strip $(TARGET_USES_ION)),true) -LOCAL_CFLAGS += -DUSE_ION -endif - -LOCAL_CFLAGS += -D_ANDROID_ -DQCAMERA_REDEFINE_LOG - -# System header file path prefix -LOCAL_CFLAGS += -DSYSTEM_HEADER_PREFIX=sys - -LOCAL_SRC_FILES:= \ - src/mm_qcamera_main_menu.c \ - src/mm_qcamera_app.c \ - src/mm_qcamera_unit_test.c \ - src/mm_qcamera_video.c \ - src/mm_qcamera_preview.c \ - src/mm_qcamera_snapshot.c \ - src/mm_qcamera_rdi.c \ - src/mm_qcamera_reprocess.c\ - src/mm_qcamera_queue.c \ - src/mm_qcamera_socket.c \ - src/mm_qcamera_commands.c -# src/mm_qcamera_dual_test.c \ - -LOCAL_C_INCLUDES:=$(LOCAL_PATH)/inc -LOCAL_C_INCLUDES+= \ - frameworks/native/include/media/openmax \ - $(LOCAL_PATH)/../common \ - $(LOCAL_PATH)/../mm-camera-interface/inc \ - $(LOCAL_PATH)/../../../mm-image-codec/qexif \ - $(LOCAL_PATH)/../../../mm-image-codec/qomx_core - -LOCAL_C_INCLUDES+= $(kernel_includes) -LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps) - -LOCAL_CFLAGS += -DCAMERA_ION_HEAP_ID=ION_IOMMU_HEAP_ID -ifeq ($(TARGET_BOARD_PLATFORM),msm8974) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(filter $(TARGET_BOARD_PLATFORM), apq8084 msm8084),$(TARGET_BOARD_PLATFORM)) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(TARGET_BOARD_PLATFORM),msm8994) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(TARGET_BOARD_PLATFORM),msm8916 msm8952 msm8937 msm8953) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(TARGET_BOARD_PLATFORM),msm8226) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(TARGET_BOARD_PLATFORM),msm8610) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=9 -else ifeq ($(TARGET_BOARD_PLATFORM),msm8960) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 -else ifneq (,$(filter msm8660,$(TARGET_BOARD_PLATFORM))) - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_IOMMU_HEAP_ID # EBI - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=0 - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 -else - LOCAL_CFLAGS += -DCAMERA_GRALLOC_CACHING_ID=GRALLOC_USAGE_PRIVATE_UNCACHED #uncached - LOCAL_CFLAGS += -DCAMERA_ION_FALLBACK_HEAP_ID=ION_CAMERA_HEAP_ID - LOCAL_CFLAGS += -DNUM_RECORDING_BUFFERS=5 -endif -LOCAL_CFLAGS += -Wall -Wextra -Werror - -LOCAL_SHARED_LIBRARIES:= \ - libcutils libdl libmmcamera_interface - -LOCAL_MODULE_TAGS := optional - -LOCAL_32_BIT_ONLY := $(BOARD_QTI_CAMERA_32BIT_ONLY) - -LOCAL_MODULE:= libmm-qcamera - -include $(BUILD_SHARED_LIBRARY) - -LOCAL_PATH := $(OLD_LOCAL_PATH) diff --git a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_app.h b/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_app.h deleted file mode 100644 index 1b94ea8..0000000 --- a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_app.h +++ /dev/null @@ -1,533 +0,0 @@ -/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __MM_QCAMERA_APP_H__ -#define __MM_QCAMERA_APP_H__ - -// System dependencies -#include <pthread.h> -#include <linux/msm_ion.h> -#include <linux/msm_mdp.h> - -// Camera dependencies -#include "mm_camera_interface.h" -#include "mm_jpeg_interface.h" -#include "mm_qcamera_socket.h" - -#define MM_QCAMERA_APP_INTERATION 1 - -#define MM_APP_MAX_DUMP_FRAME_NUM 1000 - -#define PREVIEW_BUF_NUM 7 -#define SNAPSHOT_BUF_NUM 10 -#define VIDEO_BUF_NUM 7 -#define ISP_PIX_BUF_NUM 9 -#define STATS_BUF_NUM 4 -#define RDI_BUF_NUM 8 -#define CAPTURE_BUF_NUM 5 - -#define DEFAULT_PREVIEW_FORMAT CAM_FORMAT_YUV_420_NV21 -#define DEFAULT_PREVIEW_WIDTH 1280 -#define DEFAULT_PREVIEW_HEIGHT 960 -#define DEFAULT_PREVIEW_PADDING CAM_PAD_TO_WORD -#define DEFAULT_VIDEO_FORMAT CAM_FORMAT_YUV_420_NV12 -#define DEFAULT_VIDEO_WIDTH 800 -#define DEFAULT_VIDEO_HEIGHT 480 -#define DEFAULT_VIDEO_PADDING CAM_PAD_TO_2K -#define DEFAULT_SNAPSHOT_FORMAT CAM_FORMAT_YUV_420_NV21 -#define DEFAULT_RAW_FORMAT CAM_FORMAT_BAYER_MIPI_RAW_10BPP_GBRG - -#define DEFAULT_SNAPSHOT_WIDTH 4160 -#define DEFAULT_SNAPSHOT_HEIGHT 3120 -#define DEFAULT_SNAPSHOT_PADDING CAM_PAD_TO_WORD - -#define DEFAULT_OV_FORMAT MDP_Y_CRCB_H2V2 -#define DEFAULT_OV_FORMAT_BPP 3/2 -#define DEFAULT_CAMERA_FORMAT_BPP 3/2 -#define FB_PATH "/dev/graphics/fb0" -#define BACKLIGHT_CONTROL "/sys/class/leds/lcd-backlight/brightness" -#define BACKLIGHT_LEVEL "205" - -#define ENABLE_REPROCESSING 1 - -#define INVALID_KEY_PRESS 0 -#define BASE_OFFSET ('Z' - 'A' + 1) -#define BASE_OFFSET_NUM ('Z' - 'A' + 2) - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -typedef enum { - TUNE_CMD_INIT, - TUNE_CMD_GET_LIST, - TUNE_CMD_GET_PARAMS, - TUNE_CMD_SET_PARAMS, - TUNE_CMD_MISC, - TUNE_CMD_DEINIT, -} mm_camera_tune_cmd_t; - -typedef enum { - TUNE_PREVCMD_INIT, - TUNE_PREVCMD_SETDIM, - TUNE_PREVCMD_GETINFO, - TUNE_PREVCMD_GETCHUNKSIZE, - TUNE_PREVCMD_GETFRAME, - TUNE_PREVCMD_UNSUPPORTED, - TUNE_PREVCMD_DEINIT, -} mm_camera_tune_prevcmd_t; - -typedef void (*cam_stream_user_cb) (mm_camera_buf_def_t *frame); -typedef void (*prev_callback) (mm_camera_buf_def_t *preview_frame); - - -typedef struct { - char *send_buf; - uint32_t send_len; - void *next; -} eztune_prevcmd_rsp; - -typedef struct { - int (*command_process) (void *recv, mm_camera_tune_cmd_t cmd, - void *param, char *send_buf, uint32_t send_len); - int (*prevcommand_process) (void *recv, mm_camera_tune_prevcmd_t cmd, - void *param, char **send_buf, uint32_t *send_len); - void (*prevframe_callback) (mm_camera_buf_def_t *preview_frame); -} mm_camera_tune_func_t; - -typedef struct { - mm_camera_tune_func_t *func_tbl; - void *lib_handle; -}mm_camera_tuning_lib_params_t; - -typedef enum { - MM_CAMERA_OK, - MM_CAMERA_E_GENERAL, - MM_CAMERA_E_NO_MEMORY, - MM_CAMERA_E_NOT_SUPPORTED, - MM_CAMERA_E_INVALID_INPUT, - MM_CAMERA_E_INVALID_OPERATION, /* 5 */ - MM_CAMERA_E_ENCODE, - MM_CAMERA_E_BUFFER_REG, - MM_CAMERA_E_PMEM_ALLOC, - MM_CAMERA_E_CAPTURE_FAILED, - MM_CAMERA_E_CAPTURE_TIMEOUT, /* 10 */ -} mm_camera_status_type_t; - -typedef enum { - MM_CHANNEL_TYPE_ZSL, /* preview, and snapshot main */ - MM_CHANNEL_TYPE_CAPTURE, /* snapshot main, and postview */ - MM_CHANNEL_TYPE_PREVIEW, /* preview only */ - MM_CHANNEL_TYPE_SNAPSHOT, /* snapshot main only */ - MM_CHANNEL_TYPE_VIDEO, /* video only */ - MM_CHANNEL_TYPE_RDI, /* rdi only */ - MM_CHANNEL_TYPE_REPROCESS,/* offline reprocess */ - MM_CHANNEL_TYPE_MAX -} mm_camera_channel_type_t; - -typedef struct { - int fd; - int main_ion_fd; - ion_user_handle_t handle; - size_t size; - parm_buffer_t *data; -} mm_camera_app_meminfo_t; - -typedef struct { - mm_camera_buf_def_t buf; - mm_camera_app_meminfo_t mem_info; -} mm_camera_app_buf_t; - -typedef struct { - uint32_t s_id; - mm_camera_stream_config_t s_config; - cam_frame_len_offset_t offset; - uint8_t num_of_bufs; - uint32_t multipleOf; - mm_camera_app_buf_t s_bufs[MM_CAMERA_MAX_NUM_FRAMES]; - mm_camera_app_buf_t s_info_buf; -} mm_camera_stream_t; - -typedef struct { - uint32_t ch_id; - uint8_t num_streams; - mm_camera_stream_t streams[MAX_STREAM_NUM_IN_BUNDLE]; -} mm_camera_channel_t; - -typedef void (*release_data_fn)(void* data, void *user_data); - -typedef struct { - struct cam_list list; - void* data; -} camera_q_node; - -typedef struct { - camera_q_node m_head; - int m_size; - pthread_mutex_t m_lock; - release_data_fn m_dataFn; - void * m_userData; -} mm_camera_queue_t; - -typedef struct { - uint16_t user_input_display_width; - uint16_t user_input_display_height; -} USER_INPUT_DISPLAY_T; - -typedef struct { - mm_camera_vtbl_t *cam; - uint8_t num_channels; - mm_camera_channel_t channels[MM_CHANNEL_TYPE_MAX]; - mm_jpeg_ops_t jpeg_ops; - uint32_t jpeg_hdl; - mm_camera_app_buf_t cap_buf; - mm_camera_app_buf_t parm_buf; - - uint32_t current_jpeg_sess_id; - mm_camera_super_buf_t* current_job_frames; - uint32_t current_job_id; - mm_camera_app_buf_t jpeg_buf; - - int fb_fd; - struct fb_var_screeninfo vinfo; - struct mdp_overlay data_overlay; - uint32_t slice_size; - uint32_t buffer_width, buffer_height; - uint32_t buffer_size; - cam_format_t buffer_format; - uint32_t frame_size; - uint32_t frame_count; - int encodeJpeg; - int zsl_enabled; - int8_t focus_supported; - cam_stream_user_cb user_preview_cb; - cam_stream_user_cb user_metadata_cb; - parm_buffer_t *params_buffer; - USER_INPUT_DISPLAY_T preview_resolution; - - //Reprocess params&stream - int8_t enable_reproc; - int32_t reproc_sharpness; - cam_denoise_param_t reproc_wnr; - int8_t enable_CAC; - mm_camera_queue_t pp_frames; - mm_camera_stream_t *reproc_stream; - metadata_buffer_t *metadata; - int8_t is_chromatix_reload; -} mm_camera_test_obj_t; - -typedef struct { - void *ptr; - void* ptr_jpeg; - - uint8_t (*get_num_of_cameras) (); - int32_t (*mm_camera_open) (uint8_t camera_idx, mm_camera_vtbl_t **camera_vtbl); - uint32_t (*jpeg_open)(mm_jpeg_ops_t *ops, mm_jpeg_mpo_ops_t *mpo_ops, - mm_dimension picture_size, - cam_jpeg_metadata_t *jpeg_metadata); - -} hal_interface_lib_t; - -typedef struct { - uint8_t num_cameras; - hal_interface_lib_t hal_lib; -} mm_camera_app_t; - -typedef struct { - uint32_t width; - uint32_t height; -} mm_camera_lib_snapshot_params; - -typedef enum { - MM_CAMERA_LIB_NO_ACTION = 0, - MM_CAMERA_LIB_RAW_CAPTURE, - MM_CAMERA_LIB_JPEG_CAPTURE, - MM_CAMERA_LIB_SET_FOCUS_MODE, - MM_CAMERA_LIB_DO_AF, - MM_CAMERA_LIB_CANCEL_AF, - MM_CAMERA_LIB_LOCK_AE, - MM_CAMERA_LIB_UNLOCK_AE, - MM_CAMERA_LIB_LOCK_AWB, - MM_CAMERA_LIB_UNLOCK_AWB, - MM_CAMERA_LIB_GET_CHROMATIX, - MM_CAMERA_LIB_SET_RELOAD_CHROMATIX, - MM_CAMERA_LIB_GET_AFTUNE, - MM_CAMERA_LIB_SET_RELOAD_AFTUNE, - MM_CAMERA_LIB_SET_AUTOFOCUS_TUNING, - MM_CAMERA_LIB_ZSL_ENABLE, - MM_CAMERA_LIB_EV, - MM_CAMERA_LIB_ANTIBANDING, - MM_CAMERA_LIB_SET_VFE_COMMAND, - MM_CAMERA_LIB_SET_POSTPROC_COMMAND, - MM_CAMERA_LIB_SET_3A_COMMAND, - MM_CAMERA_LIB_AEC_ENABLE, - MM_CAMERA_LIB_AEC_DISABLE, - MM_CAMERA_LIB_AF_ENABLE, - MM_CAMERA_LIB_AF_DISABLE, - MM_CAMERA_LIB_AWB_ENABLE, - MM_CAMERA_LIB_AWB_DISABLE, - MM_CAMERA_LIB_AEC_FORCE_LC, - MM_CAMERA_LIB_AEC_FORCE_GAIN, - MM_CAMERA_LIB_AEC_FORCE_EXP, - MM_CAMERA_LIB_AEC_FORCE_SNAP_LC, - MM_CAMERA_LIB_AEC_FORCE_SNAP_GAIN, - MM_CAMERA_LIB_AEC_FORCE_SNAP_EXP, - MM_CAMERA_LIB_WB, - MM_CAMERA_LIB_EXPOSURE_METERING, - MM_CAMERA_LIB_BRIGHTNESS, - MM_CAMERA_LIB_CONTRAST, - MM_CAMERA_LIB_SATURATION, - MM_CAMERA_LIB_SHARPNESS, - MM_CAMERA_LIB_ISO, - MM_CAMERA_LIB_ZOOM, - MM_CAMERA_LIB_BESTSHOT, - MM_CAMERA_LIB_FLASH, - MM_CAMERA_LIB_FPS_RANGE, - MM_CAMERA_LIB_WNR_ENABLE, - MM_CAMERA_LIB_SET_TINTLESS, -} mm_camera_lib_commands; - -typedef struct { - int32_t stream_width, stream_height; - cam_focus_mode_type af_mode; -} mm_camera_lib_params; - -typedef struct { - tuneserver_protocol_t *proto; - int clientsocket_id; - prserver_protocol_t *pr_proto; - int pr_clientsocket_id; - mm_camera_tuning_lib_params_t tuning_params; -} tuningserver_t; - -typedef struct { - mm_camera_app_t app_ctx; - mm_camera_test_obj_t test_obj; - mm_camera_lib_params current_params; - int stream_running; - tuningserver_t tsctrl; -} mm_camera_lib_ctx; - -typedef mm_camera_lib_ctx mm_camera_lib_handle; - -typedef int (*mm_app_test_t) (mm_camera_app_t *cam_apps); -typedef struct { - mm_app_test_t f; - int r; -} mm_app_tc_t; - -extern int mm_app_unit_test_entry(mm_camera_app_t *cam_app); -extern int mm_app_dual_test_entry(mm_camera_app_t *cam_app); -extern int setmetainfoCommand(mm_camera_test_obj_t *test_obj, - cam_stream_size_info_t *value); - -extern void mm_app_dump_frame(mm_camera_buf_def_t *frame, - char *name, - char *ext, - uint32_t frame_idx); -extern void mm_app_dump_jpeg_frame(const void * data, - size_t size, - char* name, - char* ext, - uint32_t index); -extern int mm_camera_app_timedwait(uint8_t seconds); -extern int mm_camera_app_wait(); -extern void mm_camera_app_done(); -extern int mm_app_alloc_bufs(mm_camera_app_buf_t* app_bufs, - cam_frame_len_offset_t *frame_offset_info, - uint8_t num_bufs, - uint8_t is_streambuf, - size_t multipleOf); -extern int mm_app_release_bufs(uint8_t num_bufs, - mm_camera_app_buf_t* app_bufs); -extern int mm_app_stream_initbuf(cam_frame_len_offset_t *frame_offset_info, - uint8_t *num_bufs, - uint8_t **initial_reg_flag, - mm_camera_buf_def_t **bufs, - mm_camera_map_unmap_ops_tbl_t *ops_tbl, - void *user_data); -extern int32_t mm_app_stream_deinitbuf(mm_camera_map_unmap_ops_tbl_t *ops_tbl, - void *user_data); -extern int mm_app_cache_ops(mm_camera_app_meminfo_t *mem_info, int cmd); -extern int32_t mm_app_stream_clean_invalidate_buf(uint32_t index, void *user_data); -extern int32_t mm_app_stream_invalidate_buf(uint32_t index, void *user_data); -extern int mm_app_open(mm_camera_app_t *cam_app, - int cam_id, - mm_camera_test_obj_t *test_obj); -extern int mm_app_close(mm_camera_test_obj_t *test_obj); -extern mm_camera_channel_t * mm_app_add_channel( - mm_camera_test_obj_t *test_obj, - mm_camera_channel_type_t ch_type, - mm_camera_channel_attr_t *attr, - mm_camera_buf_notify_t channel_cb, - void *userdata); -extern int mm_app_del_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel); -extern mm_camera_stream_t * mm_app_add_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel); -extern int mm_app_del_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_stream_t *stream); -extern int mm_app_config_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_stream_t *stream, - mm_camera_stream_config_t *config); -extern int mm_app_start_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel); -extern int mm_app_stop_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel); -extern mm_camera_channel_t *mm_app_get_channel_by_type( - mm_camera_test_obj_t *test_obj, - mm_camera_channel_type_t ch_type); - -extern int mm_app_start_preview(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_preview(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_preview_zsl(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_preview_zsl(mm_camera_test_obj_t *test_obj); -extern mm_camera_channel_t * mm_app_add_preview_channel( - mm_camera_test_obj_t *test_obj); -extern mm_camera_stream_t * mm_app_add_raw_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst); -extern int mm_app_stop_and_del_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel); -extern mm_camera_channel_t * mm_app_add_snapshot_channel( - mm_camera_test_obj_t *test_obj); -extern mm_camera_stream_t * mm_app_add_snapshot_stream( - mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst); -extern mm_camera_stream_t * mm_app_add_metadata_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs); -extern int mm_app_start_record_preview(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_record_preview(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_record(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_record(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_live_snapshot(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_live_snapshot(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_capture(mm_camera_test_obj_t *test_obj, - uint8_t num_snapshots); -extern int mm_app_stop_capture(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_capture_raw(mm_camera_test_obj_t *test_obj, - uint8_t num_snapshots); -extern int mm_app_stop_capture_raw(mm_camera_test_obj_t *test_obj); -extern int mm_app_start_rdi(mm_camera_test_obj_t *test_obj, uint8_t num_burst); -extern int mm_app_stop_rdi(mm_camera_test_obj_t *test_obj); -extern int mm_app_initialize_fb(mm_camera_test_obj_t *test_obj); -extern int mm_app_close_fb(mm_camera_test_obj_t *test_obj); -extern int mm_app_fb_write(mm_camera_test_obj_t *test_obj, char *buffer); -extern int mm_app_overlay_display(mm_camera_test_obj_t *test_obj, int bufferFd); -extern int mm_app_allocate_ion_memory(mm_camera_app_buf_t *buf, unsigned int ion_type); -extern int mm_app_deallocate_ion_memory(mm_camera_app_buf_t *buf); -extern int mm_app_set_params(mm_camera_test_obj_t *test_obj, - cam_intf_parm_type_t param_type, - int32_t value); -extern int mm_app_set_preview_fps_range(mm_camera_test_obj_t *test_obj, - cam_fps_range_t *fpsRange); -extern int mm_app_set_face_detection(mm_camera_test_obj_t *test_obj, - cam_fd_set_parm_t *fd_set_parm); -extern int mm_app_set_metadata_usercb(mm_camera_test_obj_t *test_obj, - cam_stream_user_cb usercb); -extern int mm_app_set_face_detection(mm_camera_test_obj_t *test_obj, - cam_fd_set_parm_t *fd_set_parm); -extern int mm_app_set_flash_mode(mm_camera_test_obj_t *test_obj, - cam_flash_mode_t flashMode); - -/* JIG camera lib interface */ - -int mm_camera_lib_open(mm_camera_lib_handle *handle, int cam_id); -int mm_camera_lib_get_caps(mm_camera_lib_handle *handle, - cam_capability_t *caps); -int mm_camera_lib_start_stream(mm_camera_lib_handle *handle); -int mm_camera_lib_send_command(mm_camera_lib_handle *handle, - mm_camera_lib_commands cmd, - void *data, void *out_data); -int mm_camera_lib_stop_stream(mm_camera_lib_handle *handle); -int mm_camera_lib_number_of_cameras(mm_camera_lib_handle *handle); -int mm_camera_lib_close(mm_camera_lib_handle *handle); -int32_t mm_camera_load_tuninglibrary( - mm_camera_tuning_lib_params_t *tuning_param); -int mm_camera_lib_set_preview_usercb( - mm_camera_lib_handle *handle, cam_stream_user_cb cb); -// - -int mm_app_start_regression_test(int run_tc); -int mm_app_load_hal(mm_camera_app_t *my_cam_app); - -extern int createEncodingSession(mm_camera_test_obj_t *test_obj, - mm_camera_stream_t *m_stream, - mm_camera_buf_def_t *m_frame); -extern int encodeData(mm_camera_test_obj_t *test_obj, mm_camera_super_buf_t* recvd_frame, - mm_camera_stream_t *m_stream); -extern int mm_app_take_picture(mm_camera_test_obj_t *test_obj, uint8_t); - -extern mm_camera_channel_t * mm_app_add_reprocess_channel(mm_camera_test_obj_t *test_obj, - mm_camera_stream_t *source_stream); -extern int mm_app_start_reprocess(mm_camera_test_obj_t *test_obj); -extern int mm_app_stop_reprocess(mm_camera_test_obj_t *test_obj); -extern int mm_app_do_reprocess(mm_camera_test_obj_t *test_obj, - mm_camera_buf_def_t *frame, - uint32_t meta_idx, - mm_camera_super_buf_t *super_buf, - mm_camera_stream_t *src_meta); -extern void mm_app_release_ppinput(void *data, void *user_data); - -extern int mm_camera_queue_init(mm_camera_queue_t *queue, - release_data_fn data_rel_fn, - void *user_data); -extern int mm_qcamera_queue_release(mm_camera_queue_t *queue); -extern int mm_qcamera_queue_isempty(mm_camera_queue_t *queue); -extern int mm_qcamera_queue_enqueue(mm_camera_queue_t *queue, void *data); -extern void* mm_qcamera_queue_dequeue(mm_camera_queue_t *queue, - int bFromHead); -extern void mm_qcamera_queue_flush(mm_camera_queue_t *queue); - -#endif /* __MM_QCAMERA_APP_H__ */ - - - - - - - - - diff --git a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_commands.h b/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_commands.h deleted file mode 100644 index 1a7ac33..0000000 --- a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_commands.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (c) 2013, 2016, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __MM_QCAMERA_COMMANDS_H__ -#define __MM_QCAMERA_COMMANDS_H__ - -// Camera dependencies -#include "mm_qcamera_socket.h" -#include "mm_qcamera_app.h" - -int tuneserver_close_cam(mm_camera_lib_handle *lib_handle); -int tuneserver_stop_cam(mm_camera_lib_handle *lib_handle); -int tuneserver_open_cam(mm_camera_lib_handle *lib_handle); - -int tuneserver_initialize_tuningp(void * ctrl, int client_socket_id, - char *send_buf, uint32_t send_len); -int tuneserver_deinitialize_tuningp(void * ctrl, int client_socket_id, - char *send_buf, uint32_t send_len); -int tuneserver_process_get_list_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len); -int tuneserver_process_misc_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len); -int tuneserver_process_get_params_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len); -int tuneserver_process_set_params_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len); - -int tuneserver_initialize_prevtuningp(void * ctrl, - int pr_client_socket_id, cam_dimension_t dimension, - char **send_buf, uint32_t *send_len); -int tuneserver_deinitialize_prevtuningp(void * ctrl, - char **send_buf, uint32_t *send_len); -int tuneserver_preview_getinfo(void * ctrl, - char **send_buf, uint32_t *send_len); -int tuneserver_preview_getchunksize(void * ctrl, - char **send_buf, uint32_t *send_len); -int tuneserver_preview_getframe(void * ctrl, - char **send_buf, uint32_t *send_len); -int tuneserver_preview_unsupported(void * ctrl, - char **send_buf, uint32_t *send_len); - -#endif /*__MM_QCAMERA_COMMANDS_H__*/ diff --git a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_dbg.h b/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_dbg.h deleted file mode 100644 index acd197e..0000000 --- a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_dbg.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __MM_QCAMERA_DBG_H__ -#define __MM_QCAMERA_DBG_H__ - -#ifdef QCAMERA_REDEFINE_LOG -#define CAM_MODULE CAM_HAL_MODULE -#include "mm_camera_dbg.h" -#endif - -#endif /* __MM_QCAMERA_DBG_H__ */ diff --git a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_main_menu.h b/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_main_menu.h deleted file mode 100644 index 1b9eb4e..0000000 --- a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_main_menu.h +++ /dev/null @@ -1,439 +0,0 @@ -/* Copyright (c) 2013, 2016, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __MM_QCAMERA_MAIN_MENU_H__ -#define __MM_QCAMERA_MAIN_MENU_H__ - -// Camera dependencies -#include "mm_camera_interface.h" -#include "mm_jpeg_interface.h" - -#define VIDEO_BUFFER_SIZE (PREVIEW_WIDTH * PREVIEW_HEIGHT * 3/2) -#define THUMBNAIL_BUFFER_SIZE (THUMBNAIL_WIDTH * THUMBNAIL_HEIGHT * 3/2) -#define SNAPSHOT_BUFFER_SIZE (PICTURE_WIDTH * PICTURE_HEIGHT * 3/2) - -/*=========================================================================== - * Macro - *===========================================================================*/ -#define PREVIEW_FRAMES_NUM 5 -#define VIDEO_FRAMES_NUM 5 -#define THUMBNAIL_FRAMES_NUM 1 -#define SNAPSHOT_FRAMES_NUM 1 -#define MAX_NUM_FORMAT 32 - -typedef enum -{ - START_PREVIEW, - STOP_PREVIEW, - SET_WHITE_BALANCE, - SET_TINTLESS_ENABLE, - SET_TINTLESS_DISABLE, - SET_EXP_METERING, - GET_CTRL_VALUE, - TOGGLE_AFR, - SET_ISO, - BRIGHTNESS_GOTO_SUBMENU, - CONTRAST_GOTO_SUBMENU, - EV_GOTO_SUBMENU, - SATURATION_GOTO_SUBMENU, - SET_ZOOM, - SET_SHARPNESS, - TAKE_JPEG_SNAPSHOT, - START_RECORDING, - STOP_RECORDING, - BEST_SHOT, - LIVE_SHOT, - FLASH_MODES, - TOGGLE_ZSL, - TAKE_RAW_SNAPSHOT, - SWITCH_SNAP_RESOLUTION, - TOGGLE_WNR, - EXIT -} Camera_main_menu_t; - -typedef enum -{ - ACTION_NO_ACTION, - ACTION_START_PREVIEW, - ACTION_STOP_PREVIEW, - ACTION_SET_WHITE_BALANCE, - ACTION_SET_TINTLESS_ENABLE, - ACTION_SET_TINTLESS_DISABLE, - ACTION_SET_EXP_METERING, - ACTION_GET_CTRL_VALUE, - ACTION_TOGGLE_AFR, - ACTION_SET_ISO, - ACTION_BRIGHTNESS_INCREASE, - ACTION_BRIGHTNESS_DECREASE, - ACTION_CONTRAST_INCREASE, - ACTION_CONTRAST_DECREASE, - ACTION_EV_INCREASE, - ACTION_EV_DECREASE, - ACTION_SATURATION_INCREASE, - ACTION_SATURATION_DECREASE, - ACTION_SET_ZOOM, - ACTION_SHARPNESS_INCREASE, - ACTION_SHARPNESS_DECREASE, - ACTION_TAKE_JPEG_SNAPSHOT, - ACTION_START_RECORDING, - ACTION_STOP_RECORDING, - ACTION_SET_BESTSHOT_MODE, - ACTION_TAKE_LIVE_SNAPSHOT, - ACTION_SET_FLASH_MODE, - ACTION_SWITCH_CAMERA, - ACTION_TOGGLE_ZSL, - ACTION_TAKE_RAW_SNAPSHOT, - ACTION_SWITCH_RESOLUTION, - ACTION_TOGGLE_WNR, - ACTION_EXIT -} camera_action_t; - -#define INVALID_KEY_PRESS 0 -#define BASE_OFFSET ('Z' - 'A' + 1) -#define BASE_OFFSET_NUM ('Z' - 'A' + 2) -#define PAD_TO_WORD(a) (((a)+3)&~3) - - -#define SQCIF_WIDTH 128 -#define SQCIF_HEIGHT 96 -#define QCIF_WIDTH 176 -#define QCIF_HEIGHT 144 -#define QVGA_WIDTH 320 -#define QVGA_HEIGHT 240 -#define HD_THUMBNAIL_WIDTH 256 -#define HD_THUMBNAIL_HEIGHT 144 -#define CIF_WIDTH 352 -#define CIF_HEIGHT 288 -#define VGA_WIDTH 640 -#define VGA_HEIGHT 480 -#define WVGA_WIDTH 800 -#define WVGA_HEIGHT 480 -#define WVGA_PLUS_WIDTH 960 -#define WVGA_PLUS_HEIGHT 720 - -#define MP1_WIDTH 1280 -#define MP1_HEIGHT 960 -#define MP2_WIDTH 1600 -#define MP2_HEIGHT 1200 -#define MP3_WIDTH 2048 -#define MP3_HEIGHT 1536 -#define MP5_WIDTH 2592 -#define MP5_HEIGHT 1944 -#define MP8_WIDTH 3264 -#define MP8_HEIGHT 2448 -#define MP12_WIDTH 4000 -#define MP12_HEIGHT 3000 - -#define SVGA_WIDTH 800 -#define SVGA_HEIGHT 600 -#define XGA_WIDTH 1024 -#define XGA_HEIGHT 768 -#define HD720_WIDTH 1280 -#define HD720_HEIGHT 720 -#define HD720_PLUS_WIDTH 1440 -#define HD720_PLUS_HEIGHT 1080 -#define WXGA_WIDTH 1280 -#define WXGA_HEIGHT 768 -#define HD1080_WIDTH 1920 -#define HD1080_HEIGHT 1080 - - -#define ONEMP_WIDTH 1280 -#define SXGA_WIDTH 1280 -#define UXGA_WIDTH 1600 -#define QXGA_WIDTH 2048 -#define FIVEMP_WIDTH 2560 - - -#define ONEMP_HEIGHT 960 -#define SXGA_HEIGHT 1024 -#define UXGA_HEIGHT 1200 -#define QXGA_HEIGHT 1536 -#define FIVEMP_HEIGHT 1920 - - -typedef enum -{ - RESOLUTION_MIN, - QCIF = RESOLUTION_MIN, - QVGA, - VGA, - WVGA, - WVGA_PLUS , - HD720, - HD720_PLUS, - HD1080, - RESOLUTION_PREVIEW_VIDEO_MAX = HD1080, - WXGA, - MP1, - MP2, - MP3, - MP5, - MP8, - MP12, - RESOLUTION_MAX = MP12, -} Camera_Resolution; - -typedef struct{ - uint16_t width; - uint16_t height; - char * name; - char * str_name; - int supported; -} DIMENSION_TBL_T; - -typedef enum { - WHITE_BALANCE_STATE, - WHITE_BALANCE_TEMPERATURE, - BRIGHTNESS_CTRL, - EV, - CONTRAST_CTRL, - SATURATION_CTRL, - SHARPNESS_CTRL -} Get_Ctrl_modes; - -typedef enum { - AUTO_EXP_FRAME_AVG, - AUTO_EXP_CENTER_WEIGHTED, - AUTO_EXP_SPOT_METERING, - AUTO_EXP_SMART_METERING, - AUTO_EXP_USER_METERING, - AUTO_EXP_SPOT_METERING_ADV, - AUTO_EXP_CENTER_WEIGHTED_ADV, - AUTO_EXP_MAX -} Exp_Metering_modes; - -typedef enum { - ISO_AUTO, - ISO_DEBLUR, - ISO_100, - ISO_200, - ISO_400, - ISO_800, - ISO_1600, - ISO_MAX -} ISO_modes; - -typedef enum { - BESTSHOT_AUTO, - BESTSHOT_ACTION, - BESTSHOT_PORTRAIT, - BESTSHOT_LANDSCAPE, - BESTSHOT_NIGHT, - BESTSHOT_NIGHT_PORTRAIT, - BESTSHOT_THEATRE, - BESTSHOT_BEACH, - BESTSHOT_SNOW, - BESTSHOT_SUNSET, - BESTSHOT_ANTISHAKE, - BESTSHOT_FIREWORKS, - BESTSHOT_SPORTS, - BESTSHOT_PARTY, - BESTSHOT_CANDLELIGHT, - BESTSHOT_ASD, - BESTSHOT_BACKLIGHT, - BESTSHOT_FLOWERS, - BESTSHOT_AR, - BESTSHOT_HDR, - BESTSHOT_MAX -}Bestshot_modes; - -typedef enum { - FLASH_MODE_OFF, - FLASH_MODE_AUTO, - FLASH_MODE_ON, - FLASH_MODE_TORCH, - FLASH_MODE_MAX, -}Flash_modes; - -typedef enum { - WB_AUTO, - WB_INCANDESCENT, - WB_FLUORESCENT, - WB_WARM_FLUORESCENT, - WB_DAYLIGHT, - WB_CLOUDY_DAYLIGHT, - WB_TWILIGHT, - WB_SHADE, - WB_MAX -} White_Balance_modes; - -typedef enum -{ - MENU_ID_MAIN, - MENU_ID_WHITEBALANCECHANGE, - MENU_ID_EXPMETERINGCHANGE, - MENU_ID_GET_CTRL_VALUE, - MENU_ID_TOGGLEAFR, - MENU_ID_ISOCHANGE, - MENU_ID_BRIGHTNESSCHANGE, - MENU_ID_CONTRASTCHANGE, - MENU_ID_EVCHANGE, - MENU_ID_SATURATIONCHANGE, - MENU_ID_ZOOMCHANGE, - MENU_ID_SHARPNESSCHANGE, - MENU_ID_BESTSHOT, - MENU_ID_FLASHMODE, - MENU_ID_SENSORS, - MENU_ID_SWITCH_RES, - MENU_ID_INVALID, -} menu_id_change_t; - -typedef enum -{ - DECREASE_ZOOM, - INCREASE_ZOOM, - INCREASE_STEP_ZOOM, - DECREASE_STEP_ZOOM, -} Camera_Zoom; - -typedef enum -{ - INC_CONTRAST, - DEC_CONTRAST, -} Camera_Contrast_changes; - -typedef enum -{ - INC_BRIGHTNESS, - DEC_BRIGHTNESS, -} Camera_Brightness_changes; - -typedef enum -{ - INCREASE_EV, - DECREASE_EV, -} Camera_EV_changes; - -typedef enum { - INC_SATURATION, - DEC_SATURATION, -} Camera_Saturation_changes; - -typedef enum -{ - INC_ISO, - DEC_ISO, -} Camera_ISO_changes; - -typedef enum -{ - INC_SHARPNESS, - DEC_SHARPNESS, -} Camera_Sharpness_changes; - -typedef enum { - ZOOM_IN, - ZOOM_OUT, -} Zoom_direction; - -typedef struct{ - Camera_main_menu_t main_menu; - char * menu_name; -} CAMERA_MAIN_MENU_TBL_T; - -typedef struct{ - char * menu_name; - int present; -} CAMERA_SENSOR_MENU_TLB_T; - -typedef struct{ - Camera_Resolution cs_id; - uint16_t width; - uint16_t height; - char * name; - char * str_name; -} PREVIEW_DIMENSION_TBL_T; - -typedef struct { - White_Balance_modes wb_id; - char * wb_name; -} WHITE_BALANCE_TBL_T; - -typedef struct { - Get_Ctrl_modes get_ctrl_id; - char * get_ctrl_name; -} GET_CTRL_TBL_T; - -typedef struct{ - Exp_Metering_modes exp_metering_id; - char * exp_metering_name; -} EXP_METERING_TBL_T; - -typedef struct { - Bestshot_modes bs_id; - char *name; -} BESTSHOT_MODE_TBT_T; - -typedef struct { - Flash_modes bs_id; - char *name; -} FLASH_MODE_TBL_T; - -typedef struct { - ISO_modes iso_modes; - char *iso_modes_name; -} ISO_TBL_T; - -typedef struct { - Zoom_direction zoom_direction; - char * zoom_direction_name; -} ZOOM_TBL_T; - -typedef struct { - Camera_Sharpness_changes sharpness_change; - char *sharpness_change_name; -} SHARPNESS_TBL_T; - -typedef struct { - Camera_Brightness_changes bc_id; - char * brightness_name; -} CAMERA_BRIGHTNESS_TBL_T; - -typedef struct { - Camera_Contrast_changes cc_id; - char * contrast_name; -} CAMERA_CONTRST_TBL_T; - -typedef struct { - Camera_EV_changes ec_id; - char * EV_name; -} CAMERA_EV_TBL_T; - -typedef struct { - Camera_Saturation_changes sc_id; - char * saturation_name; -} CAMERA_SATURATION_TBL_T; - -typedef struct { - Camera_Sharpness_changes bc_id; - char * sharpness_name; -} CAMERA_SHARPNESS_TBL_T; - -#endif /* __MM_QCAMERA_MAIN_MENU_H__ */ diff --git a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_socket.h b/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_socket.h deleted file mode 100644 index 186c109..0000000 --- a/camera/QCamera2/stack/mm-camera-test/inc/mm_qcamera_socket.h +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright (c) 2013-2014, 2016, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef __MM_QCAMERA_SOCKET_H__ -#define __MM_QCAMERA_SOCKET_H__ - -// System dependencies -#include <arpa/inet.h> - -#undef __FD_SET -#define __FD_SET(fd, fdsetp) \ - (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] |= (1LU<<((fd) & 31))) - -#undef __FD_CLR -#define __FD_CLR(fd, fdsetp) \ - (((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] &= ~(1LU<<((fd) & 31))) - -#undef __FD_ISSET -#define __FD_ISSET(fd, fdsetp) \ - ((((fd_set *)(fdsetp))->fds_bits[(fd) >> 5] & (1LU<<((fd) & 31))) != 0) - -#undef __FD_ZERO -#define __FD_ZERO(fdsetp) \ - (memset (fdsetp, 0, sizeof (*(fd_set *)(fdsetp)))) - -#define TUNESERVER_MAX_RECV 2048 -#define TUNESERVER_MAX(a, b) (((a) > (b)) ? (a) : (b)) - -#define TUNESERVER_GET_LIST 1014 -#define TUNESERVER_GET_PARMS 1015 -#define TUNESERVER_SET_PARMS 1016 -#define TUNESERVER_MISC_CMDS 1021 - -#define TUNE_PREV_GET_INFO 0x0001 -#define TUNE_PREV_CH_CNK_SIZE 0x0002 -#define TUNE_PREV_GET_PREV_FRAME 0x0003 -#define TUNE_PREV_GET_JPG_SNAP 0x0004 -#define TUNE_PREV_GET_RAW_SNAP 0x0005 -#define TUNE_PREV_GET_RAW_PREV 0x0006 - -typedef struct { - char data[128]; -} tuneserver_misc_cmd; - -typedef enum { - TUNESERVER_RECV_COMMAND = 1, - TUNESERVER_RECV_PAYLOAD_SIZE, - TUNESERVER_RECV_PAYLOAD, - TUNESERVER_RECV_RESPONSE, - TUNESERVERER_RECV_INVALID, -} tuneserver_recv_cmd_t; - -typedef struct { - uint16_t current_cmd; - tuneserver_recv_cmd_t next_recv_code; - uint32_t next_recv_len; - void *recv_buf; - uint32_t recv_len; - uint32_t send_len; - void *send_buf; -} tuneserver_protocol_t; - -typedef enum { - TUNE_PREV_RECV_COMMAND = 1, - TUNE_PREV_RECV_NEWCNKSIZE, - TUNE_PREV_RECV_INVALID -} tune_prev_cmd_t; - -typedef struct _eztune_preview_protocol_t { - uint16_t current_cmd; - tune_prev_cmd_t next_recv_code; - uint32_t next_recv_len; - int32_t send_len; - char* send_buf; - uint32_t send_buf_size; - uint32_t new_cnk_size; - uint32_t new_cmd_available; -} prserver_protocol_t; - -typedef union { - struct sockaddr addr; - struct sockaddr_in addr_in; -} mm_qcamera_sock_addr_t; - -int eztune_server_start(void *lib_handle); - -#endif /*__MM_QCAMERA_SOCKET_H__*/ diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_app.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_app.c deleted file mode 100644 index 5735ed6..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_app.c +++ /dev/null @@ -1,2404 +0,0 @@ -/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS"AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -// To remove -#include <cutils/properties.h> - -// System dependencies -#include <dlfcn.h> -#include <errno.h> -#include <fcntl.h> -#include <linux/msm_ion.h> -#define MMAN_H <SYSTEM_HEADER_PREFIX/mman.h> -#include MMAN_H - -// Camera dependencies -#include "mm_qcamera_dbg.h" -#include "mm_qcamera_app.h" - -static pthread_mutex_t app_mutex; -static int thread_status = 0; -static pthread_cond_t app_cond_v; - -#define MM_QCAMERA_APP_NANOSEC_SCALE 1000000000 - -int mm_camera_app_timedwait(uint8_t seconds) -{ - int rc = 0; - pthread_mutex_lock(&app_mutex); - if(FALSE == thread_status) { - struct timespec tw; - memset(&tw, 0, sizeof tw); - tw.tv_sec = 0; - tw.tv_nsec = time(0) + seconds * MM_QCAMERA_APP_NANOSEC_SCALE; - - rc = pthread_cond_timedwait(&app_cond_v, &app_mutex,&tw); - thread_status = FALSE; - } - pthread_mutex_unlock(&app_mutex); - return rc; -} - -int mm_camera_app_wait() -{ - int rc = 0; - pthread_mutex_lock(&app_mutex); - if(FALSE == thread_status){ - pthread_cond_wait(&app_cond_v, &app_mutex); - } - thread_status = FALSE; - pthread_mutex_unlock(&app_mutex); - return rc; -} - -void mm_camera_app_done() -{ - pthread_mutex_lock(&app_mutex); - thread_status = TRUE; - pthread_cond_signal(&app_cond_v); - pthread_mutex_unlock(&app_mutex); -} - -int mm_app_load_hal(mm_camera_app_t *my_cam_app) -{ - memset(&my_cam_app->hal_lib, 0, sizeof(hal_interface_lib_t)); - my_cam_app->hal_lib.ptr = dlopen("libmmcamera_interface.so", RTLD_NOW); - my_cam_app->hal_lib.ptr_jpeg = dlopen("libmmjpeg_interface.so", RTLD_NOW); - if (!my_cam_app->hal_lib.ptr || !my_cam_app->hal_lib.ptr_jpeg) { - LOGE("Error opening HAL library %s\n", dlerror()); - return -MM_CAMERA_E_GENERAL; - } - *(void **)&(my_cam_app->hal_lib.get_num_of_cameras) = - dlsym(my_cam_app->hal_lib.ptr, "get_num_of_cameras"); - *(void **)&(my_cam_app->hal_lib.mm_camera_open) = - dlsym(my_cam_app->hal_lib.ptr, "camera_open"); - *(void **)&(my_cam_app->hal_lib.jpeg_open) = - dlsym(my_cam_app->hal_lib.ptr_jpeg, "jpeg_open"); - - if (my_cam_app->hal_lib.get_num_of_cameras == NULL || - my_cam_app->hal_lib.mm_camera_open == NULL || - my_cam_app->hal_lib.jpeg_open == NULL) { - LOGE("Error loading HAL sym %s\n", dlerror()); - return -MM_CAMERA_E_GENERAL; - } - - my_cam_app->num_cameras = my_cam_app->hal_lib.get_num_of_cameras(); - LOGD("num_cameras = %d\n", my_cam_app->num_cameras); - - return MM_CAMERA_OK; -} - -int mm_app_allocate_ion_memory(mm_camera_app_buf_t *buf, - __unused unsigned int ion_type) -{ - int rc = MM_CAMERA_OK; - struct ion_handle_data handle_data; - struct ion_allocation_data alloc; - struct ion_fd_data ion_info_fd; - int main_ion_fd = -1; - void *data = NULL; - - main_ion_fd = open("/dev/ion", O_RDONLY); - if (main_ion_fd <= 0) { - LOGE("Ion dev open failed %s\n", strerror(errno)); - goto ION_OPEN_FAILED; - } - - memset(&alloc, 0, sizeof(alloc)); - alloc.len = buf->mem_info.size; - /* to make it page size aligned */ - alloc.len = (alloc.len + 4095U) & (~4095U); - alloc.align = 4096; - alloc.flags = ION_FLAG_CACHED; - alloc.heap_id_mask = ION_HEAP(ION_SYSTEM_HEAP_ID); - rc = ioctl(main_ion_fd, ION_IOC_ALLOC, &alloc); - if (rc < 0) { - LOGE("ION allocation failed %s with rc = %d \n",strerror(errno), rc); - goto ION_ALLOC_FAILED; - } - - memset(&ion_info_fd, 0, sizeof(ion_info_fd)); - ion_info_fd.handle = alloc.handle; - rc = ioctl(main_ion_fd, ION_IOC_SHARE, &ion_info_fd); - if (rc < 0) { - LOGE("ION map failed %s\n", strerror(errno)); - goto ION_MAP_FAILED; - } - - data = mmap(NULL, - alloc.len, - PROT_READ | PROT_WRITE, - MAP_SHARED, - ion_info_fd.fd, - 0); - - if (data == MAP_FAILED) { - LOGE("ION_MMAP_FAILED: %s (%d)\n", strerror(errno), errno); - goto ION_MAP_FAILED; - } - buf->mem_info.main_ion_fd = main_ion_fd; - buf->mem_info.fd = ion_info_fd.fd; - buf->mem_info.handle = ion_info_fd.handle; - buf->mem_info.size = alloc.len; - buf->mem_info.data = data; - return MM_CAMERA_OK; - -ION_MAP_FAILED: - memset(&handle_data, 0, sizeof(handle_data)); - handle_data.handle = ion_info_fd.handle; - ioctl(main_ion_fd, ION_IOC_FREE, &handle_data); -ION_ALLOC_FAILED: - close(main_ion_fd); -ION_OPEN_FAILED: - return -MM_CAMERA_E_GENERAL; -} - -int mm_app_deallocate_ion_memory(mm_camera_app_buf_t *buf) -{ - struct ion_handle_data handle_data; - int rc = 0; - - rc = munmap(buf->mem_info.data, buf->mem_info.size); - - if (buf->mem_info.fd >= 0) { - close(buf->mem_info.fd); - buf->mem_info.fd = -1; - } - - if (buf->mem_info.main_ion_fd >= 0) { - memset(&handle_data, 0, sizeof(handle_data)); - handle_data.handle = buf->mem_info.handle; - ioctl(buf->mem_info.main_ion_fd, ION_IOC_FREE, &handle_data); - close(buf->mem_info.main_ion_fd); - buf->mem_info.main_ion_fd = -1; - } - return rc; -} - -/* cmd = ION_IOC_CLEAN_CACHES, ION_IOC_INV_CACHES, ION_IOC_CLEAN_INV_CACHES */ -int mm_app_cache_ops(mm_camera_app_meminfo_t *mem_info, - int cmd) -{ - struct ion_flush_data cache_inv_data; - struct ion_custom_data custom_data; - int ret = MM_CAMERA_OK; - -#ifdef USE_ION - if (NULL == mem_info) { - LOGE("mem_info is NULL, return here"); - return -MM_CAMERA_E_GENERAL; - } - - memset(&cache_inv_data, 0, sizeof(cache_inv_data)); - memset(&custom_data, 0, sizeof(custom_data)); - cache_inv_data.vaddr = mem_info->data; - cache_inv_data.fd = mem_info->fd; - cache_inv_data.handle = mem_info->handle; - cache_inv_data.length = (unsigned int)mem_info->size; - custom_data.cmd = (unsigned int)cmd; - custom_data.arg = (unsigned long)&cache_inv_data; - - LOGD("addr = %p, fd = %d, handle = %lx length = %d, ION Fd = %d", - cache_inv_data.vaddr, cache_inv_data.fd, - (unsigned long)cache_inv_data.handle, cache_inv_data.length, - mem_info->main_ion_fd); - if(mem_info->main_ion_fd >= 0) { - if(ioctl(mem_info->main_ion_fd, ION_IOC_CUSTOM, &custom_data) < 0) { - LOGE("Cache Invalidate failed\n"); - ret = -MM_CAMERA_E_GENERAL; - } - } -#endif - - return ret; -} - -void mm_app_dump_frame(mm_camera_buf_def_t *frame, - char *name, - char *ext, - uint32_t frame_idx) -{ - char file_name[FILENAME_MAX]; - int file_fd; - int i; - int offset = 0; - if ( frame != NULL) { - snprintf(file_name, sizeof(file_name), - QCAMERA_DUMP_FRM_LOCATION"%s_%04d.%s", name, frame_idx, ext); - file_fd = open(file_name, O_RDWR | O_CREAT, 0777); - if (file_fd < 0) { - LOGE("cannot open file %s \n", file_name); - } else { - for (i = 0; i < frame->planes_buf.num_planes; i++) { - LOGD("saving file from address: %p, data offset: %d, " - "length: %d \n", frame->buffer, - frame->planes_buf.planes[i].data_offset, frame->planes_buf.planes[i].length); - write(file_fd, - (uint8_t *)frame->buffer + offset, - frame->planes_buf.planes[i].length); - offset += (int)frame->planes_buf.planes[i].length; - } - - close(file_fd); - LOGD("dump %s", file_name); - } - } -} - -void mm_app_dump_jpeg_frame(const void * data, size_t size, char* name, - char* ext, uint32_t index) -{ - char buf[FILENAME_MAX]; - int file_fd; - if ( data != NULL) { - snprintf(buf, sizeof(buf), - QCAMERA_DUMP_FRM_LOCATION"test/%s_%u.%s", name, index, ext); - LOGD("%s size =%zu, jobId=%u", buf, size, index); - file_fd = open(buf, O_RDWR | O_CREAT, 0777); - write(file_fd, data, size); - close(file_fd); - } -} - -int mm_app_alloc_bufs(mm_camera_app_buf_t* app_bufs, - cam_frame_len_offset_t *frame_offset_info, - uint8_t num_bufs, - uint8_t is_streambuf, - size_t multipleOf) -{ - uint32_t i, j; - unsigned int ion_type = 0x1 << CAMERA_ION_FALLBACK_HEAP_ID; - - if (is_streambuf) { - ion_type |= 0x1 << CAMERA_ION_HEAP_ID; - } - - for (i = 0; i < num_bufs ; i++) { - if ( 0 < multipleOf ) { - size_t m = frame_offset_info->frame_len / multipleOf; - if ( ( frame_offset_info->frame_len % multipleOf ) != 0 ) { - m++; - } - app_bufs[i].mem_info.size = m * multipleOf; - } else { - app_bufs[i].mem_info.size = frame_offset_info->frame_len; - } - mm_app_allocate_ion_memory(&app_bufs[i], ion_type); - - app_bufs[i].buf.buf_idx = i; - app_bufs[i].buf.planes_buf.num_planes = (int8_t)frame_offset_info->num_planes; - app_bufs[i].buf.fd = app_bufs[i].mem_info.fd; - app_bufs[i].buf.frame_len = app_bufs[i].mem_info.size; - app_bufs[i].buf.buffer = app_bufs[i].mem_info.data; - app_bufs[i].buf.mem_info = (void *)&app_bufs[i].mem_info; - - /* Plane 0 needs to be set seperately. Set other planes - * in a loop. */ - app_bufs[i].buf.planes_buf.planes[0].length = frame_offset_info->mp[0].len; - app_bufs[i].buf.planes_buf.planes[0].m.userptr = - (long unsigned int)app_bufs[i].buf.fd; - app_bufs[i].buf.planes_buf.planes[0].data_offset = frame_offset_info->mp[0].offset; - app_bufs[i].buf.planes_buf.planes[0].reserved[0] = 0; - for (j = 1; j < (uint8_t)frame_offset_info->num_planes; j++) { - app_bufs[i].buf.planes_buf.planes[j].length = frame_offset_info->mp[j].len; - app_bufs[i].buf.planes_buf.planes[j].m.userptr = - (long unsigned int)app_bufs[i].buf.fd; - app_bufs[i].buf.planes_buf.planes[j].data_offset = frame_offset_info->mp[j].offset; - app_bufs[i].buf.planes_buf.planes[j].reserved[0] = - app_bufs[i].buf.planes_buf.planes[j-1].reserved[0] + - app_bufs[i].buf.planes_buf.planes[j-1].length; - } - } - LOGD("X"); - return MM_CAMERA_OK; -} - -int mm_app_release_bufs(uint8_t num_bufs, - mm_camera_app_buf_t* app_bufs) -{ - int i, rc = MM_CAMERA_OK; - - LOGD("E"); - - for (i = 0; i < num_bufs; i++) { - rc = mm_app_deallocate_ion_memory(&app_bufs[i]); - } - memset(app_bufs, 0, num_bufs * sizeof(mm_camera_app_buf_t)); - LOGD("X"); - return rc; -} - -int mm_app_stream_initbuf(cam_frame_len_offset_t *frame_offset_info, - uint8_t *num_bufs, - uint8_t **initial_reg_flag, - mm_camera_buf_def_t **bufs, - mm_camera_map_unmap_ops_tbl_t *ops_tbl, - void *user_data) -{ - mm_camera_stream_t *stream = (mm_camera_stream_t *)user_data; - mm_camera_buf_def_t *pBufs = NULL; - uint8_t *reg_flags = NULL; - int i, rc; - - stream->offset = *frame_offset_info; - - LOGD("alloc buf for stream_id %d, len=%d, num planes: %d, offset: %d", - stream->s_id, - frame_offset_info->frame_len, - frame_offset_info->num_planes, - frame_offset_info->mp[1].offset); - - if (stream->num_of_bufs > CAM_MAX_NUM_BUFS_PER_STREAM) - stream->num_of_bufs = CAM_MAX_NUM_BUFS_PER_STREAM; - - pBufs = (mm_camera_buf_def_t *)malloc(sizeof(mm_camera_buf_def_t) * stream->num_of_bufs); - reg_flags = (uint8_t *)malloc(sizeof(uint8_t) * stream->num_of_bufs); - if (pBufs == NULL || reg_flags == NULL) { - LOGE("No mem for bufs"); - if (pBufs != NULL) { - free(pBufs); - } - if (reg_flags != NULL) { - free(reg_flags); - } - return -1; - } - - rc = mm_app_alloc_bufs(&stream->s_bufs[0], - frame_offset_info, - stream->num_of_bufs, - 1, - stream->multipleOf); - - if (rc != MM_CAMERA_OK) { - LOGE("mm_stream_alloc_bufs err = %d", rc); - free(pBufs); - free(reg_flags); - return rc; - } - - for (i = 0; i < stream->num_of_bufs; i++) { - /* mapping stream bufs first */ - pBufs[i] = stream->s_bufs[i].buf; - reg_flags[i] = 1; - rc = ops_tbl->map_ops(pBufs[i].buf_idx, - -1, - pBufs[i].fd, - (uint32_t)pBufs[i].frame_len, - CAM_MAPPING_BUF_TYPE_STREAM_BUF, ops_tbl->userdata); - if (rc != MM_CAMERA_OK) { - LOGE("mapping buf[%d] err = %d", i, rc); - break; - } - } - - if (rc != MM_CAMERA_OK) { - int j; - for (j=0; j>i; j++) { - ops_tbl->unmap_ops(pBufs[j].buf_idx, -1, - CAM_MAPPING_BUF_TYPE_STREAM_BUF, ops_tbl->userdata); - } - mm_app_release_bufs(stream->num_of_bufs, &stream->s_bufs[0]); - free(pBufs); - free(reg_flags); - return rc; - } - - *num_bufs = stream->num_of_bufs; - *bufs = pBufs; - *initial_reg_flag = reg_flags; - - LOGD("X"); - return rc; -} - -int32_t mm_app_stream_deinitbuf(mm_camera_map_unmap_ops_tbl_t *ops_tbl, - void *user_data) -{ - mm_camera_stream_t *stream = (mm_camera_stream_t *)user_data; - int i; - - for (i = 0; i < stream->num_of_bufs ; i++) { - /* mapping stream bufs first */ - ops_tbl->unmap_ops(stream->s_bufs[i].buf.buf_idx, -1, - CAM_MAPPING_BUF_TYPE_STREAM_BUF, ops_tbl->userdata); - } - - mm_app_release_bufs(stream->num_of_bufs, &stream->s_bufs[0]); - - LOGD("X"); - return 0; -} - -int32_t mm_app_stream_clean_invalidate_buf(uint32_t index, void *user_data) -{ - mm_camera_stream_t *stream = (mm_camera_stream_t *)user_data; - return mm_app_cache_ops(&stream->s_bufs[index].mem_info, - ION_IOC_CLEAN_INV_CACHES); -} - -int32_t mm_app_stream_invalidate_buf(uint32_t index, void *user_data) -{ - mm_camera_stream_t *stream = (mm_camera_stream_t *)user_data; - return mm_app_cache_ops(&stream->s_bufs[index].mem_info, ION_IOC_INV_CACHES); -} - -static void notify_evt_cb(uint32_t camera_handle, - mm_camera_event_t *evt, - void *user_data) -{ - mm_camera_test_obj_t *test_obj = - (mm_camera_test_obj_t *)user_data; - if (test_obj == NULL || test_obj->cam->camera_handle != camera_handle) { - LOGE("Not a valid test obj"); - return; - } - - LOGD("E evt = %d", evt->server_event_type); - switch (evt->server_event_type) { - case CAM_EVENT_TYPE_AUTO_FOCUS_DONE: - LOGD("rcvd auto focus done evt"); - break; - case CAM_EVENT_TYPE_ZOOM_DONE: - LOGD("rcvd zoom done evt"); - break; - default: - break; - } - - LOGD("X"); -} - -int mm_app_open(mm_camera_app_t *cam_app, - int cam_id, - mm_camera_test_obj_t *test_obj) -{ - int32_t rc = 0; - cam_frame_len_offset_t offset_info; - - LOGD("BEGIN\n"); - - rc = cam_app->hal_lib.mm_camera_open((uint8_t)cam_id, &(test_obj->cam)); - if(rc || !test_obj->cam) { - LOGE("dev open error. rc = %d, vtbl = %p\n", rc, test_obj->cam); - return -MM_CAMERA_E_GENERAL; - } - - LOGD("Open Camera id = %d handle = %d", cam_id, test_obj->cam->camera_handle); - - /* alloc ion mem for capability buf */ - memset(&offset_info, 0, sizeof(offset_info)); - offset_info.frame_len = sizeof(cam_capability_t); - - rc = mm_app_alloc_bufs(&test_obj->cap_buf, - &offset_info, - 1, - 0, - 0); - if (rc != MM_CAMERA_OK) { - LOGE("alloc buf for capability error\n"); - goto error_after_cam_open; - } - - /* mapping capability buf */ - rc = test_obj->cam->ops->map_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_CAPABILITY, - test_obj->cap_buf.mem_info.fd, - test_obj->cap_buf.mem_info.size); - if (rc != MM_CAMERA_OK) { - LOGE("map for capability error\n"); - goto error_after_cap_buf_alloc; - } - - /* alloc ion mem for getparm buf */ - memset(&offset_info, 0, sizeof(offset_info)); - offset_info.frame_len = sizeof(parm_buffer_t); - rc = mm_app_alloc_bufs(&test_obj->parm_buf, - &offset_info, - 1, - 0, - 0); - if (rc != MM_CAMERA_OK) { - LOGE("alloc buf for getparm_buf error\n"); - goto error_after_cap_buf_map; - } - - /* mapping getparm buf */ - rc = test_obj->cam->ops->map_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_PARM_BUF, - test_obj->parm_buf.mem_info.fd, - test_obj->parm_buf.mem_info.size); - if (rc != MM_CAMERA_OK) { - LOGE("map getparm_buf error\n"); - goto error_after_getparm_buf_alloc; - } - test_obj->params_buffer = (parm_buffer_t*) test_obj->parm_buf.mem_info.data; - LOGH("\n%s params_buffer=%p\n",test_obj->params_buffer); - - rc = test_obj->cam->ops->register_event_notify(test_obj->cam->camera_handle, - notify_evt_cb, - test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("failed register_event_notify"); - rc = -MM_CAMERA_E_GENERAL; - goto error_after_getparm_buf_map; - } - - rc = test_obj->cam->ops->query_capability(test_obj->cam->camera_handle); - if (rc != MM_CAMERA_OK) { - LOGE("failed query_capability"); - rc = -MM_CAMERA_E_GENERAL; - goto error_after_getparm_buf_map; - } - memset(&test_obj->jpeg_ops, 0, sizeof(mm_jpeg_ops_t)); - mm_dimension pic_size; - memset(&pic_size, 0, sizeof(mm_dimension)); - pic_size.w = 4000; - pic_size.h = 3000; - test_obj->jpeg_hdl = cam_app->hal_lib.jpeg_open(&test_obj->jpeg_ops, NULL, pic_size, NULL); - if (test_obj->jpeg_hdl == 0) { - LOGE("jpeg lib open err"); - rc = -MM_CAMERA_E_GENERAL; - goto error_after_getparm_buf_map; - } - - return rc; - -error_after_getparm_buf_map: - test_obj->cam->ops->unmap_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_PARM_BUF); -error_after_getparm_buf_alloc: - mm_app_release_bufs(1, &test_obj->parm_buf); -error_after_cap_buf_map: - test_obj->cam->ops->unmap_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_CAPABILITY); -error_after_cap_buf_alloc: - mm_app_release_bufs(1, &test_obj->cap_buf); -error_after_cam_open: - test_obj->cam->ops->close_camera(test_obj->cam->camera_handle); - test_obj->cam = NULL; - return rc; -} - -int init_batch_update(parm_buffer_t *p_table) -{ - int rc = MM_CAMERA_OK; - LOGH("\nEnter %s\n"); - int32_t hal_version = CAM_HAL_V1; - - memset(p_table, 0, sizeof(parm_buffer_t)); - if(ADD_SET_PARAM_ENTRY_TO_BATCH(p_table, CAM_INTF_PARM_HAL_VERSION, hal_version)) { - rc = -1; - } - - return rc; -} - -int commit_set_batch(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - int i = 0; - - for(i = 0; i < CAM_INTF_PARM_MAX; i++){ - if(test_obj->params_buffer->is_valid[i]) - break; - } - if (i < CAM_INTF_PARM_MAX) { - LOGH("\n set_param p_buffer =%p\n",test_obj->params_buffer); - rc = test_obj->cam->ops->set_parms(test_obj->cam->camera_handle, test_obj->params_buffer); - } - if (rc != MM_CAMERA_OK) { - LOGE("cam->ops->set_parms failed !!"); - } - return rc; -} - -int mm_app_close(mm_camera_test_obj_t *test_obj) -{ - int32_t rc = MM_CAMERA_OK; - - if (test_obj == NULL || test_obj->cam ==NULL) { - LOGE("cam not opened"); - return -MM_CAMERA_E_GENERAL; - } - - /* unmap capability buf */ - rc = test_obj->cam->ops->unmap_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_CAPABILITY); - if (rc != MM_CAMERA_OK) { - LOGE("unmap capability buf failed, rc=%d", rc); - } - - /* unmap parm buf */ - rc = test_obj->cam->ops->unmap_buf(test_obj->cam->camera_handle, - CAM_MAPPING_BUF_TYPE_PARM_BUF); - if (rc != MM_CAMERA_OK) { - LOGE("unmap setparm buf failed, rc=%d", rc); - } - - rc = test_obj->cam->ops->close_camera(test_obj->cam->camera_handle); - if (rc != MM_CAMERA_OK) { - LOGE("close camera failed, rc=%d", rc); - } - test_obj->cam = NULL; - - /* close jpeg client */ - if (test_obj->jpeg_hdl && test_obj->jpeg_ops.close) { - rc = test_obj->jpeg_ops.close(test_obj->jpeg_hdl); - test_obj->jpeg_hdl = 0; - if (rc != MM_CAMERA_OK) { - LOGE("close jpeg failed, rc=%d", rc); - } - } - - /* dealloc capability buf */ - rc = mm_app_release_bufs(1, &test_obj->cap_buf); - if (rc != MM_CAMERA_OK) { - LOGE("release capability buf failed, rc=%d", rc); - } - - /* dealloc parm buf */ - rc = mm_app_release_bufs(1, &test_obj->parm_buf); - if (rc != MM_CAMERA_OK) { - LOGE("release setparm buf failed, rc=%d", rc); - } - - return MM_CAMERA_OK; -} - -mm_camera_channel_t * mm_app_add_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_type_t ch_type, - mm_camera_channel_attr_t *attr, - mm_camera_buf_notify_t channel_cb, - void *userdata) -{ - uint32_t ch_id = 0; - mm_camera_channel_t *channel = NULL; - - ch_id = test_obj->cam->ops->add_channel(test_obj->cam->camera_handle, - attr, - channel_cb, - userdata); - if (ch_id == 0) { - LOGE("add channel failed"); - return NULL; - } - channel = &test_obj->channels[ch_type]; - channel->ch_id = ch_id; - return channel; -} - -int mm_app_del_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - test_obj->cam->ops->delete_channel(test_obj->cam->camera_handle, - channel->ch_id); - memset(channel, 0, sizeof(mm_camera_channel_t)); - return MM_CAMERA_OK; -} - -mm_camera_stream_t * mm_app_add_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - mm_camera_stream_t *stream = NULL; - int rc = MM_CAMERA_OK; - cam_frame_len_offset_t offset_info; - - stream = &(channel->streams[channel->num_streams++]); - stream->s_id = test_obj->cam->ops->add_stream(test_obj->cam->camera_handle, - channel->ch_id); - if (stream->s_id == 0) { - LOGE("add stream failed"); - return NULL; - } - - stream->multipleOf = test_obj->slice_size; - - /* alloc ion mem for stream_info buf */ - memset(&offset_info, 0, sizeof(offset_info)); - offset_info.frame_len = sizeof(cam_stream_info_t); - - rc = mm_app_alloc_bufs(&stream->s_info_buf, - &offset_info, - 1, - 0, - 0); - if (rc != MM_CAMERA_OK) { - LOGE("alloc buf for stream_info error\n"); - test_obj->cam->ops->delete_stream(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id); - stream->s_id = 0; - return NULL; - } - - /* mapping streaminfo buf */ - rc = test_obj->cam->ops->map_stream_buf(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id, - CAM_MAPPING_BUF_TYPE_STREAM_INFO, - 0, - -1, - stream->s_info_buf.mem_info.fd, - (uint32_t)stream->s_info_buf.mem_info.size); - if (rc != MM_CAMERA_OK) { - LOGE("map setparm_buf error\n"); - mm_app_deallocate_ion_memory(&stream->s_info_buf); - test_obj->cam->ops->delete_stream(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id); - stream->s_id = 0; - return NULL; - } - - return stream; -} - -int mm_app_del_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_stream_t *stream) -{ - test_obj->cam->ops->unmap_stream_buf(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id, - CAM_MAPPING_BUF_TYPE_STREAM_INFO, - 0, - -1); - mm_app_deallocate_ion_memory(&stream->s_info_buf); - test_obj->cam->ops->delete_stream(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id); - memset(stream, 0, sizeof(mm_camera_stream_t)); - return MM_CAMERA_OK; -} - -mm_camera_channel_t *mm_app_get_channel_by_type(mm_camera_test_obj_t *test_obj, - mm_camera_channel_type_t ch_type) -{ - return &test_obj->channels[ch_type]; -} - -int mm_app_config_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_stream_t *stream, - mm_camera_stream_config_t *config) -{ - return test_obj->cam->ops->config_stream(test_obj->cam->camera_handle, - channel->ch_id, - stream->s_id, - config); -} - -int mm_app_start_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - return test_obj->cam->ops->start_channel(test_obj->cam->camera_handle, - channel->ch_id); -} - -int mm_app_stop_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - return test_obj->cam->ops->stop_channel(test_obj->cam->camera_handle, - channel->ch_id); -} - -int initBatchUpdate(mm_camera_test_obj_t *test_obj) -{ - int32_t hal_version = CAM_HAL_V1; - - parm_buffer_t *parm_buf = ( parm_buffer_t * ) test_obj->parm_buf.mem_info.data; - memset(parm_buf, 0, sizeof(parm_buffer_t)); - ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_HAL_VERSION, hal_version); - - return MM_CAMERA_OK; -} - -int commitSetBatch(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - int i = 0; - - parm_buffer_t *p_table = ( parm_buffer_t * ) test_obj->parm_buf.mem_info.data; - for(i = 0; i < CAM_INTF_PARM_MAX; i++){ - if(p_table->is_valid[i]) - break; - } - if (i < CAM_INTF_PARM_MAX) { - rc = test_obj->cam->ops->set_parms(test_obj->cam->camera_handle, p_table); - } - return rc; -} - - -int commitGetBatch(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - int i = 0; - parm_buffer_t *p_table = ( parm_buffer_t * ) test_obj->parm_buf.mem_info.data; - for(i = 0; i < CAM_INTF_PARM_MAX; i++){ - if(p_table->is_valid[i]) - break; - } - if (i < CAM_INTF_PARM_MAX) { - rc = test_obj->cam->ops->get_parms(test_obj->cam->camera_handle, p_table); - } - return rc; -} - -int setAecLock(mm_camera_test_obj_t *test_obj, int value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_AEC_LOCK, (uint32_t)value)) { - LOGE("AEC Lock parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - -ERROR: - return rc; -} - -int setAwbLock(mm_camera_test_obj_t *test_obj, int value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_AWB_LOCK, (uint32_t)value)) { - LOGE("AWB Lock parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - -ERROR: - return rc; -} - - -int set3Acommand(mm_camera_test_obj_t *test_obj, cam_eztune_cmd_data_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_EZTUNE_CMD, *value)) { - LOGE("CAM_INTF_PARM_EZTUNE_CMD parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - -ERROR: - return rc; -} - -int setAutoFocusTuning(mm_camera_test_obj_t *test_obj, tune_actuator_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_SET_AUTOFOCUSTUNING, *value)) { - LOGE("AutoFocus Tuning not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - -ERROR: - return rc; -} - -int setVfeCommand(mm_camera_test_obj_t *test_obj, tune_cmd_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_SET_VFE_COMMAND, *value)) { - LOGE("VFE Command not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - -ERROR: - return rc; -} - -int setmetainfoCommand(mm_camera_test_obj_t *test_obj, cam_stream_size_info_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_META_STREAM_INFO, *value)) { - LOGE("PP Command not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - -ERROR: - return rc; -} - - -int setPPCommand(mm_camera_test_obj_t *test_obj, tune_cmd_t *value) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_SET_PP_COMMAND, *value)) { - LOGE("PP Command not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - -ERROR: - return rc; -} - -int setFocusMode(mm_camera_test_obj_t *test_obj, cam_focus_mode_type mode) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - uint32_t value = mode; - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_FOCUS_MODE, value)) { - LOGE("Focus mode parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - -ERROR: - return rc; -} - -int setEVCompensation(mm_camera_test_obj_t *test_obj, int ev) -{ - int rc = MM_CAMERA_OK; - - cam_capability_t *camera_cap = NULL; - - camera_cap = (cam_capability_t *) test_obj->cap_buf.mem_info.data; - if ( (ev >= camera_cap->exposure_compensation_min) && - (ev <= camera_cap->exposure_compensation_max) ) { - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_EXPOSURE_COMPENSATION, ev)) { - LOGE("EV compensation parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("EV compensation set to: %d", ev); - } else { - LOGE("Invalid EV compensation"); - return -EINVAL; - } - -ERROR: - return rc; -} - -int setAntibanding(mm_camera_test_obj_t *test_obj, cam_antibanding_mode_type antibanding) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_ANTIBANDING, antibanding)) { - LOGE("Antibanding parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("Antibanding set to: %d", (int)antibanding); - -ERROR: - return rc; -} - -int setWhiteBalance(mm_camera_test_obj_t *test_obj, cam_wb_mode_type mode) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_WHITE_BALANCE, mode)) { - LOGE("White balance parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("White balance set to: %d", (int)mode); - -ERROR: - return rc; -} - -int setExposureMetering(mm_camera_test_obj_t *test_obj, cam_auto_exposure_mode_type mode) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_EXPOSURE, mode)) { - LOGE("Exposure metering parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("Exposure metering set to: %d", (int)mode); - -ERROR: - return rc; -} - -int setBrightness(mm_camera_test_obj_t *test_obj, int brightness) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_BRIGHTNESS, brightness)) { - LOGE("Brightness parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("Brightness set to: %d", brightness); - -ERROR: - return rc; -} - -int setContrast(mm_camera_test_obj_t *test_obj, int contrast) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_CONTRAST, contrast)) { - LOGE("Contrast parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("Contrast set to: %d", contrast); - -ERROR: - return rc; -} - -int setTintless(mm_camera_test_obj_t *test_obj, int tintless) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_TINTLESS, tintless)) { - LOGE("Tintless parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("set Tintless to: %d", tintless); - -ERROR: - return rc; -} - -int setSaturation(mm_camera_test_obj_t *test_obj, int saturation) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_SATURATION, saturation)) { - LOGE("Saturation parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("Saturation set to: %d", saturation); - -ERROR: - return rc; -} - -int setSharpness(mm_camera_test_obj_t *test_obj, int sharpness) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_SHARPNESS, sharpness)) { - LOGE("Sharpness parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - test_obj->reproc_sharpness = sharpness; - LOGE("Sharpness set to: %d", sharpness); - -ERROR: - return rc; -} - -int setISO(mm_camera_test_obj_t *test_obj, cam_iso_mode_type iso) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - cam_intf_parm_manual_3a_t iso_settings; - memset(&iso_settings, 0, sizeof(cam_intf_parm_manual_3a_t)); - iso_settings.previewOnly = FALSE; - iso_settings.value = (uint64_t)iso; - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_ISO, iso_settings)) { - LOGE("ISO parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("ISO set to: %d", (int)iso); - -ERROR: - return rc; -} - -int setZoom(mm_camera_test_obj_t *test_obj, int zoom) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_ZOOM, zoom)) { - LOGE("Zoom parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("Zoom set to: %d", zoom); - -ERROR: - return rc; -} - -int setFPSRange(mm_camera_test_obj_t *test_obj, cam_fps_range_t range) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_FPS_RANGE, range)) { - LOGE("FPS range parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("FPS Range set to: [%5.2f:%5.2f]", - range.min_fps, - range.max_fps); - -ERROR: - return rc; -} - -int setScene(mm_camera_test_obj_t *test_obj, cam_scene_mode_type scene) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_BESTSHOT_MODE, scene)) { - LOGE("Scene parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("Scene set to: %d", (int)scene); - -ERROR: - return rc; -} - -int setFlash(mm_camera_test_obj_t *test_obj, cam_flash_mode_t flash) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_LED_MODE, flash)) { - LOGE("Flash parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - LOGE("Flash set to: %d", (int)flash); - -ERROR: - return rc; -} - -int setWNR(mm_camera_test_obj_t *test_obj, uint8_t enable) -{ - int rc = MM_CAMERA_OK; - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - cam_denoise_param_t param; - memset(¶m, 0, sizeof(cam_denoise_param_t)); - param.denoise_enable = enable; - param.process_plates = CAM_WAVELET_DENOISE_YCBCR_PLANE; - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_WAVELET_DENOISE, param)) { - LOGE("WNR enabled parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - - - test_obj->reproc_wnr = param; - LOGE("WNR enabled: %d", enable); - -ERROR: - return rc; -} - - -/** tuneserver_capture - * @lib_handle: the camera handle object - * @dim: snapshot dimensions - * - * makes JPEG capture - * - * Return: >=0 on success, -1 on failure. - **/ -int tuneserver_capture(mm_camera_lib_handle *lib_handle, - mm_camera_lib_snapshot_params *dim) -{ - int rc = 0; - - printf("Take jpeg snapshot\n"); - if ( lib_handle->stream_running ) { - - if ( lib_handle->test_obj.zsl_enabled) { - if ( NULL != dim) { - if ( ( lib_handle->test_obj.buffer_width != dim->width) || - ( lib_handle->test_obj.buffer_height = dim->height ) ) { - - lib_handle->test_obj.buffer_width = dim->width; - lib_handle->test_obj.buffer_height = dim->height; - - rc = mm_camera_lib_stop_stream(lib_handle); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_stop_stream() err=%d\n", - rc); - goto EXIT; - } - - rc = mm_camera_lib_start_stream(lib_handle); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_start_stream() err=%d\n", - rc); - goto EXIT; - } - } - - } - - lib_handle->test_obj.encodeJpeg = 1; - - mm_camera_app_wait(); - } else { - // For standard 2D capture streaming has to be disabled first - rc = mm_camera_lib_stop_stream(lib_handle); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_stop_stream() err=%d\n", - rc); - goto EXIT; - } - - if ( NULL != dim ) { - lib_handle->test_obj.buffer_width = dim->width; - lib_handle->test_obj.buffer_height = dim->height; - } - rc = mm_app_start_capture(&lib_handle->test_obj, 1); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_start_capture() err=%d\n", - rc); - goto EXIT; - } - - mm_camera_app_wait(); - - rc = mm_app_stop_capture(&lib_handle->test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_stop_capture() err=%d\n", - rc); - goto EXIT; - } - - // Restart streaming after capture is done - rc = mm_camera_lib_start_stream(lib_handle); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_start_stream() err=%d\n", - rc); - goto EXIT; - } - } - } - -EXIT: - - return rc; -} - -int mm_app_start_regression_test(int run_tc) -{ - int rc = MM_CAMERA_OK; - mm_camera_app_t my_cam_app; - - LOGD("\nCamera Test Application\n"); - memset(&my_cam_app, 0, sizeof(mm_camera_app_t)); - - rc = mm_app_load_hal(&my_cam_app); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_load_hal failed !!"); - return rc; - } - - if(run_tc) { - rc = mm_app_unit_test_entry(&my_cam_app); - return rc; - } -#if 0 - if(run_dual_tc) { - printf("\tRunning Dual camera test engine only\n"); - rc = mm_app_dual_test_entry(&my_cam_app); - printf("\t Dual camera engine. EXIT(%d)!!!\n", rc); - exit(rc); - } -#endif - return rc; -} - -int32_t mm_camera_load_tuninglibrary(mm_camera_tuning_lib_params_t *tuning_param) -{ - void *(*tuning_open_lib)(void) = NULL; - - LOGD("E"); - tuning_param->lib_handle = dlopen("libmmcamera_tuning.so", RTLD_NOW); - if (!tuning_param->lib_handle) { - LOGE("Failed opening libmmcamera_tuning.so\n"); - return -EINVAL; - } - - *(void **)&tuning_open_lib = dlsym(tuning_param->lib_handle, - "open_tuning_lib"); - if (!tuning_open_lib) { - LOGE("Failed symbol libmmcamera_tuning.so\n"); - return -EINVAL; - } - - if (tuning_param->func_tbl) { - LOGE("already loaded tuninglib.."); - return 0; - } - - tuning_param->func_tbl = (mm_camera_tune_func_t *)tuning_open_lib(); - if (!tuning_param->func_tbl) { - LOGE("Failed opening library func table ptr\n"); - return -EINVAL; - } - - LOGD("X"); - return 0; -} - -int mm_camera_lib_open(mm_camera_lib_handle *handle, int cam_id) -{ - int rc = MM_CAMERA_OK; - - if ( NULL == handle ) { - LOGE(" Invalid handle"); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - memset(handle, 0, sizeof(mm_camera_lib_handle)); - rc = mm_app_load_hal(&handle->app_ctx); - if( MM_CAMERA_OK != rc ) { - LOGE("mm_app_init err\n"); - goto EXIT; - } - - handle->test_obj.buffer_width = DEFAULT_PREVIEW_WIDTH; - handle->test_obj.buffer_height = DEFAULT_PREVIEW_HEIGHT; - handle->test_obj.buffer_format = DEFAULT_SNAPSHOT_FORMAT; - handle->current_params.stream_width = DEFAULT_SNAPSHOT_WIDTH; - handle->current_params.stream_height = DEFAULT_SNAPSHOT_HEIGHT; - handle->current_params.af_mode = CAM_FOCUS_MODE_AUTO; // Default to auto focus mode - rc = mm_app_open(&handle->app_ctx, (uint8_t)cam_id, &handle->test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - cam_id, rc); - goto EXIT; - } - - //rc = mm_app_initialize_fb(&handle->test_obj); - rc = MM_CAMERA_OK; - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_initialize_fb() cam_idx=%d, err=%d\n", - cam_id, rc); - goto EXIT; - } - -EXIT: - - return rc; -} - -int mm_camera_lib_start_stream(mm_camera_lib_handle *handle) -{ - int rc = MM_CAMERA_OK; - cam_capability_t camera_cap; - - if ( NULL == handle ) { - LOGE(" Invalid handle"); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - if ( handle->test_obj.zsl_enabled ) { - rc = mm_app_start_preview_zsl(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_start_preview_zsl() err=%d\n", - rc); - goto EXIT; - } - } else { - handle->test_obj.enable_reproc = ENABLE_REPROCESSING; - rc = mm_app_start_preview(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_start_preview() err=%d\n", - rc); - goto EXIT; - } - } - - // Configure focus mode after stream starts - rc = mm_camera_lib_get_caps(handle, &camera_cap); - if ( MM_CAMERA_OK != rc ) { - LOGE("mm_camera_lib_get_caps() err=%d\n", rc); - return -1; - } - if (camera_cap.supported_focus_modes_cnt == 1 && - camera_cap.supported_focus_modes[0] == CAM_FOCUS_MODE_FIXED) { - LOGD("focus not supported"); - handle->test_obj.focus_supported = 0; - handle->current_params.af_mode = CAM_FOCUS_MODE_FIXED; - } else { - handle->test_obj.focus_supported = 1; - } - rc = setFocusMode(&handle->test_obj, handle->current_params.af_mode); - if (rc != MM_CAMERA_OK) { - LOGE("autofocus error\n"); - goto EXIT; - } - handle->stream_running = 1; - -EXIT: - return rc; -} - -int mm_camera_lib_stop_stream(mm_camera_lib_handle *handle) -{ - int rc = MM_CAMERA_OK; - - if ( NULL == handle ) { - LOGE(" Invalid handle"); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - if ( handle->test_obj.zsl_enabled ) { - rc = mm_app_stop_preview_zsl(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_stop_preview_zsl() err=%d\n", - rc); - goto EXIT; - } - } else { - rc = mm_app_stop_preview(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_stop_preview() err=%d\n", - rc); - goto EXIT; - } - } - - handle->stream_running = 0; - -EXIT: - return rc; -} - -int mm_camera_lib_get_caps(mm_camera_lib_handle *handle, - cam_capability_t *caps) -{ - int rc = MM_CAMERA_OK; - - if ( NULL == handle ) { - LOGE(" Invalid handle"); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - if ( NULL == caps ) { - LOGE(" Invalid capabilities structure"); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - *caps = *( (cam_capability_t *) handle->test_obj.cap_buf.mem_info.data ); - -EXIT: - - return rc; -} - - -int mm_camera_lib_send_command(mm_camera_lib_handle *handle, - mm_camera_lib_commands cmd, - void *in_data, - __unused void *out_data) -{ - uint32_t width, height; - int rc = MM_CAMERA_OK; - cam_capability_t *camera_cap = NULL; - mm_camera_lib_snapshot_params *dim = NULL; - - if ( NULL == handle ) { - LOGE(" Invalid handle"); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - camera_cap = (cam_capability_t *) handle->test_obj.cap_buf.mem_info.data; - - switch(cmd) { - case MM_CAMERA_LIB_FPS_RANGE: - if ( NULL != in_data ) { - cam_fps_range_t range = *(( cam_fps_range_t * )in_data); - rc = setFPSRange(&handle->test_obj, range); - if (rc != MM_CAMERA_OK) { - LOGE("setFPSRange() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_FLASH: - if ( NULL != in_data ) { - cam_flash_mode_t flash = *(( int * )in_data); - rc = setFlash(&handle->test_obj, flash); - if (rc != MM_CAMERA_OK) { - LOGE("setFlash() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_BESTSHOT: - if ( NULL != in_data ) { - cam_scene_mode_type scene = *(( int * )in_data); - rc = setScene(&handle->test_obj, scene); - if (rc != MM_CAMERA_OK) { - LOGE("setScene() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_ZOOM: - if ( NULL != in_data ) { - int zoom = *(( int * )in_data); - rc = setZoom(&handle->test_obj, zoom); - if (rc != MM_CAMERA_OK) { - LOGE("setZoom() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_ISO: - if ( NULL != in_data ) { - cam_iso_mode_type iso = *(( int * )in_data); - rc = setISO(&handle->test_obj, iso); - if (rc != MM_CAMERA_OK) { - LOGE("setISO() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_SHARPNESS: - if ( NULL != in_data ) { - int sharpness = *(( int * )in_data); - rc = setSharpness(&handle->test_obj, sharpness); - if (rc != MM_CAMERA_OK) { - LOGE("setSharpness() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_SATURATION: - if ( NULL != in_data ) { - int saturation = *(( int * )in_data); - rc = setSaturation(&handle->test_obj, saturation); - if (rc != MM_CAMERA_OK) { - LOGE("setSaturation() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_CONTRAST: - if ( NULL != in_data ) { - int contrast = *(( int * )in_data); - rc = setContrast(&handle->test_obj, contrast); - if (rc != MM_CAMERA_OK) { - LOGE("setContrast() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_SET_TINTLESS: - if ( NULL != in_data ) { - int tintless = *(( int * )in_data); - rc = setTintless(&handle->test_obj, tintless); - if (rc != MM_CAMERA_OK) { - LOGE("enlabe/disable:%d tintless() err=%d\n", - tintless, rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_BRIGHTNESS: - if ( NULL != in_data ) { - int brightness = *(( int * )in_data); - rc = setBrightness(&handle->test_obj, brightness); - if (rc != MM_CAMERA_OK) { - LOGE("setBrightness() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_EXPOSURE_METERING: - if ( NULL != in_data ) { - cam_auto_exposure_mode_type exp = *(( int * )in_data); - rc = setExposureMetering(&handle->test_obj, exp); - if (rc != MM_CAMERA_OK) { - LOGE("setExposureMetering() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_WB: - if ( NULL != in_data ) { - cam_wb_mode_type wb = *(( int * )in_data); - rc = setWhiteBalance(&handle->test_obj, wb); - if (rc != MM_CAMERA_OK) { - LOGE("setWhiteBalance() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_ANTIBANDING: - if ( NULL != in_data ) { - int antibanding = *(( int * )in_data); - rc = setAntibanding(&handle->test_obj, antibanding); - if (rc != MM_CAMERA_OK) { - LOGE("setAntibanding() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_EV: - if ( NULL != in_data ) { - int ev = *(( int * )in_data); - rc = setEVCompensation(&handle->test_obj, ev); - if (rc != MM_CAMERA_OK) { - LOGE("setEVCompensation() err=%d\n", - rc); - goto EXIT; - } - } - break; - case MM_CAMERA_LIB_ZSL_ENABLE: - if ( NULL != in_data) { - int enable_zsl = *(( int * )in_data); - if ( ( enable_zsl != handle->test_obj.zsl_enabled ) && - handle->stream_running ) { - rc = mm_camera_lib_stop_stream(handle); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_stop_stream() err=%d\n", - rc); - goto EXIT; - } - handle->test_obj.zsl_enabled = enable_zsl; - rc = mm_camera_lib_start_stream(handle); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_start_stream() err=%d\n", - rc); - goto EXIT; - } - } else { - handle->test_obj.zsl_enabled = enable_zsl; - } - } - break; - case MM_CAMERA_LIB_RAW_CAPTURE: - - if ( 0 == handle->stream_running ) { - LOGE(" Streaming is not enabled!"); - rc = MM_CAMERA_E_INVALID_OPERATION; - goto EXIT; - } - - rc = mm_camera_lib_stop_stream(handle); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_stop_stream() err=%d\n", - rc); - goto EXIT; - } - - width = handle->test_obj.buffer_width; - height = handle->test_obj.buffer_height; - handle->test_obj.buffer_width = - (uint32_t)camera_cap->raw_dim[0].width; - handle->test_obj.buffer_height = - (uint32_t)camera_cap->raw_dim[0].height; - handle->test_obj.buffer_format = DEFAULT_RAW_FORMAT; - LOGE("MM_CAMERA_LIB_RAW_CAPTURE %dx%d\n", - camera_cap->raw_dim[0].width, - camera_cap->raw_dim[0].height); - rc = mm_app_start_capture_raw(&handle->test_obj, 1); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_start_capture() err=%d\n", - rc); - goto EXIT; - } - - mm_camera_app_wait(); - - rc = mm_app_stop_capture_raw(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_stop_capture() err=%d\n", - rc); - goto EXIT; - } - - handle->test_obj.buffer_width = width; - handle->test_obj.buffer_height = height; - handle->test_obj.buffer_format = DEFAULT_SNAPSHOT_FORMAT; - rc = mm_camera_lib_start_stream(handle); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_start_stream() err=%d\n", - rc); - goto EXIT; - } - - break; - - case MM_CAMERA_LIB_JPEG_CAPTURE: - if ( 0 == handle->stream_running ) { - LOGE(" Streaming is not enabled!"); - rc = MM_CAMERA_E_INVALID_OPERATION; - goto EXIT; - } - - if ( NULL != in_data ) { - dim = ( mm_camera_lib_snapshot_params * ) in_data; - } - - rc = tuneserver_capture(handle, dim); - if (rc != MM_CAMERA_OK) { - LOGE("capture error %d\n", rc); - goto EXIT; - } - break; - - case MM_CAMERA_LIB_SET_FOCUS_MODE: { - cam_focus_mode_type mode = *((cam_focus_mode_type *)in_data); - handle->current_params.af_mode = mode; - rc = setFocusMode(&handle->test_obj, mode); - if (rc != MM_CAMERA_OK) { - LOGE("autofocus error\n"); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_DO_AF: - if (handle->test_obj.focus_supported) { - rc = handle->test_obj.cam->ops->do_auto_focus(handle->test_obj.cam->camera_handle); - if (rc != MM_CAMERA_OK) { - LOGE("autofocus error\n"); - goto EXIT; - } - /*Waiting for Auto Focus Done Call Back*/ - mm_camera_app_wait(); - } - break; - - case MM_CAMERA_LIB_CANCEL_AF: - rc = handle->test_obj.cam->ops->cancel_auto_focus(handle->test_obj.cam->camera_handle); - if (rc != MM_CAMERA_OK) { - LOGE("autofocus error\n"); - goto EXIT; - } - - break; - - case MM_CAMERA_LIB_LOCK_AWB: - rc = setAwbLock(&handle->test_obj, 1); - if (rc != MM_CAMERA_OK) { - LOGE("AWB locking failed\n"); - goto EXIT; - } - break; - - case MM_CAMERA_LIB_UNLOCK_AWB: - rc = setAwbLock(&handle->test_obj, 0); - if (rc != MM_CAMERA_OK) { - LOGE("AE unlocking failed\n"); - goto EXIT; - } - break; - - case MM_CAMERA_LIB_LOCK_AE: - rc = setAecLock(&handle->test_obj, 1); - if (rc != MM_CAMERA_OK) { - LOGE("AE locking failed\n"); - goto EXIT; - } - break; - - case MM_CAMERA_LIB_UNLOCK_AE: - rc = setAecLock(&handle->test_obj, 0); - if (rc != MM_CAMERA_OK) { - LOGE("AE unlocking failed\n"); - goto EXIT; - } - break; - - case MM_CAMERA_LIB_SET_3A_COMMAND: { - rc = set3Acommand(&handle->test_obj, (cam_eztune_cmd_data_t *)in_data); - if (rc != MM_CAMERA_OK) { - LOGE("3A set command error\n"); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_SET_AUTOFOCUS_TUNING: { - rc = setAutoFocusTuning(&handle->test_obj, in_data); - if (rc != MM_CAMERA_OK) { - LOGE("Set AF tuning failed\n"); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_SET_VFE_COMMAND: { - rc = setVfeCommand(&handle->test_obj, in_data); - if (rc != MM_CAMERA_OK) { - LOGE("Set vfe command failed\n"); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_SET_POSTPROC_COMMAND: { - rc = setPPCommand(&handle->test_obj, in_data); - if (rc != MM_CAMERA_OK) { - LOGE("Set pp command failed\n"); - goto EXIT; - } - break; - } - - case MM_CAMERA_LIB_WNR_ENABLE: { - rc = setWNR(&handle->test_obj, *((uint8_t *)in_data)); - if ( rc != MM_CAMERA_OK) { - LOGE("Set wnr enable failed\n"); - goto EXIT; - } - } - - case MM_CAMERA_LIB_NO_ACTION: - default: - break; - }; - -EXIT: - - return rc; -} -int mm_camera_lib_number_of_cameras(mm_camera_lib_handle *handle) -{ - int rc = 0; - - if ( NULL == handle ) { - LOGE(" Invalid handle"); - goto EXIT; - } - - rc = handle->app_ctx.num_cameras; - -EXIT: - - return rc; -} - -int mm_camera_lib_close(mm_camera_lib_handle *handle) -{ - int rc = MM_CAMERA_OK; - - if ( NULL == handle ) { - LOGE(" Invalid handle"); - rc = MM_CAMERA_E_INVALID_INPUT; - goto EXIT; - } - - //rc = mm_app_close_fb(&handle->test_obj); - rc = MM_CAMERA_OK; - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_close_fb() err=%d\n", - rc); - goto EXIT; - } - - rc = mm_app_close(&handle->test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", - rc); - goto EXIT; - } - -EXIT: - return rc; -} - -int mm_camera_lib_set_preview_usercb( - mm_camera_lib_handle *handle, cam_stream_user_cb cb) -{ - if (handle->test_obj.user_preview_cb != NULL) { - LOGE(" already set preview callbacks\n"); - return -1; - } - handle->test_obj.user_preview_cb = *cb; - return 0; -} - -int mm_app_set_preview_fps_range(mm_camera_test_obj_t *test_obj, - cam_fps_range_t *fpsRange) -{ - int rc = MM_CAMERA_OK; - LOGH("preview fps range: min=%f, max=%f.", - fpsRange->min_fps, fpsRange->max_fps); - rc = setFPSRange(test_obj, *fpsRange); - - if (rc != MM_CAMERA_OK) { - LOGE("add_parm_entry_tobatch failed !!"); - return rc; - } - - return rc; -} - -int mm_app_set_face_detection(mm_camera_test_obj_t *test_obj, - cam_fd_set_parm_t *fd_set_parm) -{ - int rc = MM_CAMERA_OK; - - if (test_obj == NULL || fd_set_parm == NULL) { - LOGE(" invalid params!"); - return MM_CAMERA_E_INVALID_INPUT; - } - - LOGH("mode = %d, num_fd = %d", - fd_set_parm->fd_mode, fd_set_parm->num_fd); - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_FD, *fd_set_parm)) { - LOGE("FD parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - -ERROR: - return rc; -} - -int mm_app_set_flash_mode(mm_camera_test_obj_t *test_obj, - cam_flash_mode_t flashMode) -{ - int rc = MM_CAMERA_OK; - - if (test_obj == NULL) { - LOGE(" invalid params!"); - return MM_CAMERA_E_INVALID_INPUT; - } - - LOGH("mode = %d", (int)flashMode); - - rc = initBatchUpdate(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch camera parameter update failed\n"); - goto ERROR; - } - - if (ADD_SET_PARAM_ENTRY_TO_BATCH(test_obj->parm_buf.mem_info.data, - CAM_INTF_PARM_LED_MODE, flashMode)) { - LOGE("Flash mode parameter not added to batch\n"); - rc = -1; - goto ERROR; - } - - rc = commitSetBatch(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("Batch parameters commit failed\n"); - goto ERROR; - } - -ERROR: - return rc; -} - -int mm_app_set_metadata_usercb(mm_camera_test_obj_t *test_obj, - cam_stream_user_cb usercb) -{ - if (test_obj == NULL || usercb == NULL) { - LOGE(" invalid params!"); - return MM_CAMERA_E_INVALID_INPUT; - } - - LOGH("%s, set user metadata callback, addr: %p\n", usercb); - - if (test_obj->user_metadata_cb != NULL) { - LOGH("%s, already set user metadata callback"); - } - test_obj->user_metadata_cb = usercb; - - return 0; -} - - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_commands.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_commands.c deleted file mode 100644 index 45fb7a8..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_commands.c +++ /dev/null @@ -1,291 +0,0 @@ -/* Copyright (c) 2012-2013, 2016, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -// To remove -#include <cutils/properties.h> - -// Camera dependencies -#include "mm_qcamera_commands.h" -#include "mm_qcamera_dbg.h" - -int tuneserver_initialize_prevtuningp(void * ctrl, - int pr_client_socket_id, cam_dimension_t dimension, - char **send_buf, uint32_t *send_len) -{ - int result = 0; - mm_camera_lib_handle *lib_handle = (mm_camera_lib_handle *) ctrl; - tuningserver_t *tctrl = &lib_handle->tsctrl; - - LOGD("E"); - if (tctrl->tuning_params.func_tbl->prevcommand_process == NULL) { - LOGE("prevcommand_process is NULL"); - return -1; - } - - result = tctrl->tuning_params.func_tbl->prevcommand_process( - NULL, TUNE_PREVCMD_INIT, (void *)&pr_client_socket_id, - send_buf, send_len); - result = tctrl->tuning_params.func_tbl->prevcommand_process( - NULL, TUNE_PREVCMD_SETDIM, (void *)&dimension, - send_buf, send_len); - - mm_camera_lib_set_preview_usercb(lib_handle, - (tctrl->tuning_params.func_tbl->prevframe_callback)); - - return result; -} - -int tuneserver_deinitialize_prevtuningp(void * ctrl, - char **send_buf, uint32_t *send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - LOGD("E"); - - result = tctrl->tuning_params.func_tbl->prevcommand_process( - &tctrl->pr_proto, TUNE_PREVCMD_DEINIT, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_preview_getinfo(void * ctrl, char **send_buf, uint32_t *send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - LOGD("E"); - result = tctrl->tuning_params.func_tbl->prevcommand_process( - &tctrl->pr_proto, TUNE_PREVCMD_GETINFO, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_preview_getchunksize(void * ctrl, - char **send_buf, uint32_t *send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - LOGD("E"); - result = tctrl->tuning_params.func_tbl->prevcommand_process( - &tctrl->pr_proto, TUNE_PREVCMD_GETCHUNKSIZE, - (void *)&tctrl->pr_proto->new_cnk_size, send_buf, send_len); - - return result; -} - -int tuneserver_preview_getframe(void * ctrl, - char **send_buf, uint32_t *send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - LOGD("E"); - result = tctrl->tuning_params.func_tbl->prevcommand_process( - &tctrl->pr_proto, TUNE_PREVCMD_GETFRAME, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_preview_unsupported(void * ctrl, - char **send_buf, uint32_t *send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - LOGD("E"); - result = tctrl->tuning_params.func_tbl->prevcommand_process( - &tctrl->pr_proto, TUNE_PREVCMD_UNSUPPORTED, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_initialize_tuningp(void * ctrl, int client_socket_id, - char *send_buf, uint32_t send_len) -{ - int result = 0; - mm_camera_lib_handle *lib_handle = (mm_camera_lib_handle *) ctrl; - tuningserver_t *tctrl = &lib_handle->tsctrl; - - LOGD("E"); - result = tctrl->tuning_params.func_tbl->command_process( - lib_handle, TUNE_CMD_INIT, &client_socket_id, send_buf, send_len); - - return result; -} - -int tuneserver_deinitialize_tuningp(void * ctrl, int client_socket_id, - char *send_buf, uint32_t send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - LOGD("E"); - - result = tctrl->tuning_params.func_tbl->command_process( - NULL, TUNE_CMD_DEINIT, &client_socket_id, send_buf, send_len); - - return result; -} - -int tuneserver_process_get_list_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - LOGD("E"); - result = tctrl->tuning_params.func_tbl->command_process( - recv_cmd, TUNE_CMD_GET_LIST, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_process_get_params_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - LOGD("E"); - result = tctrl->tuning_params.func_tbl->command_process - (recv_cmd, TUNE_CMD_GET_PARAMS, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_process_set_params_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - LOGD("E"); - result = tctrl->tuning_params.func_tbl->command_process( - recv_cmd, TUNE_CMD_SET_PARAMS, NULL, send_buf, send_len); - - return result; -} - -int tuneserver_process_misc_cmd(void * ctrl, void *recv_cmd, - char *send_buf, uint32_t send_len) -{ - int result = 0; - tuningserver_t *tctrl = (tuningserver_t *) ctrl; - - LOGD("E"); - result = tctrl->tuning_params.func_tbl->command_process( - recv_cmd, TUNE_CMD_MISC, NULL, send_buf, send_len); - - return result; -} - -/** tuneserver_close_cam - * @lib_handle: the camera handle object - * - * closes the camera - * - * Return: >=0 on success, -1 on failure. - **/ -int tuneserver_close_cam(mm_camera_lib_handle *lib_handle) -{ - int result = 0; - - result = mm_camera_lib_close(lib_handle); - if (result < 0) { - printf(" Camera close failed\n"); - } else { - printf("Camera is closed \n"); - } - return result; -} -#if 0 -/** tuneserver_start_cam - * @lib_handle: the camera handle object - * - * starts the camera - * - * Return: >=0 on success, -1 on failure. - **/ -static int tuneserver_start_cam(mm_camera_lib_handle *lib_handle) -{ - int result = 0; - - result = mm_camera_lib_start_stream(lib_handle); - if (result < 0) { - printf(" Camera start failed\n"); - goto error1; - } - return result; -error1: - mm_camera_lib_close(lib_handle); - return result; -} -#endif - -/** tuneserver_stop_cam - * @lib_handle: the camera handle object - * - * stops the camera - * - * Return: >=0 on success, -1 on failure. - **/ -int tuneserver_stop_cam(mm_camera_lib_handle *lib_handle) -{ - int result = 0; - - result = mm_camera_lib_stop_stream(lib_handle); - if (result < 0) { - printf(" Camera stop failed\n"); - } -// result = mm_camera_lib_close(lib_handle); - return result; -} - -/** tuneserver_open_cam - * @lib_handle: the camera handle object - * - * opens the camera - * - * Return: >=0 on success, -1 on failure. - **/ -#if 1 -int tuneserver_open_cam(mm_camera_lib_handle *lib_handle) -{ - int result = 0; - - LOGD("E"); - result = mm_camera_load_tuninglibrary(&lib_handle->tsctrl.tuning_params); - if (result < 0) { - LOGE(" tuning library open failed\n"); - } - return result; -} -#endif diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_dual_test.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_dual_test.c deleted file mode 100644 index 564c474..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_dual_test.c +++ /dev/null @@ -1,1933 +0,0 @@ -/* -Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -// System dependencies -#include <pthread.h> - -// Camera dependencies -#include "mm_qcamera_unit_test.h" -#include "mm_camera_dbg.h" - -#define MM_QCAMERA_APP_UTEST_MAX_MAIN_LOOP 4 -#define MM_QCAM_APP_TEST_NUM 128 - -#define MM_QCAMERA_APP_WAIT_TIME 1000000000 - -extern int system_dimension_set(int cam_id); -extern int stopPreview(int cam_id); -extern int takePicture_yuv(int cam_id); -extern int takePicture_rdi(int cam_id); -extern int startRdi(int cam_id); -extern int stopRdi(int cam_id); -extern int startStats(int cam_id); -extern int stopStats(int cam_id); - - -/* -* 1. open back -* 2. open front -* 3. start back -* 4. start front -* 5. stop back -* 6. stop front -* 7. close back -* 8. close front -* 9. take picture -* a. start recording -* b. stop recording -* c. take picture rdi -*/ -static mm_app_tc_t mm_app_tc[MM_QCAM_APP_TEST_NUM]; -static int num_test_cases = 0; -struct test_case_params { - uint16_t launch; - uint16_t preview; - uint16_t recording; - uint16_t snapshot; -}; - -/* Test case 12436857 :*/ - -int mm_app_dtc_0(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 0...\n"); - LOGE("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - LOGE("DUAL start camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - LOGE("DUAL stop camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - usleep(10*1000); - - LOGE("DUAL close front camera\n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - sleep(1); - LOGE("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - LOGD(" startPreview() err=%d\n", rc); - goto end; - } - usleep(10*1000); - LOGE("DUAL close back camera \n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case 12436587 :*/ - -int mm_app_dtc_1(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 1...\n"); - LOGE("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - LOGE("DUAL start camera Preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - LOGE("DUAL end \n"); - - LOGE("DUAL stop camera Preview for front \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - usleep(10*1000); - LOGE("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - LOGD(" startPreview() err=%d\n", rc); - goto end; - } - usleep(10*1000); - LOGE("DUAL close front camera\n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - LOGE("DUAL close back camera \n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case 12436578 :*/ - -int mm_app_dtc_2(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 2...\n"); - LOGE("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - LOGE("DUAL start camera Preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - LOGE("DUAL end \n"); - - LOGE("DUAL stop camera Preview for front \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - usleep(10*1000); - LOGE("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - LOGD(" startPreview() err=%d\n", rc); - goto end; - } - usleep(10*1000); - LOGE("DUAL close back camera \n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - LOGE("DUAL close front camera\n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case 241395768 : 1357 * 3, This is performed three times -* And for each iteration 9 is performed thrice */ - -int mm_app_dtc_3(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j,k; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview and snapshot on back Camera and RDI on Front camera 3...\n"); - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Preview for front \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" startPreview() frontcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - usleep(10*1000); - - for (k = 0; k < MM_QCAMERA_APP_INTERATION ; k++) { - LOGE("DUAL open back camera %d \n",k); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - - for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - LOGE("DUAL take picture for back \n"); - if ( MM_CAMERA_OK != (rc = takePicture_yuv(back_camera))) { - LOGE(" TakePicture() err=%d\n", rc); - break; - } - mm_camera_app_wait(); - - } - usleep(10*1000); - LOGE("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - LOGE(" stopPreview() backcamera err=%d\n", rc); - goto end; - } - usleep(10*1000); - - LOGE("DUAL close back camera\n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - usleep(20*1000); - } - LOGE("DUAL stop camera Preview for Rdi \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - LOGD(" stopRdi() err=%d\n", rc); - goto end; - } - usleep(10*1000); - LOGE("DUAL close front camera \n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case 2413ab5768 : 1357 * 3, This is performed three times -* And for each iteration ab is performed thrice */ - -int mm_app_dtc_4(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j,k; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 4...\n"); - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Preview for front \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" startPreview() frontcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - usleep(20*1000); - - for (k = 0; k < MM_QCAMERA_APP_INTERATION ; k++){ - LOGE("DUAL open back camera %d \n",k); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - usleep(30*1000); - - for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - LOGE("DUAL start camera record for back \n"); - if ( MM_CAMERA_OK != (rc = startRecording(back_camera))) { - LOGE(" StartVideorecording() err=%d\n", rc); - break; - } - - mm_camera_app_wait(); - usleep(15*1000); - LOGE("DUAL stop camera record for back \n"); - if ( MM_CAMERA_OK != (rc = stopRecording(back_camera))) { - LOGE(" Stopvideorecording() err=%d\n", rc); - break; - } - } - usleep(10*1000); - - LOGE("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - LOGE(" stopPreview() backcamera err=%d\n", rc); - goto end; - } - usleep(10*1000); - - LOGE("DUAL close back camera\n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - usleep(20*1000); - } - LOGE("DUAL stop camera Preview for Rdi \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - LOGD(" stopRdi() err=%d\n", rc); - goto end; - } - usleep(10*1000); - LOGE("DUAL close front camera \n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case 24135768 : 1357 * 3, This is performed three times*/ - -int mm_app_dtc_5(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j,k; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 5...\n"); - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Preview for front \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" startPreview() frontcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - for (k = 0; k < 4 ; k++) { - LOGE("DUAL open back camera %d \n",k); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - LOGE("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - LOGE(" stopPreview() backcamera err=%d\n", rc); - goto end; - } - usleep(10*1000); - - LOGE("DUAL close back camera\n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - sleep(1); - } - LOGE("DUAL stop camera Preview for Rdi \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - LOGD(" stopRdi() err=%d\n", rc); - goto end; - } - usleep(10*1000); - LOGE("DUAL close front camera \n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case 13246857 : 2468 * 3, This is performed three times*/ - -int mm_app_dtc_6(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j,k; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera 6...\n"); - LOGE("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - for (k = 0; k < 4 ; k++) { - LOGE("DUAL open front camera %d \n",k); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - LOGE("DUAL stop camera Preview for front \n"); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - usleep(10*1000); - - LOGE("DUAL close front camera\n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - sleep(1); - } - LOGE("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - LOGD(" startPreview() err=%d\n", rc); - goto end; - } - usleep(10*1000); - LOGE("DUAL close back camera \n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/*Multi Threaded Test Cases*/ -static void *front_thread(void *data) -{ - int front_camera = 1; - int rc = MM_CAMERA_OK; - int i,j,k,m; - struct test_case_params params - = *((struct test_case_params *)data); - for (i = 0; i < params.launch; i++) { - LOGE("DUAL open front camera %d\n",i); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - for (j = 0; j < params.preview; j++) { - LOGE("DUAL start camera Rdi for front %d ,%d \n",i,j); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - usleep(20*1000); - for (k = 0; k < params.snapshot; k++) { - LOGE("DUAL take picture for front %d,%d,%d \n",i,j,k); - if ( MM_CAMERA_OK != (rc = takePicture_rdi(front_camera))) { - LOGE(" TakePicture() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - usleep(30*1000); - } - LOGE("DUAL stop camera Rdi for front %d,%d\n",i,j); - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - usleep(10*1000); - } - - LOGE("DUAL close front camera %d\n",i); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - } -end: - LOGE("DUAL front thread close %d",rc); - return NULL; -} - -static void *back_thread(void *data) -{ - int rc = MM_CAMERA_OK; - int back_camera = 0; - int i,j,k,m; - struct test_case_params params - = *((struct test_case_params *)data); - for (i = 0; i < params.launch; i++) { - LOGE("DUAL open back camera %d\n",i); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - for (j = 0; j < params.preview; j++) { - LOGE("DUAL start camera Preview for back %d, %d\n",i,j); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - usleep(20*1000); - for (k = 0; k < params.snapshot; k++) { - LOGE("DUAL take picture for back %d, %d, %d\n",i,j,k); - if ( MM_CAMERA_OK != (rc = takePicture_yuv(back_camera))) { - LOGE(" TakePicture() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - usleep(30*1000); - } - - for (m = 0; m < params.recording; m++) { - LOGE("DUAL start record for back %d, %d, %d\n",i,j,m); - if ( MM_CAMERA_OK != (rc = startRecording(back_camera))) { - LOGE(" StartVideorecording() err=%d\n", rc); - break; - } - - mm_camera_app_wait(); - usleep(10*1000); - LOGE("DUAL stop camera record for back \n"); - if ( MM_CAMERA_OK != (rc = stopRecording(back_camera))) { - LOGE(" Stopvideorecording() err=%d\n", rc); - break; - } - usleep(10*1000); - } - LOGE("DUAL stop camera Preview for back %d, %d\n",i,j); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - LOGD(" startPreview() err=%d\n", rc); - goto end; - } - usleep(10*1000); - } - - LOGE("DUAL close back camera %d\n",i); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - } -end: - LOGE("DUAL back thread close %d",rc); - return NULL; -} - -/* Test case m13572468 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_7(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - pthread_t back_thread_id, front_thread_id; - struct test_case_params params; - memset(¶ms, 0, sizeof(struct test_case_params)); - params.launch = 5; - params.preview = 5; - printf("\n Verifying Preview on back Camera and RDI on Front camera 7...\n"); - - LOGE("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, ¶ms); - LOGE("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, ¶ms); - sleep(1); - LOGE("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - LOGE("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case m139572468 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_8(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - - pthread_t back_thread_id, front_thread_id; - struct test_case_params bparams, fparams; - memset(&bparams, 0, sizeof(struct test_case_params)); - memset(&fparams, 0, sizeof(struct test_case_params)); - bparams.launch = 5; - bparams.preview = 5; - bparams.snapshot= 5; - fparams.launch = 5; - fparams.preview = 5; - printf("\n Verifying Preview on back Camera and RDI on Front camera 8...\n"); - - LOGE("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, &bparams); - LOGE("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, &fparams); - sleep(1); - LOGE("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - LOGE("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - LOGE("DUAL end \n"); - -end: - if(rc == 0) - printf("\nPassed\n"); - else - printf("\nFailed\n"); - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case m1395724c68 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_9(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - - pthread_t back_thread_id, front_thread_id; - struct test_case_params bparams, fparams; - memset(&bparams, 0, sizeof(struct test_case_params)); - memset(&fparams, 0, sizeof(struct test_case_params)); - bparams.launch = 5; - bparams.preview = 5; - bparams.snapshot= 5; - fparams.launch = 5; - fparams.preview = 5; - fparams.snapshot = 5; - printf("\n Verifying Preview on back Camera and RDI on Front camera 9...\n"); - - LOGE("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, &bparams); - LOGE("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, &fparams); - sleep(1); - LOGE("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - LOGE("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case m13ab572468 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_10(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - - pthread_t back_thread_id, front_thread_id; - struct test_case_params bparams, fparams; - memset(&bparams, 0, sizeof(struct test_case_params)); - memset(&fparams, 0, sizeof(struct test_case_params)); - bparams.launch = 5; - bparams.preview = 5; - bparams.recording= 5; - fparams.launch = 5; - fparams.preview = 5; - printf("\n Verifying Preview on back Camera and RDI on Front camera 10...\n"); - - LOGE("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, &bparams); - LOGE("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, &fparams); - sleep(1); - LOGE("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - LOGE("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - LOGE("DUAL end \n"); -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case m13ab5724c68 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_11(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - - pthread_t back_thread_id, front_thread_id; - struct test_case_params bparams, fparams; - memset(&bparams, 0, sizeof(struct test_case_params)); - memset(&fparams, 0, sizeof(struct test_case_params)); - bparams.launch = 5; - bparams.preview = 5; - bparams.recording= 5; - fparams.launch = 5; - fparams.preview = 5; - fparams.snapshot = 5; - printf("\n Verifying Preview on back Camera and RDI on Front camera 11...\n"); - - LOGE("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, &bparams); - LOGE("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, &fparams); - sleep(1); - LOGE("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - LOGE("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case m1728 : Open & start in 2 concurrent pthread*/ -int mm_app_dtc_12(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int result = 0; - - pthread_t back_thread_id, front_thread_id; - struct test_case_params bparams, fparams; - memset(&bparams, 0, sizeof(struct test_case_params)); - memset(&fparams, 0, sizeof(struct test_case_params)); - bparams.launch = 15; - fparams.launch = 15; - printf("\n Verifying Preview on back Camera and RDI on Front camera 12...\n"); - - LOGE("start back DUAL "); - rc = pthread_create(&back_thread_id, NULL, back_thread, &bparams); - LOGE("start front DUAL "); - rc = pthread_create(&front_thread_id, NULL, front_thread, &fparams); - sleep(1); - LOGE("stop back DUAL "); - rc = pthread_join(back_thread_id, NULL); - LOGE("stop front DUAL "); - rc = pthread_join(front_thread_id, NULL); - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* Test case 2413(ab)5768 - * Test the dual camera usecase. We startPreview on front camera, - * but backend will allocate RDI buffers and start front camera in - * RDI streaming mode. It then diverts RDI frames, converts them into YUV 420 - * through C2D and generate preview data in the buffers allocated here. - * Back camera will use the pixel interface as usual. - */ - -int mm_app_dtc_13(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j,k; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n 13. Verifying Preview + Recording on back Camera and Preview(through RDI) on Front camera\n"); - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Preview for front \n"); - if( MM_CAMERA_OK != (rc = startPreview(front_camera))) { - LOGE(" front camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - usleep(20*1000); - - for (k = 0; k < MM_QCAMERA_APP_INTERATION ; k++){ - LOGE("DUAL open back camera %d \n",k); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - usleep(30*1000); - - for (j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - LOGE("DUAL start camera record for back Iteration %d \n", j); - if ( MM_CAMERA_OK != (rc = startRecording(back_camera))) { - LOGE(" StartVideorecording() err=%d\n", rc); - break; - } - - mm_camera_app_wait(); - usleep(10*1000*1000); - LOGE("DUAL stop camera record for back Iteration %d\n", j); - if ( MM_CAMERA_OK != (rc = stopRecording(back_camera))) { - LOGE(" Stopvideorecording() err=%d\n", rc); - break; - } - } - usleep(10*1000); - - LOGE("DUAL stop camera Preview for back \n"); - if( MM_CAMERA_OK != (rc = stopPreview(back_camera))) { - LOGE(" stopPreview() backcamera err=%d\n", rc); - goto end; - } - usleep(10*1000); - - LOGE("DUAL close back camera\n"); - if( mm_app_close(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - usleep(20*1000); - } - LOGE("DUAL stop camera Preview for Rdi \n"); - if( MM_CAMERA_OK != (rc = stopPreview(front_camera))) { - LOGE(" stopPreview() frontcamera err=%d\n", rc); - goto end; - } - usleep(10*1000); - LOGE("DUAL close front camera \n"); - if( mm_app_close(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/*Below 6 are reference test cases just to test the open path for dual camera*/ -int mm_app_dtc_1243(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - LOGE("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - LOGE("DUAL start camera Preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_dtc_2134(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera Preview for front \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - LOGE("DUAL start camera Rdi for back \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} -int mm_app_dtc_2143(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - LOGE("DUAL start camera preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_dtc_2413(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera rdi for front \n"); - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - LOGE("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera preview for back \n"); - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_dtc_1234(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - LOGE("DUAL open back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - LOGE("DUAL open front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - LOGE("DUAL start camera preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - - LOGE("DUAL start camera rdi for front \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_dtc_1324(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - LOGE("DUAL start back camera \n"); - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - LOGE("DUAL start camera preview for back \n"); - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - //mm_camera_app_wait(); - sleep(1); - LOGE("DUAL start front camera \n"); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - LOGE("DUAL start rdi preview \n"); - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - sleep(1); - LOGE("DUAL end \n"); - -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/* single camera test cases*/ -int mm_app_dtc_s_0(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - if( MM_CAMERA_OK != (rc = startPreview(back_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - - mm_camera_app_wait(); - if(mm_app_open(front_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() front camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(front_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - if( MM_CAMERA_OK != (rc = startRdi(front_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - mm_camera_app_wait(); - - if( MM_CAMERA_OK != (rc = stopRdi(front_camera))) { - LOGE(" startPreview() backcamera err=%d\n", rc); - goto end; - } - - if( MM_CAMERA_OK != (rc = stopPreview(my_cam_app.cam_open))) { - LOGD(" startPreview() err=%d\n", rc); - goto end; - } - - if( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_dtc_s_1(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - - printf("\n Verifying Snapshot on front and back camera...\n"); - for(i = 0; i < cam_apps->num_cameras; i++) { - if( mm_app_open(i) != MM_CAMERA_OK) { - LOGE("mm_app_open() err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - if( MM_CAMERA_OK != (rc = startPreview(my_cam_app.cam_open))) { - LOGE(" startPreview() err=%d\n", rc); - break; - } - for(j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - if( MM_CAMERA_OK != (rc = takePicture_yuv(my_cam_app.cam_open))) { - LOGE(" TakePicture() err=%d\n", rc); - break; - } - /*if(mm_camera_app_timedwait() == ETIMEDOUT) { - LOGE(" Snapshot/Preview Callback not received in time or qbuf Faile\n"); - break; - }*/ - mm_camera_app_wait(); - result++; - } - if( MM_CAMERA_OK != (rc = stopPreview(my_cam_app.cam_open))) { - LOGD(" startPreview() err=%d\n", rc); - break; - } - if( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - if(result != MM_QCAMERA_APP_INTERATION) { - printf(" Snapshot Start/Stop Fails for Camera %d in %d iteration", i,j); - rc = -1; - break; - } - - result = 0; - } -end: - if(rc == 0) { - printf("\t***Passed***\n"); - }else{ - printf("\t***Failed***\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_dtc_s_2(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - - printf("\n Verifying Video on front and back camera...\n"); - for(i = 0; i < cam_apps->num_cameras; i++) { - if( mm_app_open(i) != MM_CAMERA_OK) { - LOGE("mm_app_open() err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - if( MM_CAMERA_OK != (rc = startPreview(my_cam_app.cam_open))) { - LOGE(" startPreview() err=%d\n", rc); - break; - } - for(j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - if( MM_CAMERA_OK != (rc = startRecording(my_cam_app.cam_open))) { - LOGE(" StartVideorecording() err=%d\n", rc); - break; - } - - /*if(mm_camera_app_timedwait() == ETIMEDOUT) { - LOGE(" Video Callback not received in time\n"); - break; - }*/ - mm_camera_app_wait(); - if( MM_CAMERA_OK != (rc = stopRecording(my_cam_app.cam_open))) { - LOGE(" Stopvideorecording() err=%d\n", rc); - break; - } - result++; - } - if( MM_CAMERA_OK != (rc = stopPreview(my_cam_app.cam_open))) { - LOGD(" startPreview() err=%d\n", rc); - break; - } - if( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - if(result != MM_QCAMERA_APP_INTERATION) { - printf(" Video Start/Stop Fails for Camera %d in %d iteration", i,j); - rc = -1; - break; - } - - result = 0; - } -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_dtc_s_3(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - - printf("\n Verifying RDI Stream on front and back camera...\n"); - if(cam_apps->num_cameras == 0) { - LOGE("Query Failed: Num of cameras = %d\n", cam_apps->num_cameras); - rc = -1; - goto end; - } - for(i = 0; i < cam_apps->num_cameras; i++) { - if( mm_app_open(i) != MM_CAMERA_OK) { - LOGE("mm_app_open() err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(my_cam_app.cam_open) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - for(j = 0; j < MM_QCAMERA_APP_INTERATION; j++) { - if( MM_CAMERA_OK != (rc = startRdi(my_cam_app.cam_open))) { - LOGE(" StartVideorecording() err=%d\n", rc); - break; - } - - /*if(mm_camera_app_timedwait() == ETIMEDOUT) { - LOGE(" Video Callback not received in time\n"); - break; - }*/ - mm_camera_app_wait(); - if( MM_CAMERA_OK != (rc = stopRdi(my_cam_app.cam_open))) { - LOGE(" Stopvideorecording() err=%d\n", rc); - break; - } - result++; - } - if( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } - if(result != MM_QCAMERA_APP_INTERATION) { - printf(" Video Start/Stop Fails for Camera %d in %d iteration", i,j); - rc = -1; - break; - } - - result = 0; - } -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -/*Stats Test Case*/ -int mm_app_dtc_s_5(mm_camera_app_t *cam_apps) -{ - int rc = MM_CAMERA_OK; - int i,j; - int result = 0; - int front_camera = 1; - int back_camera = 0; - - printf("\n Verifying Preview on back Camera and RDI on Front camera...\n"); - - if(mm_app_open(back_camera) != MM_CAMERA_OK) { - LOGE("mm_app_open() back camera err=%d\n", rc); - rc = -1; - goto end; - } - if(system_dimension_set(back_camera) != MM_CAMERA_OK){ - LOGE("system_dimension_set() err=%d\n", rc); - rc = -1; - goto end; - } - - if( MM_CAMERA_OK != (rc = startStats(back_camera))) { - LOGE(" back camera startPreview() err=%d\n", rc); - goto end; - } - - mm_camera_app_wait(); - - if( MM_CAMERA_OK != (rc = stopStats(my_cam_app.cam_open))) { - LOGD(" startPreview() err=%d\n", rc); - goto end; - } - - if( mm_app_close(my_cam_app.cam_open) != MM_CAMERA_OK) { - LOGE("mm_app_close() err=%d\n", rc); - rc = -1; - goto end; - } -end: - if(rc == 0) { - printf("\nPassed\n"); - }else{ - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_gen_dual_test_cases() -{ - int tc = 0; - memset(mm_app_tc, 0, sizeof(mm_app_tc)); - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_0; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_1; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_2; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_3; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_4; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_5; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_6; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_7; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_8; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_9; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_10; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_11; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_12; - if(tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_dtc_13; - - return tc; -} - -int mm_app_dual_test_entry(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, tc = 0; - int cam_id = 0; - - tc = mm_app_gen_dual_test_cases(); - LOGD("Running %d test cases\n",tc); - for(i = 0; i < tc; i++) { - mm_app_tc[i].r = mm_app_tc[i].f(cam_app); - if(mm_app_tc[i].r != MM_CAMERA_OK) { - printf(" test case %d error = %d, abort unit testing engine!!!!\n", - i, mm_app_tc[i].r); - rc = mm_app_tc[i].r; - goto end; - } - } -end: - printf("nTOTAL_TSET_CASE = %d, NUM_TEST_RAN = %d, rc=%d\n", tc, i, rc); - return rc; -} - - - - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_main_menu.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_main_menu.c deleted file mode 100644 index 0865c6f..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_main_menu.c +++ /dev/null @@ -1,2047 +0,0 @@ -/* Copyright (c) 2013-2014, 2016, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -// System dependencies -#include <ctype.h> -#include <errno.h> - -// Camera dependencies -#include "mm_qcamera_main_menu.h" -#include "mm_qcamera_app.h" -#include "mm_qcamera_dbg.h" - -/*=========================================================================== - * Macro - *===========================================================================*/ -#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) -#define VIDEO_BUFFER_SIZE (PREVIEW_WIDTH * PREVIEW_HEIGHT * 3/2) -#define THUMBNAIL_BUFFER_SIZE (THUMBNAIL_WIDTH * THUMBNAIL_HEIGHT * 3/2) -#define SNAPSHOT_BUFFER_SIZE (PICTURE_WIDTH * PICTURE_HEIGHT * 3/2) -//TODO:check this Macros with current app. - -/*=========================================================================== - * Defines - *===========================================================================*/ -//#define VIDEO_FRAMES_NUM 4 -#define THUMBNAIL_FRAMES_NUM 1 -#define SNAPSHOT_FRAMES_NUM 1 -#define MAX_NUM_FORMAT 32 -#define ZOOM_STEP 2 -#define ZOOM_MIN_VALUE 0 -#define EXPOSURE_COMPENSATION_MAXIMUM_NUMERATOR 12 -#define EXPOSURE_COMPENSATION_MINIMUM_NUMERATOR -12 -#define EXPOSURE_COMPENSATION_DEFAULT_NUMERATOR 0 -#define EXPOSURE_COMPENSATION_DENOMINATOR 6 - -//TODO: find correct values of Contrast defines. -#define CAMERA_MIN_CONTRAST 0 -#define CAMERA_DEF_CONTRAST 5 -#define CAMERA_MAX_CONTRAST 10 -#define CAMERA_CONTRAST_STEP 1 - -//TODO: find correct values of Brightness defines. -#define CAMERA_MIN_BRIGHTNESS 0 -#define CAMERA_DEF_BRIGHTNESS 3 -#define CAMERA_MAX_BRIGHTNESS 6 -#define CAMERA_BRIGHTNESS_STEP 1 - -//TODO: find correct values of Saturation defines. -#define CAMERA_MIN_SATURATION 0 -#define CAMERA_DEF_SATURATION 5 -#define CAMERA_MAX_SATURATION 10 -#define CAMERA_SATURATION_STEP 1 - -#define CAMERA_MIN_SHARPNESS 0 -#define CAMERA_MAX_SHARPNESS 10 -#define CAMERA_DEF_SHARPNESS 5 -#define CAMERA_SHARPNESS_STEP 1 - -const CAMERA_MAIN_MENU_TBL_T camera_main_menu_tbl[] = { - {START_PREVIEW, "Start preview"}, - {STOP_PREVIEW, "Stop preview/video"}, - {SET_WHITE_BALANCE, "Set white balance mode"}, - {SET_TINTLESS_ENABLE, "Set Tintless Enable"}, - {SET_TINTLESS_DISABLE, "Set Tintless Disable"}, - {SET_EXP_METERING, "Set exposure metering mode"}, - {GET_CTRL_VALUE, "Get control value menu"}, - {TOGGLE_AFR, "Toggle auto frame rate. Default fixed frame rate"}, - {SET_ISO, "ISO changes."}, - {BRIGHTNESS_GOTO_SUBMENU, "Brightness changes."}, - {CONTRAST_GOTO_SUBMENU, "Contrast changes."}, - {EV_GOTO_SUBMENU, "EV changes."}, - {SATURATION_GOTO_SUBMENU, "Saturation changes."}, - {SET_ZOOM, "Set Digital Zoom."}, - {SET_SHARPNESS, "Set Sharpness."}, - {TAKE_JPEG_SNAPSHOT, "Take a snapshot"}, - {START_RECORDING, "Start RECORDING"}, - {STOP_RECORDING, "Stop RECORDING"}, - {BEST_SHOT, "Set best-shot mode"}, - {LIVE_SHOT, "Take a live snapshot"}, - {FLASH_MODES, "Set Flash modes"}, - {TOGGLE_ZSL, "Toggle ZSL On/Off"}, - {TAKE_RAW_SNAPSHOT, "Take RAW snapshot"}, - {SWITCH_SNAP_RESOLUTION, "Select Jpeg resolution"}, - {TOGGLE_WNR, "Toggle Wavelet Denoise"}, - {EXIT, "Exit"} -}; - -CAMERA_SENSOR_MENU_TLB_T sensor_tbl[] = { - {"Primary Camera", 0}, - {"Secondary Camera", 0}, - {"Camera Sensor 3", 0}, - {"Camera Sensor 4", 0} -}; - -const CAMERA_BRIGHTNESS_TBL_T brightness_change_tbl[] = { - {INC_BRIGHTNESS, "Increase Brightness by one step."}, - {DEC_BRIGHTNESS, "Decrease Brightness by one step."}, -}; - -const CAMERA_CONTRST_TBL_T contrast_change_tbl[] = { - {INC_CONTRAST, "Increase Contrast by one step."}, - {DEC_CONTRAST, "Decrease Contrast by one step."}, -}; - -const CAMERA_EV_TBL_T camera_EV_tbl[] = { - {INCREASE_EV, "Increase EV by one step."}, - {DECREASE_EV, "Decrease EV by one step."}, -}; - -const CAMERA_SATURATION_TBL_T camera_saturation_tbl[] = { - {INC_SATURATION, "Increase Satuation by one step."}, - {DEC_SATURATION, "Decrease Satuation by one step."}, -}; - -const CAMERA_SHARPNESS_TBL_T camera_sharpness_tbl[] = { - {INC_SHARPNESS, "Increase Sharpness."}, - {DEC_SHARPNESS, "Decrease Sharpness."}, -}; - -const WHITE_BALANCE_TBL_T white_balance_tbl[] = { - { WB_AUTO, "White Balance - Auto"}, - { WB_INCANDESCENT, "White Balance - Incandescent"}, - { WB_FLUORESCENT, "White Balance - Fluorescent"}, - { WB_WARM_FLUORESCENT, "White Balance - Warm Fluorescent"}, - { WB_DAYLIGHT, "White Balance - Daylight"}, - { WB_CLOUDY_DAYLIGHT, "White Balance - Cloudy Daylight"}, - { WB_TWILIGHT, "White Balance - Twilight"}, - { WB_SHADE, "White Balance - Shade"}, -}; - -const GET_CTRL_TBL_T get_ctrl_tbl[] = { - { WHITE_BALANCE_STATE, "Get white balance state (auto/off)"}, - { WHITE_BALANCE_TEMPERATURE, "Get white balance temperature"}, - { BRIGHTNESS_CTRL, "Get brightness value"}, - { EV, "Get exposure value"}, - { CONTRAST_CTRL, "Get contrast value"}, - { SATURATION_CTRL, "Get saturation value"}, - { SHARPNESS_CTRL, "Get sharpness value"}, -}; - -const EXP_METERING_TBL_T exp_metering_tbl[] = { - { AUTO_EXP_FRAME_AVG, "Exposure Metering - Frame Average"}, - { AUTO_EXP_CENTER_WEIGHTED, "Exposure Metering - Center Weighted"}, - { AUTO_EXP_SPOT_METERING, "Exposure Metering - Spot Metering"}, - { AUTO_EXP_SMART_METERING, "Exposure Metering - Smart Metering"}, - { AUTO_EXP_USER_METERING, "Exposure Metering - User Metering"}, - { AUTO_EXP_SPOT_METERING_ADV, "Exposure Metering - Spot Metering Adv"}, - { AUTO_EXP_CENTER_WEIGHTED_ADV,"Exposure Metering - Center Weighted Adv"}, -}; - -const ISO_TBL_T iso_tbl[] = { - { ISO_AUTO, "ISO: Auto"}, - { ISO_DEBLUR, "ISO: Deblur"}, - { ISO_100, "ISO: 100"}, - { ISO_200, "ISO: 200"}, - { ISO_400, "ISO: 400"}, - { ISO_800, "ISO: 800"}, - { ISO_1600, "ISO: 1600"}, -}; - -const ZOOM_TBL_T zoom_tbl[] = { - { ZOOM_IN, "Zoom In one step"}, - { ZOOM_OUT, "Zoom Out one step"}, -}; - -const BESTSHOT_MODE_TBT_T bestshot_mode_tbl[] = { - {BESTSHOT_AUTO, "Bestshot Mode: Auto"}, - {BESTSHOT_ACTION, "Bestshot Mode: Action"}, - {BESTSHOT_PORTRAIT, "Bestshot Mode: Portrait"}, - {BESTSHOT_LANDSCAPE, "Bestshot Mode: Landscape"}, - {BESTSHOT_NIGHT, "Bestshot Mode: Night"}, - {BESTSHOT_NIGHT_PORTRAIT, "Bestshot Mode: Night Portrait"}, - {BESTSHOT_THEATRE, "Bestshot Mode: Theatre"}, - {BESTSHOT_BEACH, "Bestshot Mode: Beach"}, - {BESTSHOT_SNOW, "Bestshot Mode: Snow"}, - {BESTSHOT_SUNSET, "Bestshot Mode: Sunset"}, - {BESTSHOT_ANTISHAKE, "Bestshot Mode: Antishake"}, - {BESTSHOT_FIREWORKS, "Bestshot Mode: Fireworks"}, - {BESTSHOT_SPORTS, "Bestshot Mode: Sports"}, - {BESTSHOT_PARTY, "Bestshot Mode: Party"}, - {BESTSHOT_CANDLELIGHT, "Bestshot Mode: Candlelight"}, - {BESTSHOT_ASD, "Bestshot Mode: ASD"}, - {BESTSHOT_BACKLIGHT, "Bestshot Mode: Backlight"}, - {BESTSHOT_FLOWERS, "Bestshot Mode: Flowers"}, - {BESTSHOT_AR, "Bestshot Mode: Augmented Reality"}, - {BESTSHOT_HDR, "Bestshot Mode: HDR"}, -}; - -const FLASH_MODE_TBL_T flashmodes_tbl[] = { - { FLASH_MODE_OFF, "Flash Mode Off"}, - { FLASH_MODE_AUTO, "Flash Mode Auto"}, - { FLASH_MODE_ON, "Flash Mode On"}, - { FLASH_MODE_TORCH, "Flash Mode Torch"}, -}; - -DIMENSION_TBL_T dimension_tbl[] = { -{VGA_WIDTH, VGA_HEIGHT, "VGA", "Size: VGA <640x480>" , 0}, -{MP1_WIDTH, MP1_HEIGHT, "1MP", "Size: 1MP <1280x960>" , 0}, -{MP5_WIDTH, MP5_HEIGHT, "5MP", "Size: 5MP <2592x1944>", 0}, -{MP8_WIDTH, MP8_HEIGHT, "8MP", "Size: 8MP <3264x2448>", 0}, -{MP12_WIDTH, MP12_HEIGHT, "12MP", "Size: 12MP <4000x3000>", 0}, -}; - -/*=========================================================================== - * Forward declarations - *===========================================================================*/ -//static void system_dimension_set(mm_camera_test_obj_t *test_obj); -/*=========================================================================== - * Static global variables - *===========================================================================*/ -USER_INPUT_DISPLAY_T input_display; -int preview_video_resolution_flag = 0; - -//TODO: default values. -#if 1 -int brightness = CAMERA_DEF_BRIGHTNESS; -int contrast = CAMERA_DEF_CONTRAST; -int saturation = CAMERA_DEF_SATURATION; -int sharpness = CAMERA_DEF_SHARPNESS; -#else -int brightness = 0; -int contrast = 0; -int saturation = 0; -int sharpness = 0; -#endif -//TODO: find new method to calculate ev. -//int32_t ev_numerator = EXPOSURE_COMPENSATION_DEFAULT_NUMERATOR; - -//TODO: -//fps_mode_t fps_mode = FPS_MODE_FIXED; -int zoom_level; -int zoom_max_value; -int cam_id; -int is_rec = 0; - - -static int submain(); - -/*=========================================================================== - * FUNCTION - keypress_to_event - - * - * DESCRIPTION: - *==========================================================================*/ -int keypress_to_event(char keypress) -{ - int out_buf = INVALID_KEY_PRESS; - if ((keypress >= 'A' && keypress <= 'Z') || - (keypress >= 'a' && keypress <= 'z')) { - out_buf = tolower(keypress); - out_buf = out_buf - 'a'; - } else if (keypress >= '0' && keypress <= '9') { - out_buf = keypress - '0'; - } - return out_buf; -} - -int next_menu(menu_id_change_t current_menu_id, char keypress, camera_action_t * action_id_ptr, int * action_param) -{ - int output_to_event; - menu_id_change_t next_menu_id = MENU_ID_INVALID; - * action_id_ptr = ACTION_NO_ACTION; - - output_to_event = keypress_to_event(keypress); - LOGD("current_menu_id=%d\n",current_menu_id); - printf("output_to_event=%d\n",output_to_event); - switch(current_menu_id) { - case MENU_ID_MAIN: - switch(output_to_event) { - case START_PREVIEW: - * action_id_ptr = ACTION_START_PREVIEW; - LOGD("START_PREVIEW\n"); - break; - case STOP_PREVIEW: - * action_id_ptr = ACTION_STOP_PREVIEW; - LOGD("STOP_PREVIEW\n"); - break; - - case SET_WHITE_BALANCE: - next_menu_id = MENU_ID_WHITEBALANCECHANGE; - LOGD("next_menu_id = MENU_ID_WHITEBALANCECHANGE = %d\n", next_menu_id); - break; - - case SET_TINTLESS_ENABLE: - * action_id_ptr = ACTION_SET_TINTLESS_ENABLE; - next_menu_id = MENU_ID_MAIN; - LOGD("next_menu_id = MENU_ID_TINTLESSENABLE = %d\n", next_menu_id); - break; - - case SET_TINTLESS_DISABLE: - * action_id_ptr = ACTION_SET_TINTLESS_DISABLE; - next_menu_id = MENU_ID_MAIN; - LOGD("next_menu_id = MENU_ID_TINTLESSDISABLE = %d\n", next_menu_id); - break; - - case SET_EXP_METERING: - next_menu_id = MENU_ID_EXPMETERINGCHANGE; - LOGD("next_menu_id = MENU_ID_EXPMETERINGCHANGE = %d\n", next_menu_id); - break; - - case GET_CTRL_VALUE: - next_menu_id = MENU_ID_GET_CTRL_VALUE; - LOGD("next_menu_id = MENU_ID_GET_CTRL_VALUE = %d\n", next_menu_id); - break; - - case BRIGHTNESS_GOTO_SUBMENU: - next_menu_id = MENU_ID_BRIGHTNESSCHANGE; - LOGD("next_menu_id = MENU_ID_BRIGHTNESSCHANGE = %d\n", next_menu_id); - break; - - case CONTRAST_GOTO_SUBMENU: - next_menu_id = MENU_ID_CONTRASTCHANGE; - break; - - case EV_GOTO_SUBMENU: - next_menu_id = MENU_ID_EVCHANGE; - break; - - case SATURATION_GOTO_SUBMENU: - next_menu_id = MENU_ID_SATURATIONCHANGE; - break; - - case TOGGLE_AFR: - * action_id_ptr = ACTION_TOGGLE_AFR; - LOGD("next_menu_id = MENU_ID_TOGGLEAFR = %d\n", next_menu_id); - break; - - case SET_ISO: - next_menu_id = MENU_ID_ISOCHANGE; - LOGD("next_menu_id = MENU_ID_ISOCHANGE = %d\n", next_menu_id); - break; - - case SET_ZOOM: - next_menu_id = MENU_ID_ZOOMCHANGE; - LOGD("next_menu_id = MENU_ID_ZOOMCHANGE = %d\n", next_menu_id); - break; - - case BEST_SHOT: - next_menu_id = MENU_ID_BESTSHOT; - LOGD("next_menu_id = MENU_ID_BESTSHOT = %d\n", next_menu_id); - break; - - case LIVE_SHOT: - * action_id_ptr = ACTION_TAKE_LIVE_SNAPSHOT; - LOGD("\nTaking Live snapshot\n"); - break; - - case FLASH_MODES: - next_menu_id = MENU_ID_FLASHMODE; - LOGD("next_menu_id = MENU_ID_FLASHMODE = %d\n", next_menu_id); - break; - - case SET_SHARPNESS: - next_menu_id = MENU_ID_SHARPNESSCHANGE; - LOGD("next_menu_id = MENU_ID_SHARPNESSCHANGE = %d\n", next_menu_id); - break; - - case SWITCH_SNAP_RESOLUTION: - next_menu_id = MENU_ID_SWITCH_RES; - LOGD("next_menu_id = MENU_ID_SWITCH_RES = %d\n", next_menu_id); - break; - - case TAKE_JPEG_SNAPSHOT: - * action_id_ptr = ACTION_TAKE_JPEG_SNAPSHOT; - printf("\n Taking JPEG snapshot\n"); - break; - - case START_RECORDING: - * action_id_ptr = ACTION_START_RECORDING; - LOGD("Start recording\n"); - break; - case STOP_RECORDING: - * action_id_ptr = ACTION_STOP_RECORDING; - LOGD("Stop recording\n"); - break; - case TOGGLE_ZSL: - * action_id_ptr = ACTION_TOGGLE_ZSL; - LOGD("Toggle ZSL\n"); - break; - case TAKE_RAW_SNAPSHOT: - * action_id_ptr = ACTION_TAKE_RAW_SNAPSHOT; - next_menu_id = MENU_ID_MAIN; - LOGD("Capture RAW\n"); - break; - case TOGGLE_WNR: - * action_id_ptr = ACTION_TOGGLE_WNR; - next_menu_id = MENU_ID_MAIN; - LOGD("Toggle WNR"); - break; - case EXIT: - * action_id_ptr = ACTION_EXIT; - LOGD("Exit \n"); - break; - default: - next_menu_id = MENU_ID_MAIN; - LOGD("next_menu_id = MENU_ID_MAIN = %d\n", next_menu_id); - break; - } - break; - - case MENU_ID_SWITCH_RES: - printf("MENU_ID_SWITCH_RES\n"); - *action_id_ptr = ACTION_SWITCH_RESOLUTION; - *action_param = output_to_event; - int available_sizes = sizeof(dimension_tbl)/sizeof(dimension_tbl[0]); - if ( ( *action_param >= 0 ) && - ( *action_param < available_sizes ) && - ( dimension_tbl[*action_param].supported )) { - next_menu_id = MENU_ID_MAIN; - } - else { - next_menu_id = current_menu_id; - } - break; - - case MENU_ID_SENSORS: - next_menu_id = MENU_ID_MAIN; - *action_id_ptr = ACTION_SWITCH_CAMERA; - *action_param = output_to_event; - break; - - case MENU_ID_WHITEBALANCECHANGE: - printf("MENU_ID_WHITEBALANCECHANGE\n"); - if (output_to_event >= WB_MAX) { - next_menu_id = current_menu_id; - * action_id_ptr = ACTION_NO_ACTION; - } else { - next_menu_id = MENU_ID_MAIN; - * action_id_ptr = ACTION_SET_WHITE_BALANCE; - * action_param = output_to_event; - } - break; - - case MENU_ID_EXPMETERINGCHANGE: - printf("MENU_ID_EXPMETERINGCHANGE\n"); - if (output_to_event >= AUTO_EXP_MAX) { - next_menu_id = current_menu_id; - * action_id_ptr = ACTION_NO_ACTION; - } else { - next_menu_id = MENU_ID_MAIN; - * action_id_ptr = ACTION_SET_EXP_METERING; - * action_param = output_to_event; - } - break; - - case MENU_ID_GET_CTRL_VALUE: - printf("MENU_ID_GET_CTRL_VALUE\n"); - * action_id_ptr = ACTION_GET_CTRL_VALUE; - if (output_to_event > 0 && - output_to_event <= (int)(sizeof(get_ctrl_tbl)/sizeof(get_ctrl_tbl[0]))) { - next_menu_id = MENU_ID_MAIN; - * action_param = output_to_event; - } - else { - next_menu_id = current_menu_id; - } - break; - - case MENU_ID_BRIGHTNESSCHANGE: - switch (output_to_event) { - case INC_BRIGHTNESS: - * action_id_ptr = ACTION_BRIGHTNESS_INCREASE; - next_menu_id = MENU_ID_MAIN; - break; - - case DEC_BRIGHTNESS: - * action_id_ptr = ACTION_BRIGHTNESS_DECREASE; - next_menu_id = MENU_ID_MAIN; - break; - - default: - next_menu_id = MENU_ID_BRIGHTNESSCHANGE; - break; - } - break; - - case MENU_ID_CONTRASTCHANGE: - switch (output_to_event) { - case INC_CONTRAST: - * action_id_ptr = ACTION_CONTRAST_INCREASE; - next_menu_id = MENU_ID_MAIN; - break; - - case DEC_CONTRAST: - * action_id_ptr = ACTION_CONTRAST_DECREASE; - next_menu_id = MENU_ID_MAIN; - break; - - default: - next_menu_id = MENU_ID_CONTRASTCHANGE; - break; - } - break; - - case MENU_ID_EVCHANGE: - switch (output_to_event) { - case INCREASE_EV: - * action_id_ptr = ACTION_EV_INCREASE; - next_menu_id = MENU_ID_MAIN; - break; - - case DECREASE_EV: - * action_id_ptr = ACTION_EV_DECREASE; - next_menu_id = MENU_ID_MAIN; - break; - - default: - next_menu_id = MENU_ID_EVCHANGE; - break; - } - break; - - case MENU_ID_SATURATIONCHANGE: - switch (output_to_event) { - case INC_SATURATION: - * action_id_ptr = ACTION_SATURATION_INCREASE; - next_menu_id = MENU_ID_MAIN; - break; - - case DEC_SATURATION: - * action_id_ptr = ACTION_SATURATION_DECREASE; - next_menu_id = MENU_ID_MAIN; - break; - - default: - next_menu_id = MENU_ID_EVCHANGE; - break; - } - break; - - case MENU_ID_ISOCHANGE: - printf("MENU_ID_ISOCHANGE\n"); - if (output_to_event >= ISO_MAX) { - next_menu_id = current_menu_id; - * action_id_ptr = ACTION_NO_ACTION; - } else { - next_menu_id = MENU_ID_MAIN; - * action_id_ptr = ACTION_SET_ISO; - * action_param = output_to_event; - } - break; - - case MENU_ID_ZOOMCHANGE: - * action_id_ptr = ACTION_SET_ZOOM; - if (output_to_event > 0 && - output_to_event <= (int)(sizeof(zoom_tbl)/sizeof(zoom_tbl[0]))) { - next_menu_id = MENU_ID_MAIN; - * action_param = output_to_event; - } else { - next_menu_id = current_menu_id; - } - break; - - case MENU_ID_SHARPNESSCHANGE: - switch (output_to_event) { - case INC_SHARPNESS: - * action_id_ptr = ACTION_SHARPNESS_INCREASE; - next_menu_id = MENU_ID_MAIN; - break; - case DEC_SHARPNESS: - * action_id_ptr = ACTION_SHARPNESS_DECREASE; - next_menu_id = MENU_ID_MAIN; - break; - default: - next_menu_id = MENU_ID_SHARPNESSCHANGE; - break; - } - break; - - case MENU_ID_BESTSHOT: - if (output_to_event >= BESTSHOT_MAX) { - next_menu_id = current_menu_id; - * action_id_ptr = ACTION_NO_ACTION; - } else { - next_menu_id = MENU_ID_MAIN; - * action_id_ptr = ACTION_SET_BESTSHOT_MODE; - * action_param = output_to_event; - } - break; - - case MENU_ID_FLASHMODE: - if (output_to_event >= FLASH_MODE_MAX) { - next_menu_id = current_menu_id; - * action_id_ptr = ACTION_NO_ACTION; - } else { - next_menu_id = MENU_ID_MAIN; - * action_id_ptr = ACTION_SET_FLASH_MODE; - * action_param = output_to_event; - } - break; - - default: - LOGD("menu id is wrong: %d\n", current_menu_id); - break; - } - - return next_menu_id; -} - -/*=========================================================================== - * FUNCTION - print_menu_preview_video - - * - * DESCRIPTION: - * ===========================================================================*/ -static void print_menu_preview_video(void) { - unsigned int i; - if (!is_rec) { - printf("\n"); - printf("===========================================\n"); - printf(" Camera is in preview/video mode now \n"); - printf("===========================================\n\n"); - } else { - printf("\n"); - printf("===========================================\n"); - printf(" Camera is in RECORDING mode now \n"); - printf(" Press 'Q' To Stop Recording \n"); - printf(" Press 'S' To Take Live Snapshot \n"); - printf("===========================================\n\n"); - } - char menuNum = 'A'; - for (i = 0; i < sizeof(camera_main_menu_tbl)/sizeof(camera_main_menu_tbl[0]); i++) { - if (i == BASE_OFFSET) { - menuNum = '1'; - } - - printf("%c. %s\n", menuNum, camera_main_menu_tbl[i].menu_name); - menuNum++; - } - - printf("\nPlease enter your choice: "); - - return; -} - -static void camera_preview_video_wb_change_tbl(void) { - unsigned int i; - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in white balance change mode \n"); - printf("==========================================================\n\n"); - - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(white_balance_tbl) / - sizeof(white_balance_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, white_balance_tbl[i].wb_name); - submenuNum++; - } - printf("\nPlease enter your choice for White Balance modes: "); - return; -} - -static void camera_preview_video_get_ctrl_value_tbl(void) { - unsigned int i; - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in get control value mode \n"); - printf("==========================================================\n\n"); - - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(get_ctrl_tbl) / - sizeof(get_ctrl_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, get_ctrl_tbl[i].get_ctrl_name); - submenuNum++; - } - printf("\nPlease enter your choice for control value you want to get: "); - return; -} - -static void camera_preview_video_exp_metering_change_tbl(void) { - unsigned int i; - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in exposure metering change mode \n"); - printf("==========================================================\n\n"); - - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(exp_metering_tbl) / - sizeof(exp_metering_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, exp_metering_tbl[i].exp_metering_name); - submenuNum++; - } - printf("\nPlease enter your choice for exposure metering modes: "); - return; -} - -static void camera_contrast_change_tbl(void) { - unsigned int i; - - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in change contrast resolution mode \n"); - printf("==========================================================\n\n"); - - char contrastmenuNum = 'A'; - for (i = 0; i < sizeof(contrast_change_tbl) / - sizeof(contrast_change_tbl[0]); i++) { - printf("%c. %s\n", contrastmenuNum, - contrast_change_tbl[i].contrast_name); - contrastmenuNum++; - } - - printf("\nPlease enter your choice for contrast Change: "); - return; -} - -static void camera_EV_change_tbl(void) { - unsigned int i; - - printf("\n"); - printf("===========================================\n"); - printf(" Camera is in EV change mode now \n"); - printf("===========================================\n\n"); - - char submenuNum = 'A'; - for (i = 0; i < sizeof(camera_EV_tbl)/sizeof(camera_EV_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, camera_EV_tbl[i].EV_name); - submenuNum++; - } - - printf("\nPlease enter your choice for EV changes: "); - return; -} - -static void camera_resolution_change_tbl(void) { - unsigned int i; - - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in snapshot resolution mode \n"); - printf("==========================================================\n\n"); - - for (i = 0; i < sizeof(dimension_tbl) / - sizeof(dimension_tbl[0]); i++) { - if ( dimension_tbl[i].supported ) { - printf("%d. %s\n", i, - dimension_tbl[i].str_name); - } - } - - printf("\nPlease enter your choice for Resolution: "); - return; -} - -static void camera_preview_video_zoom_change_tbl(void) { - unsigned int i; - zoom_max_value = MAX_ZOOMS_CNT; - printf("\nCurrent Zoom Value = %d ,Max Zoom Value = %d\n",zoom_level,zoom_max_value); - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(zoom_tbl) / - sizeof(zoom_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, zoom_tbl[i].zoom_direction_name); - submenuNum++; - } - printf("\nPlease enter your choice for zoom change direction: "); - return; -} - -static void camera_brightness_change_tbl(void) { - unsigned int i; - - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in change brightness mode \n"); - printf("==========================================================\n\n"); - - char brightnessmenuNum = 'A'; - for (i = 0; i < sizeof(brightness_change_tbl) / - sizeof(brightness_change_tbl[0]); i++) { - printf("%c. %s\n", brightnessmenuNum, - brightness_change_tbl[i].brightness_name); - brightnessmenuNum++; - } - - printf("\nPlease enter your choice for Brightness Change: "); - return; -} - -static void camera_saturation_change_tbl(void) { - unsigned int i; - - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in change saturation mode \n"); - printf("==========================================================\n\n"); - - char saturationmenuNum = 'A'; - for (i = 0; i < sizeof(camera_saturation_tbl) / - sizeof(camera_saturation_tbl[0]); i++) { - printf("%c. %s\n", saturationmenuNum, - camera_saturation_tbl[i].saturation_name); - saturationmenuNum++; - } - - printf("\nPlease enter your choice for Saturation Change: "); - return; -} - -static void camera_preview_video_iso_change_tbl(void) { - unsigned int i; - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in ISO change mode \n"); - printf("==========================================================\n\n"); - - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(iso_tbl) / - sizeof(iso_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, iso_tbl[i].iso_modes_name); - submenuNum++; - } - printf("\nPlease enter your choice for iso modes: "); - return; -} - -static void camera_preview_video_sharpness_change_tbl(void) { - unsigned int i; - printf("\n"); - printf("==========================================================\n"); - printf(" Camera is in sharpness change mode \n"); - printf("==========================================================\n\n"); - - char submenuNum = 'A'; - for (i = 0 ; i < sizeof(camera_sharpness_tbl) / - sizeof(camera_sharpness_tbl[0]); i++) { - printf("%c. %s\n", submenuNum, camera_sharpness_tbl[i].sharpness_name); - submenuNum++; - } - printf("\nPlease enter your choice for sharpness modes: "); - return; -} - -static void camera_set_bestshot_tbl(void) -{ - unsigned int i; - - printf("\n"); - printf("===========================================\n"); - printf(" Camera is in set besthot mode now \n"); - printf("===========================================\n\n"); - - - char bsmenuNum = 'A'; - for (i = 0; i < sizeof(bestshot_mode_tbl)/sizeof(bestshot_mode_tbl[0]); i++) { - printf("%c. %s\n", bsmenuNum, - bestshot_mode_tbl[i].name); - bsmenuNum++; - } - - printf("\nPlease enter your choice of Bestshot Mode: "); - return; -} - -static void camera_set_flashmode_tbl(void) -{ - unsigned int i; - - printf("\n"); - printf("===========================================\n"); - printf(" Camera is in set flash mode now \n"); - printf("===========================================\n\n"); - - - char bsmenuNum = 'A'; - for (i = 0; i < sizeof(flashmodes_tbl)/sizeof(flashmodes_tbl[0]); i++) { - printf("%c. %s\n", bsmenuNum, - flashmodes_tbl[i].name); - bsmenuNum++; - } - - printf("\nPlease enter your choice of Bestshot Mode: "); - return; -} - -static void camera_sensors_tbl(void) -{ - unsigned int i; - size_t available_sensors = sizeof(sensor_tbl)/sizeof(sensor_tbl[0]); - - printf("\n"); - printf("===========================================\n"); - printf(" Camera Sensor to be used: \n"); - printf("===========================================\n\n"); - - - char bsmenuNum = 'A'; - for (i = 0; ( i < available_sensors ) && ( sensor_tbl[i].present ) ; i++) { - printf("%c. %s\n", bsmenuNum, - sensor_tbl[i].menu_name); - bsmenuNum++; - } - - printf("\nPlease enter your choice for sensor: "); - return; -} - -/*=========================================================================== - * FUNCTION - increase_contrast - - * - * DESCRIPTION: - * ===========================================================================*/ -int increase_contrast (mm_camera_lib_handle *lib_handle) { - contrast += CAMERA_CONTRAST_STEP; - if (contrast > CAMERA_MAX_CONTRAST) { - contrast = CAMERA_MAX_CONTRAST; - printf("Reached max CONTRAST. \n"); - } - printf("Increase Contrast to %d\n", contrast); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_CONTRAST, - &contrast, - NULL); -} - -/*=========================================================================== - * FUNCTION - decrease_contrast - - * - * DESCRIPTION: - * ===========================================================================*/ -int decrease_contrast (mm_camera_lib_handle *lib_handle) { - contrast -= CAMERA_CONTRAST_STEP; - if (contrast < CAMERA_MIN_CONTRAST) { - contrast = CAMERA_MIN_CONTRAST; - printf("Reached min CONTRAST. \n"); - } - printf("Decrease Contrast to %d\n", contrast); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_CONTRAST, - &contrast, - NULL); -} - -/*=========================================================================== - * FUNCTION - decrease_brightness - - * - * DESCRIPTION: - * ===========================================================================*/ -int decrease_brightness (mm_camera_lib_handle *lib_handle) { - brightness -= CAMERA_BRIGHTNESS_STEP; - if (brightness < CAMERA_MIN_BRIGHTNESS) { - brightness = CAMERA_MIN_BRIGHTNESS; - printf("Reached min BRIGHTNESS. \n"); - } - printf("Decrease Brightness to %d\n", brightness); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_BRIGHTNESS, - &brightness, - NULL); -} - -/*=========================================================================== - * FUNCTION - increase_brightness - - * - * DESCRIPTION: - * ===========================================================================*/ -int increase_brightness (mm_camera_lib_handle *lib_handle) { - brightness += CAMERA_BRIGHTNESS_STEP; - if (brightness > CAMERA_MAX_BRIGHTNESS) { - brightness = CAMERA_MAX_BRIGHTNESS; - printf("Reached max BRIGHTNESS. \n"); - } - printf("Increase Brightness to %d\n", brightness); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_BRIGHTNESS, - &brightness, - NULL); -} - -/*=========================================================================== - * FUNCTION - increase_EV - - * - * DESCRIPTION: - * ===========================================================================*/ - -int increase_EV (void) { -#if 0 - int rc = 0; - int32_t value = 0; - rc = cam_config_is_parm_supported(cam_id, MM_CAMERA_PARM_EXPOSURE_COMPENSATION); - if(!rc) { - printf("MM_CAMERA_PARM_EXPOSURE_COMPENSATION mode is not supported for this sensor"); - return -1; - } - ev_numerator += 1; - if(ev_numerator >= EXPOSURE_COMPENSATION_MINIMUM_NUMERATOR && - ev_numerator <= EXPOSURE_COMPENSATION_MAXIMUM_NUMERATOR){ - int16_t numerator16 = (int16_t)(ev_numerator & 0x0000ffff); - uint16_t denominator16 = EXPOSURE_COMPENSATION_DENOMINATOR; - value = numerator16 << 16 | denominator16; - } else { - printf("Reached max EV.\n"); - } - return mm_app_set_config_parm(cam_id, MM_CAMERA_PARM_EXPOSURE_COMPENSATION, value); -#endif - return 0; -} - -/*=========================================================================== - * FUNCTION - decrease_EV - - * - * DESCRIPTION: - * ===========================================================================*/ -int decrease_EV (void) { -#if 0 - int rc = 0; - int32_t value = 0; - rc = cam_config_is_parm_supported(cam_id, MM_CAMERA_PARM_EXPOSURE_COMPENSATION); - if(!rc) { - printf("MM_CAMERA_PARM_EXPOSURE_COMPENSATION mode is not supported for this sensor"); - return -1; - } - ev_numerator -= 1; - if(ev_numerator >= EXPOSURE_COMPENSATION_MINIMUM_NUMERATOR && - ev_numerator <= EXPOSURE_COMPENSATION_MAXIMUM_NUMERATOR){ - int16_t numerator16 = (int16_t)(ev_numerator & 0x0000ffff); - uint16_t denominator16 = EXPOSURE_COMPENSATION_DENOMINATOR; - value = numerator16 << 16 | denominator16; - } else { - printf("Reached min EV.\n"); - } - return mm_app_set_config_parm(cam_id, MM_CAMERA_PARM_EXPOSURE_COMPENSATION, value); -#endif - return 0; -} - -/*=========================================================================== - * FUNCTION - increase_saturation - - * - * DESCRIPTION: - * ===========================================================================*/ -int increase_saturation (mm_camera_lib_handle *lib_handle) { -#if 0 - saturation += CAMERA_SATURATION_STEP; - if (saturation > CAMERA_MAX_SATURATION) { - saturation = CAMERA_MAX_SATURATION; - printf("Reached max saturation. \n"); - } - printf("Increase Saturation to %d\n", saturation); - return mm_app_set_config_parm(cam_id, MM_CAMERA_PARM_SATURATION, saturation); -#endif - saturation += CAMERA_SATURATION_STEP; - if (saturation > CAMERA_MAX_SATURATION) { - saturation = CAMERA_MAX_SATURATION; - printf("Reached max saturation. \n"); - } - printf("Increase saturation to %d\n", contrast); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_SATURATION, - &saturation, - NULL); -} - -/*=========================================================================== - * FUNCTION - decrease_saturation - - * - * DESCRIPTION: - * ===========================================================================*/ -int decrease_saturation (mm_camera_lib_handle *lib_handle) { -#if 0 - saturation -= CAMERA_SATURATION_STEP; - if (saturation < CAMERA_MIN_SATURATION) { - saturation = CAMERA_MIN_SATURATION; - printf("Reached min saturation. \n"); - } - printf("Dcrease Saturation to %d\n", saturation); - return mm_app_set_config_parm(cam_id, MM_CAMERA_PARM_SATURATION, saturation); -#endif - saturation -= CAMERA_SATURATION_STEP; - if (saturation < CAMERA_MIN_SATURATION) { - saturation = CAMERA_MIN_SATURATION; - printf("Reached min saturation. \n"); - } - printf("decrease saturation to %d\n", contrast); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_SATURATION, - &saturation, - NULL); -} - - -int take_jpeg_snapshot(mm_camera_test_obj_t *test_obj, int is_burst_mode) -{ - LOGH("\nEnter take_jpeg_snapshot!!\n"); - int rc = mm_app_take_picture (test_obj, (uint8_t)is_burst_mode); - if (MM_CAMERA_OK != rc) { - LOGE(" mm_app_take_picture() err=%d\n", rc); - } - return rc; -} - -/*=========================================================================== - * FUNCTION - main - - * - * DESCRIPTION: - *==========================================================================*/ -int main() -{ - char tc_buf[3]; - int mode = 0; - int rc = 0; - - printf("Please Select Execution Mode:\n"); - printf("0: Menu Based 1: Regression\n"); - fgets(tc_buf, 3, stdin); - mode = tc_buf[0] - '0'; - if(mode == 0) { - printf("\nStarting Menu based!!\n"); - } else if(mode == 1) { - printf("Starting Regression testing!!\n"); - if(!mm_app_start_regression_test(1)) { - printf("\nRegressiion test passed!!\n"); - return 0; - } else { - printf("\nRegression test failed!!\n"); - exit(-1); - } - } else { - printf("\nPlease Enter 0 or 1\n"); - printf("\nExisting the App!!\n"); - exit(-1); - } - - - rc = submain(); - - printf("Exiting application\n"); - - return rc; -} - -/*=========================================================================== - * FUNCTION - set_whitebalance - - * - * DESCRIPTION: - * ===========================================================================*/ -int set_whitebalance (mm_camera_lib_handle *lib_handle, int wb_action_param) { - cam_wb_mode_type type = 0; - switch (wb_action_param) { - case WB_AUTO: - printf("\n WB_AUTO\n"); - type = CAM_WB_MODE_AUTO; - break; - case WB_INCANDESCENT: - printf("\n WB_INCANDESCENT\n"); - type = CAM_WB_MODE_INCANDESCENT; - break; - case WB_FLUORESCENT: - printf("\n WB_FLUORESCENT\n"); - type = CAM_WB_MODE_FLUORESCENT; - break; - case WB_WARM_FLUORESCENT: - printf("\n WB_WARM_FLUORESCENT\n"); - type = CAM_WB_MODE_WARM_FLUORESCENT; - break; - case WB_DAYLIGHT: - printf("\n WB_DAYLIGHT\n"); - type = CAM_WB_MODE_DAYLIGHT; - break; - case WB_CLOUDY_DAYLIGHT: - printf("\n WB_CLOUDY_DAYLIGHT\n"); - type = CAM_WB_MODE_CLOUDY_DAYLIGHT; - break; - case WB_TWILIGHT: - printf("\n WB_TWILIGHT\n"); - type = CAM_WB_MODE_TWILIGHT; - break; - case WB_SHADE: - printf("\n WB_SHADE\n"); - type = CAM_WB_MODE_SHADE; - break; - default: - break; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_WB, - &type, - NULL); -} - - -/*=========================================================================== - * FUNCTION - set_exp_metering - - * - * DESCRIPTION: - * ===========================================================================*/ -int set_exp_metering (mm_camera_lib_handle *lib_handle, int exp_metering_action_param) { - cam_auto_exposure_mode_type type = 0; - switch (exp_metering_action_param) { - case AUTO_EXP_FRAME_AVG: - printf("\nAUTO_EXP_FRAME_AVG\n"); - type = CAM_AEC_MODE_FRAME_AVERAGE; - break; - case AUTO_EXP_CENTER_WEIGHTED: - printf("\n AUTO_EXP_CENTER_WEIGHTED\n"); - type = CAM_AEC_MODE_CENTER_WEIGHTED; - break; - case AUTO_EXP_SPOT_METERING: - printf("\n AUTO_EXP_SPOT_METERING\n"); - type = CAM_AEC_MODE_SPOT_METERING; - break; - case AUTO_EXP_SMART_METERING: - printf("\n AUTO_EXP_SMART_METERING\n"); - type = CAM_AEC_MODE_SMART_METERING; - break; - case AUTO_EXP_USER_METERING: - printf("\n AUTO_EXP_USER_METERING\n"); - type = CAM_AEC_MODE_USER_METERING; - break; - case AUTO_EXP_SPOT_METERING_ADV: - printf("\n AUTO_EXP_SPOT_METERING_ADV\n"); - type = CAM_AEC_MODE_SPOT_METERING_ADV; - break; - case AUTO_EXP_CENTER_WEIGHTED_ADV: - printf("\n AUTO_EXP_CENTER_WEIGHTED_ADV\n"); - type = CAM_AEC_MODE_CENTER_WEIGHTED_ADV; - break; - default: - break; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_EXPOSURE_METERING, - &type, - NULL); -} - -int get_ctrl_value (int ctrl_value_mode_param){ -#if 0 - int rc = 0; - struct v4l2_control ctrl; - - if (ctrl_value_mode_param == WHITE_BALANCE_STATE) { - printf("You chose WHITE_BALANCE_STATE\n"); - ctrl.id = V4L2_CID_AUTO_WHITE_BALANCE; - } - else if (ctrl_value_mode_param == WHITE_BALANCE_TEMPERATURE) { - printf("You chose WHITE_BALANCE_TEMPERATURE\n"); - ctrl.id = V4L2_CID_WHITE_BALANCE_TEMPERATURE; - } - else if (ctrl_value_mode_param == BRIGHTNESS_CTRL) { - printf("You chose brightness value\n"); - ctrl.id = V4L2_CID_BRIGHTNESS; - } - else if (ctrl_value_mode_param == EV) { - printf("You chose exposure value\n"); - ctrl.id = V4L2_CID_EXPOSURE; - } - else if (ctrl_value_mode_param == CONTRAST_CTRL) { - printf("You chose contrast value\n"); - ctrl.id = V4L2_CID_CONTRAST; - } - else if (ctrl_value_mode_param == SATURATION_CTRL) { - printf("You chose saturation value\n"); - ctrl.id = V4L2_CID_SATURATION; - } else if (ctrl_value_mode_param == SHARPNESS_CTRL) { - printf("You chose sharpness value\n"); - ctrl.id = V4L2_CID_SHARPNESS; - } - - // rc = ioctl(camfd, VIDIOC_G_CTRL, &ctrl); - return rc; -#endif - return ctrl_value_mode_param; -} - -/*=========================================================================== - * FUNCTION - toggle_afr - - * - * DESCRIPTION: - * ===========================================================================*/ -int toggle_afr () { -#if 0 - if (fps_mode == FPS_MODE_AUTO) { - printf("\nSetting FPS_MODE_FIXED\n"); - fps_mode = FPS_MODE_FIXED; - } else { - printf("\nSetting FPS_MODE_AUTO\n"); - fps_mode = FPS_MODE_AUTO; - } - return mm_app_set_config_parm(cam_id, MM_CAMERA_PARM_FPS_MODE, fps_mode); -#endif - return 0; -} - -int set_zoom (mm_camera_lib_handle *lib_handle, int zoom_action_param) { - - if (zoom_action_param == ZOOM_IN) { - zoom_level += ZOOM_STEP; - if (zoom_level > zoom_max_value) - zoom_level = zoom_max_value; - } else if (zoom_action_param == ZOOM_OUT) { - zoom_level -= ZOOM_STEP; - if (zoom_level < ZOOM_MIN_VALUE) - zoom_level = ZOOM_MIN_VALUE; - } else { - LOGD(" Invalid zoom_action_param value\n"); - return -EINVAL; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_ZOOM, - &zoom_level, - NULL); -} - -/*=========================================================================== - * FUNCTION - set_iso - - * - * DESCRIPTION: - * ===========================================================================*/ -int set_iso (mm_camera_lib_handle *lib_handle, int iso_action_param) { - cam_iso_mode_type type = 0; - switch (iso_action_param) { - case ISO_AUTO: - printf("\n ISO_AUTO\n"); - type = CAM_ISO_MODE_AUTO; - break; - case ISO_DEBLUR: - printf("\n ISO_DEBLUR\n"); - type = CAM_ISO_MODE_DEBLUR; - break; - case ISO_100: - printf("\n ISO_100\n"); - type = CAM_ISO_MODE_100; - break; - case ISO_200: - printf("\n ISO_200\n"); - type = CAM_ISO_MODE_200; - break; - case ISO_400: - printf("\n ISO_400\n"); - type = CAM_ISO_MODE_400; - break; - case ISO_800: - printf("\n ISO_800\n"); - type = CAM_ISO_MODE_800; - break; - case ISO_1600: - printf("\n ISO_1600\n"); - type = CAM_ISO_MODE_1600; - break; - default: - break; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_ISO, - &type, - NULL); -} - -/*=========================================================================== - * FUNCTION - increase_sharpness - - * - * DESCRIPTION: - * ===========================================================================*/ -int increase_sharpness (mm_camera_lib_handle *lib_handle) { - sharpness += CAMERA_SHARPNESS_STEP; - if (sharpness > CAMERA_MAX_SHARPNESS) { - sharpness = CAMERA_MAX_SHARPNESS; - printf("Reached max SHARPNESS. \n"); - } - printf("Increase Sharpness to %d\n", sharpness); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_SHARPNESS, - &sharpness, - NULL); -} - -/*=========================================================================== - * FUNCTION - decrease_sharpness - - * - * DESCRIPTION: - * ===========================================================================*/ -int decrease_sharpness (mm_camera_lib_handle *lib_handle) { - sharpness -= CAMERA_SHARPNESS_STEP; - if (sharpness < CAMERA_MIN_SHARPNESS) { - sharpness = CAMERA_MIN_SHARPNESS; - printf("Reached min SHARPNESS. \n"); - } - printf("Decrease Sharpness to %d\n", sharpness); - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_SHARPNESS, - &sharpness, - NULL); -} - -int set_flash_mode (mm_camera_lib_handle *lib_handle, int action_param) { - cam_flash_mode_t type = 0; - switch (action_param) { - case FLASH_MODE_OFF: - printf("\n FLASH_MODE_OFF\n"); - type = CAM_FLASH_MODE_OFF; - break; - case FLASH_MODE_AUTO: - printf("\n FLASH_MODE_AUTO\n"); - type = CAM_FLASH_MODE_AUTO; - break; - case FLASH_MODE_ON: - printf("\n FLASH_MODE_ON\n"); - type = CAM_FLASH_MODE_ON; - break; - case FLASH_MODE_TORCH: - printf("\n FLASH_MODE_TORCH\n"); - type = CAM_FLASH_MODE_TORCH; - break; - default: - break; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_FLASH, - &type, - NULL); -} - -int set_bestshot_mode(mm_camera_lib_handle *lib_handle, int action_param) { - cam_scene_mode_type type = 0; - switch (action_param) { - case BESTSHOT_AUTO: - printf("\n BEST SHOT AUTO\n"); - type = CAM_SCENE_MODE_OFF; - break; - case BESTSHOT_ACTION: - printf("\n BEST SHOT ACTION\n"); - type = CAM_SCENE_MODE_ACTION; - break; - case BESTSHOT_PORTRAIT: - printf("\n BEST SHOT PORTRAIT\n"); - type = CAM_SCENE_MODE_PORTRAIT; - break; - case BESTSHOT_LANDSCAPE: - printf("\n BEST SHOT LANDSCAPE\n"); - type = CAM_SCENE_MODE_LANDSCAPE; - break; - case BESTSHOT_NIGHT: - printf("\n BEST SHOT NIGHT\n"); - type = CAM_SCENE_MODE_NIGHT; - break; - case BESTSHOT_NIGHT_PORTRAIT: - printf("\n BEST SHOT NIGHT PORTRAIT\n"); - type = CAM_SCENE_MODE_NIGHT_PORTRAIT; - break; - case BESTSHOT_THEATRE: - printf("\n BEST SHOT THREATRE\n"); - type = CAM_SCENE_MODE_THEATRE; - break; - case BESTSHOT_BEACH: - printf("\n BEST SHOT BEACH\n"); - type = CAM_SCENE_MODE_BEACH; - break; - case BESTSHOT_SNOW: - printf("\n BEST SHOT SNOW\n"); - type = CAM_SCENE_MODE_SNOW; - break; - case BESTSHOT_SUNSET: - printf("\n BEST SHOT SUNSET\n"); - type = CAM_SCENE_MODE_SUNSET; - break; - case BESTSHOT_ANTISHAKE: - printf("\n BEST SHOT ANTISHAKE\n"); - type = CAM_SCENE_MODE_ANTISHAKE; - break; - case BESTSHOT_FIREWORKS: - printf("\n BEST SHOT FIREWORKS\n"); - type = CAM_SCENE_MODE_FIREWORKS; - break; - case BESTSHOT_SPORTS: - printf("\n BEST SHOT SPORTS\n"); - type = CAM_SCENE_MODE_SPORTS; - break; - case BESTSHOT_PARTY: - printf("\n BEST SHOT PARTY\n"); - type = CAM_SCENE_MODE_PARTY; - break; - case BESTSHOT_CANDLELIGHT: - printf("\n BEST SHOT CANDLELIGHT\n"); - type = CAM_SCENE_MODE_CANDLELIGHT; - break; - case BESTSHOT_ASD: - printf("\n BEST SHOT ASD\n"); - type = CAM_SCENE_MODE_AUTO; - break; - case BESTSHOT_BACKLIGHT: - printf("\n BEST SHOT BACKLIGHT\n"); - type = CAM_SCENE_MODE_BACKLIGHT; - break; - case BESTSHOT_FLOWERS: - printf("\n BEST SHOT FLOWERS\n"); - type = CAM_SCENE_MODE_FLOWERS; - break; - case BESTSHOT_AR: - printf("\n BEST SHOT AR\n"); - type = CAM_SCENE_MODE_AR; - break; - case BESTSHOT_HDR: - printf("\n BEST SHOT HDR\n"); - type = CAM_SCENE_MODE_OFF; - break; - default: - break; - } - return mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_BESTSHOT, - &type, - NULL); -} -/*=========================================================================== - * FUNCTION - print_current_menu - - * - * DESCRIPTION: - * ===========================================================================*/ -int print_current_menu (menu_id_change_t current_menu_id) { - if (current_menu_id == MENU_ID_MAIN) { - print_menu_preview_video (); - } else if (current_menu_id == MENU_ID_WHITEBALANCECHANGE) { - camera_preview_video_wb_change_tbl(); - } else if (current_menu_id == MENU_ID_EXPMETERINGCHANGE) { - camera_preview_video_exp_metering_change_tbl(); - } else if (current_menu_id == MENU_ID_GET_CTRL_VALUE) { - camera_preview_video_get_ctrl_value_tbl(); - } else if (current_menu_id == MENU_ID_ISOCHANGE) { - camera_preview_video_iso_change_tbl(); - } else if (current_menu_id == MENU_ID_BRIGHTNESSCHANGE) { - camera_brightness_change_tbl (); - } else if (current_menu_id == MENU_ID_CONTRASTCHANGE) { - camera_contrast_change_tbl (); - } else if (current_menu_id == MENU_ID_EVCHANGE) { - camera_EV_change_tbl (); - } else if (current_menu_id == MENU_ID_SATURATIONCHANGE) { - camera_saturation_change_tbl (); - } else if (current_menu_id == MENU_ID_ZOOMCHANGE) { - camera_preview_video_zoom_change_tbl(); - } else if (current_menu_id == MENU_ID_SHARPNESSCHANGE) { - camera_preview_video_sharpness_change_tbl(); - } else if (current_menu_id == MENU_ID_BESTSHOT) { - camera_set_bestshot_tbl(); - } else if (current_menu_id == MENU_ID_FLASHMODE) { - camera_set_flashmode_tbl(); - } else if (current_menu_id == MENU_ID_SENSORS ) { - camera_sensors_tbl(); - } else if (current_menu_id == MENU_ID_SWITCH_RES ) { - camera_resolution_change_tbl(); - } - - return 0; -} - -int filter_resolutions(mm_camera_lib_handle *lib_handle, - DIMENSION_TBL_T *tbl, - size_t tbl_size) -{ - size_t i, j; - cam_capability_t camera_cap; - int rc = 0; - - if ( ( NULL == lib_handle ) || ( NULL == tbl ) ) { - return -1; - } - - rc = mm_camera_lib_get_caps(lib_handle, &camera_cap); - if ( MM_CAMERA_OK != rc ) { - LOGE("mm_camera_lib_get_caps() err=%d\n", rc); - return -1; - } - - for( i = 0 ; i < tbl_size ; i++ ) { - for( j = 0; j < camera_cap.picture_sizes_tbl_cnt; j++ ) { - if ( ( tbl[i].width == camera_cap.picture_sizes_tbl[j].width ) && - ( tbl[i].height == camera_cap.picture_sizes_tbl[j].height ) ) { - tbl[i].supported = 1; - rc = (int)i; - break; - } - } - } - - return rc; -} - -/*=========================================================================== - * FUNCTION : enableAFR - * - * DESCRIPTION: This function will go through the list - * of supported FPS ranges and select the - * one which has maximum range - * - * PARAMETERS : - * @lib_handle : camera test library handle - * - * RETURN : uint32_t type of stream handle - * MM_CAMERA_OK -- Success - * !=MM_CAMERA_OK -- Error status - *==========================================================================*/ -int enableAFR(mm_camera_lib_handle *lib_handle) -{ - size_t i, j; - float max_range = 0.0f; - cam_capability_t cap; - int rc = MM_CAMERA_OK; - - if ( NULL == lib_handle ) { - return MM_CAMERA_E_INVALID_INPUT; - } - - rc = mm_camera_lib_get_caps(lib_handle, &cap); - if ( MM_CAMERA_OK != rc ) { - LOGE("mm_camera_lib_get_caps() err=%d\n", rc); - return rc; - } - - for( i = 0, j = 0 ; i < cap.fps_ranges_tbl_cnt ; i++ ) { - if ( max_range < (cap.fps_ranges_tbl[i].max_fps - cap.fps_ranges_tbl[i].min_fps) ) { - j = i; - } - } - - rc = mm_camera_lib_send_command(lib_handle, - MM_CAMERA_LIB_FPS_RANGE, - &cap.fps_ranges_tbl[j], - NULL); - - LOGE("FPS range [%5.2f:%5.2f] rc = %d", - cap.fps_ranges_tbl[j].min_fps, - cap.fps_ranges_tbl[j].max_fps, - rc); - - return rc; -} - -/*=========================================================================== - * FUNCTION - submain - - * - * DESCRIPTION: - * ===========================================================================*/ -static int submain() -{ - int rc = 0; - char tc_buf[3]; - menu_id_change_t current_menu_id = MENU_ID_MAIN, next_menu_id; - camera_action_t action_id; - int action_param; - uint8_t previewing = 0; - int isZSL = 0; - uint8_t wnr_enabled = 0; - mm_camera_lib_handle lib_handle; - int num_cameras; - int available_sensors = - (int)(sizeof(sensor_tbl) / sizeof(sensor_tbl[0])); - int available_snap_sizes = - (int)(sizeof(dimension_tbl)/sizeof(dimension_tbl[0])); - int i,c; - mm_camera_lib_snapshot_params snap_dim; - snap_dim.width = DEFAULT_SNAPSHOT_WIDTH; - snap_dim.height = DEFAULT_SNAPSHOT_HEIGHT; - cam_scene_mode_type default_scene= CAM_SCENE_MODE_OFF; - int set_tintless= 0; - - mm_camera_test_obj_t test_obj; - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - - rc = mm_camera_lib_open(&lib_handle, 0); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_open() err=%d\n", rc); - return -1; - } - - num_cameras = mm_camera_lib_number_of_cameras(&lib_handle); - if ( 0 >= num_cameras ) { - LOGE(" No camera sensors reported!"); - rc = -1; - goto ERROR; - } else if ( 1 <= num_cameras ) { - c = MIN(num_cameras, available_sensors); - for ( i = 0 ; i < c ; i++ ) { - sensor_tbl[i].present = 1; - } - current_menu_id = MENU_ID_SENSORS; - } else { - i = filter_resolutions(&lib_handle, - dimension_tbl, - (size_t)available_snap_sizes); - if ( ( i < 0 ) || ( i >= available_snap_sizes ) ) { - LOGE("filter_resolutions()\n"); - goto ERROR; - } - snap_dim.width = dimension_tbl[i].width; - snap_dim.height = dimension_tbl[i].height; - - rc = enableAFR(&lib_handle); - if (rc != MM_CAMERA_OK) { - LOGE("enableAFR() err=%d\n", rc); - goto ERROR; - } - - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_BESTSHOT, - &default_scene, - NULL); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_send_command() err=%d\n", rc); - goto ERROR; - } - } - /*start the eztune server*/ - LOGH("Starting eztune Server \n"); - eztune_server_start(&lib_handle); - - do { - print_current_menu (current_menu_id); - fgets(tc_buf, 3, stdin); - - next_menu_id = next_menu(current_menu_id, tc_buf[0], & action_id, & action_param); - - if (next_menu_id != MENU_ID_INVALID) { - current_menu_id = next_menu_id; - } - if (action_id == ACTION_NO_ACTION) { - continue; - } - - switch(action_id) { - case ACTION_START_PREVIEW: - LOGE("ACTION_START_PREVIEW \n"); - rc = mm_camera_lib_start_stream(&lib_handle); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_start_stream() err=%d\n", rc); - goto ERROR; - } - previewing = 1; - break; - - case ACTION_STOP_PREVIEW: - LOGD("ACTION_STOP_PREVIEW \n"); - rc = mm_camera_lib_stop_stream(&lib_handle); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_stop_stream() err=%d\n", rc); - goto ERROR; - } - previewing = 0; - break; - - case ACTION_SET_WHITE_BALANCE: - LOGD("Selection for the White Balance changes\n"); - set_whitebalance(&lib_handle, action_param); - break; - - case ACTION_SET_TINTLESS_ENABLE: - LOGD("Selection for the Tintless enable changes\n"); - set_tintless = 1; - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_SET_TINTLESS, - &set_tintless, - NULL); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_send_command() err=%d\n", rc); - goto ERROR; - } - break; - - case ACTION_SET_TINTLESS_DISABLE: - LOGD("Selection for the Tintless disable changes\n"); - set_tintless = 0; - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_SET_TINTLESS, - &set_tintless, - NULL); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_send_command() err=%d\n", rc); - goto ERROR; - } - break; - - case ACTION_SET_EXP_METERING: - LOGD("Selection for the Exposure Metering changes\n"); - set_exp_metering(&lib_handle, action_param); - break; - - case ACTION_GET_CTRL_VALUE: - LOGD("Selection for getting control value\n"); - get_ctrl_value(action_param); - break; - - case ACTION_BRIGHTNESS_INCREASE: - printf("Increase brightness\n"); - increase_brightness(&lib_handle); - break; - - case ACTION_BRIGHTNESS_DECREASE: - printf("Decrease brightness\n"); - decrease_brightness(&lib_handle); - break; - - case ACTION_CONTRAST_INCREASE: - LOGD("Selection for the contrast increase\n"); - increase_contrast (&lib_handle); - break; - - case ACTION_CONTRAST_DECREASE: - LOGD("Selection for the contrast decrease\n"); - decrease_contrast (&lib_handle); - break; - - case ACTION_EV_INCREASE: - LOGD("Selection for the EV increase\n"); - increase_EV (); - break; - - case ACTION_EV_DECREASE: - LOGD("Selection for the EV decrease\n"); - decrease_EV (); - break; - - case ACTION_SATURATION_INCREASE: - LOGD("Selection for the EV increase\n"); - increase_saturation (&lib_handle); - break; - - case ACTION_SATURATION_DECREASE: - LOGD("Selection for the EV decrease\n"); - decrease_saturation (&lib_handle); - break; - - case ACTION_TOGGLE_AFR: - LOGD("Select for auto frame rate toggling\n"); - toggle_afr(); - break; - - case ACTION_SET_ISO: - LOGD("Select for ISO changes\n"); - set_iso(&lib_handle, action_param); - break; - - case ACTION_SET_ZOOM: - LOGD("Selection for the zoom direction changes\n"); - set_zoom(&lib_handle, action_param); - break; - - case ACTION_SHARPNESS_INCREASE: - LOGD("Selection for sharpness increase\n"); - increase_sharpness(&lib_handle); - break; - - case ACTION_SHARPNESS_DECREASE: - LOGD("Selection for sharpness decrease\n"); - decrease_sharpness(&lib_handle); - break; - - case ACTION_SET_BESTSHOT_MODE: - LOGD("Selection for bestshot\n"); - set_bestshot_mode(&lib_handle, action_param); - break; - - case ACTION_SET_FLASH_MODE: - printf("\n Selection for flashmode\n"); - set_flash_mode(&lib_handle, action_param); - break; - - case ACTION_SWITCH_CAMERA: - rc = mm_camera_lib_close(&lib_handle); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_close() err=%d\n", rc); - goto ERROR; - } - - rc = mm_camera_lib_open(&lib_handle, action_param); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_open() err=%d\n", rc); - goto ERROR; - } - - i = filter_resolutions(&lib_handle, - dimension_tbl, - sizeof(dimension_tbl)/sizeof(dimension_tbl[0])); - if ( ( i < 0 ) || ( i >= available_snap_sizes ) ) { - LOGE("filter_resolutions()\n"); - goto ERROR; - } - snap_dim.width = dimension_tbl[i].width; - snap_dim.height = dimension_tbl[i].height; - - rc = enableAFR(&lib_handle); - if (rc != MM_CAMERA_OK) { - LOGE("enableAFR() err=%d\n", rc); - goto ERROR; - } - - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_BESTSHOT, - &default_scene, - NULL); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_send_command() err=%d\n", rc); - goto ERROR; - } - break; - - case ACTION_TOGGLE_ZSL: - printf("ZSL Toggle !!!\n"); - isZSL = !isZSL; - if ( isZSL ) { - printf("ZSL on !!!\n"); - } else { - printf("ZSL off !!!\n"); - } - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_ZSL_ENABLE, - &isZSL, - NULL); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_send_command() err=%d\n", rc); - goto ERROR; - } - break; - - case ACTION_TAKE_RAW_SNAPSHOT: - LOGH("\n Take RAW snapshot\n"); - - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_DO_AF, - NULL, - NULL); - - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_send_command() err=%d\n", rc); - goto ERROR; - } - - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_RAW_CAPTURE, - NULL, - NULL); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_send_command() err=%d\n", rc); - goto ERROR; - } - break; - - case ACTION_TAKE_JPEG_SNAPSHOT: - LOGH("\n Take JPEG snapshot\n"); - - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_JPEG_CAPTURE, - &snap_dim, - NULL); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_send_command() err=%d\n", rc); - goto ERROR; - } - break; - case ACTION_SWITCH_RESOLUTION: - printf("\n Switch snapshot resolution to %dx%d\n", - dimension_tbl[action_param].width, - dimension_tbl[action_param].height); - snap_dim.width = dimension_tbl[action_param].width; - snap_dim.height = dimension_tbl[action_param].height; - break; - - case ACTION_START_RECORDING: - LOGD("Start recording action\n"); -#if 0 - if (mm_app_start_video(cam_id) < 0) - goto ERROR; - is_rec = 1; -#endif - break; - case ACTION_STOP_RECORDING: - LOGD("Stop recording action\n"); -#if 0 - if(is_rec) { - if (mm_app_stop_video(cam_id) < 0) - goto ERROR; - is_rec = 0; - } -#endif - break; - case ACTION_TAKE_LIVE_SNAPSHOT: - printf("Selection for live shot\n"); -#if 0 - if(is_rec) - mm_app_take_live_snapshot(cam_id); - else - printf("\n !!! Use live snapshot option while recording only !!!\n"); -#endif - break; - - case ACTION_TOGGLE_WNR: - wnr_enabled = !wnr_enabled; - printf("WNR Enabled = %d\n", wnr_enabled); - rc = mm_camera_lib_send_command(&lib_handle, - MM_CAMERA_LIB_WNR_ENABLE, - &wnr_enabled, - NULL); - if (rc != MM_CAMERA_OK) { - LOGE("mm_camera_lib_send_command() err=%d\n", rc); - goto ERROR; - } - break; - - case ACTION_EXIT: - printf("Exiting....\n"); - break; - case ACTION_NO_ACTION: - printf("Go back to main menu"); - break; - - default: - printf("\n\n!!!!!WRONG INPUT: %d!!!!\n", action_id); - break; - } - - usleep(1000 * 1000); - LOGD("action_id = %d\n", action_id); - - } while (action_id != ACTION_EXIT); - action_id = ACTION_NO_ACTION; - - mm_camera_lib_close(&lib_handle); - return 0; - -ERROR: - - mm_camera_lib_close(&lib_handle); - - return rc; -} - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_preview.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_preview.c deleted file mode 100644 index 9734986..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_preview.c +++ /dev/null @@ -1,1313 +0,0 @@ -/* -Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -// System dependencies -#include <assert.h> -#include <errno.h> -#include <fcntl.h> -#define MMAN_H <SYSTEM_HEADER_PREFIX/mman.h> -#include MMAN_H - -// Camera dependencies -#include "mm_qcamera_app.h" -#include "mm_qcamera_dbg.h" -#include "mm_qcamera_app.h" -#include <assert.h> -#include <sys/mman.h> -#include <semaphore.h> - -static void mm_app_metadata_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - uint32_t i = 0; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *p_stream = NULL; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_buf_def_t *frame; - metadata_buffer_t *pMetadata; - - if (NULL == bufs || NULL == user_data) { - LOGE("bufs or user_data are not valid "); - return; - } - frame = bufs->bufs[0]; - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - - if (NULL == channel) { - LOGE("Channel object is NULL "); - return; - } - - /* find preview stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_METADATA) { - p_stream = &channel->streams[i]; - break; - } - } - - if (NULL == p_stream) { - LOGE("cannot find metadata stream"); - return; - } - - /* find preview frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == p_stream->s_id) { - frame = bufs->bufs[i]; - break; - } - } - - if (pme->metadata == NULL) { - /* The app will free the meta data, we don't need to bother here */ - pme->metadata = malloc(sizeof(metadata_buffer_t)); - if (NULL == pme->metadata) { - LOGE("Canot allocate metadata memory\n"); - return; - } - } - memcpy(pme->metadata, frame->buffer, sizeof(metadata_buffer_t)); - - pMetadata = (metadata_buffer_t *)frame->buffer; - IF_META_AVAILABLE(uint32_t, afState, CAM_INTF_META_AF_STATE, pMetadata) { - if ((cam_af_state_t)(*afState) == CAM_AF_STATE_FOCUSED_LOCKED || - (cam_af_state_t)(*afState) == CAM_AF_STATE_NOT_FOCUSED_LOCKED) { - LOGE("AutoFocus Done Call Back Received\n"); - mm_camera_app_done(); - } else if ((cam_af_state_t)(*afState) == CAM_AF_STATE_NOT_FOCUSED_LOCKED) { - LOGE("AutoFocus failed\n"); - mm_camera_app_done(); - } - } - - if (pme->user_metadata_cb) { - LOGD("[DBG] %s, user defined own metadata cb. calling it..."); - pme->user_metadata_cb(frame); - } - - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - LOGE("Failed in Preview Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); -} - -static void mm_app_snapshot_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - - int rc = 0; - uint32_t i = 0; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *p_stream = NULL; - mm_camera_stream_t *m_stream = NULL; - mm_camera_buf_def_t *p_frame = NULL; - mm_camera_buf_def_t *m_frame = NULL; - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - if (NULL == channel) { - LOGE("Wrong channel id (%d)", bufs->ch_id); - rc = -1; - goto error; - } - - /* find snapshot stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_SNAPSHOT) { - m_stream = &channel->streams[i]; - break; - } - } - if (NULL == m_stream) { - LOGE("cannot find snapshot stream"); - rc = -1; - goto error; - } - - /* find snapshot frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == m_stream->s_id) { - m_frame = bufs->bufs[i]; - break; - } - } - if (NULL == m_frame) { - LOGE("main frame is NULL"); - rc = -1; - goto error; - } - - mm_app_dump_frame(m_frame, "main", "yuv", m_frame->frame_idx); - - /* find postview stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_POSTVIEW) { - p_stream = &channel->streams[i]; - break; - } - } - if (NULL != p_stream) { - /* find preview frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == p_stream->s_id) { - p_frame = bufs->bufs[i]; - break; - } - } - if (NULL != p_frame) { - mm_app_dump_frame(p_frame, "postview", "yuv", p_frame->frame_idx); - } - } - - mm_app_cache_ops((mm_camera_app_meminfo_t *)m_frame->mem_info, - ION_IOC_CLEAN_INV_CACHES); - - pme->jpeg_buf.buf.buffer = (uint8_t *)malloc(m_frame->frame_len); - if ( NULL == pme->jpeg_buf.buf.buffer ) { - LOGE("error allocating jpeg output buffer"); - goto error; - } - - pme->jpeg_buf.buf.frame_len = m_frame->frame_len; - /* create a new jpeg encoding session */ - rc = createEncodingSession(pme, m_stream, m_frame); - if (0 != rc) { - LOGE("error creating jpeg session"); - free(pme->jpeg_buf.buf.buffer); - goto error; - } - - /* start jpeg encoding job */ - rc = encodeData(pme, bufs, m_stream); - if (0 != rc) { - LOGE("error creating jpeg session"); - free(pme->jpeg_buf.buf.buffer); - goto error; - } - -error: - /* buf done rcvd frames in error case */ - if ( 0 != rc ) { - for (i=0; i<bufs->num_bufs; i++) { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - bufs->bufs[i])) { - LOGE("Failed in Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)bufs->bufs[i]->mem_info, - ION_IOC_INV_CACHES); - } - } - - LOGD(" END\n"); -} - -static void mm_app_preview_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - uint32_t i = 0; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *p_stream = NULL; - mm_camera_buf_def_t *frame = NULL; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - - if (NULL == bufs || NULL == user_data) { - LOGE("bufs or user_data are not valid "); - return; - } - - frame = bufs->bufs[0]; - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - if (NULL == channel) { - LOGE("Channel object is NULL "); - return; - } - /* find preview stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_PREVIEW) { - p_stream = &channel->streams[i]; - break; - } - } - - if (NULL == p_stream) { - LOGE("cannot find preview stream"); - return; - } - - /* find preview frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == p_stream->s_id) { - frame = bufs->bufs[i]; - break; - } - } - - if ( 0 < pme->fb_fd ) { - mm_app_overlay_display(pme, frame->fd); - } -#ifdef DUMP_PRV_IN_FILE - { - char file_name[64]; - snprintf(file_name, sizeof(file_name), "P_C%d", pme->cam->camera_handle); - mm_app_dump_frame(frame, file_name, "yuv", frame->frame_idx); - } -#endif - if (pme->user_preview_cb) { - LOGE("[DBG] %s, user defined own preview cb. calling it..."); - pme->user_preview_cb(frame); - } - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - LOGE("Failed in Preview Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); - - LOGD(" END\n"); -} - -static void mm_app_zsl_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - int rc = MM_CAMERA_OK; - uint32_t i = 0; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *p_stream = NULL; - mm_camera_stream_t *m_stream = NULL; - mm_camera_stream_t *md_stream = NULL; - mm_camera_buf_def_t *p_frame = NULL; - mm_camera_buf_def_t *m_frame = NULL; - mm_camera_buf_def_t *md_frame = NULL; - - LOGD(" BEGIN\n"); - - if (NULL == bufs || NULL == user_data) { - LOGE("bufs or user_data are not valid "); - return; - } - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - if (NULL == channel) { - LOGE("Wrong channel id (%d)", bufs->ch_id); - return; - } - - /* find preview stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_PREVIEW) { - p_stream = &channel->streams[i]; - break; - } - } - if (NULL == p_stream) { - LOGE("cannot find preview stream"); - return; - } - - /* find snapshot stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_SNAPSHOT) { - m_stream = &channel->streams[i]; - break; - } - } - if (NULL == m_stream) { - LOGE("cannot find snapshot stream"); - return; - } - - /* find metadata stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_METADATA) { - md_stream = &channel->streams[i]; - break; - } - } - if (NULL == md_stream) { - LOGE("cannot find metadata stream"); - } - - /* find preview frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == p_stream->s_id) { - p_frame = bufs->bufs[i]; - break; - } - } - - if(md_stream) { - /* find metadata frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == md_stream->s_id) { - md_frame = bufs->bufs[i]; - break; - } - } - if (!md_frame) { - LOGE("md_frame is null\n"); - return; - } - if (!pme->metadata) { - /* App will free the metadata */ - pme->metadata = malloc(sizeof(metadata_buffer_t)); - if (!pme->metadata) { - LOGE("not enough memory\n"); - return; - } - } - - memcpy(pme->metadata , md_frame->buffer, sizeof(metadata_buffer_t)); - } - /* find snapshot frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == m_stream->s_id) { - m_frame = bufs->bufs[i]; - break; - } - } - - if (!m_frame || !p_frame) { - LOGE("cannot find preview/snapshot frame"); - return; - } - - LOGD(" ZSL CB with fb_fd = %d, m_frame = %p, p_frame = %p \n", - pme->fb_fd, - m_frame, - p_frame); - - if ( 0 < pme->fb_fd ) { - mm_app_overlay_display(pme, p_frame->fd); - }/* else { - mm_app_dump_frame(p_frame, "zsl_preview", "yuv", p_frame->frame_idx); - mm_app_dump_frame(m_frame, "zsl_main", "yuv", m_frame->frame_idx); - }*/ - - if ( pme->enable_reproc && ( NULL != pme->reproc_stream ) ) { - - if (NULL != md_frame) { - rc = mm_app_do_reprocess(pme, - m_frame, - md_frame->buf_idx, - bufs, - md_stream); - - if (MM_CAMERA_OK != rc ) { - LOGE("reprocess failed rc = %d", rc); - } - } else { - LOGE("md_frame is null\n"); - } - - return; - } - - if ( pme->encodeJpeg ) { - pme->jpeg_buf.buf.buffer = (uint8_t *)malloc(m_frame->frame_len); - if ( NULL == pme->jpeg_buf.buf.buffer ) { - LOGE("error allocating jpeg output buffer"); - goto exit; - } - - pme->jpeg_buf.buf.frame_len = m_frame->frame_len; - /* create a new jpeg encoding session */ - rc = createEncodingSession(pme, m_stream, m_frame); - if (0 != rc) { - LOGE("error creating jpeg session"); - free(pme->jpeg_buf.buf.buffer); - goto exit; - } - - /* start jpeg encoding job */ - rc = encodeData(pme, bufs, m_stream); - pme->encodeJpeg = 0; - } else { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - m_frame)) { - LOGE("Failed in main Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)m_frame->mem_info, - ION_IOC_INV_CACHES); - } - -exit: - - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - p_frame)) { - LOGE("Failed in preview Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)p_frame->mem_info, - ION_IOC_INV_CACHES); - - if(md_frame) { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - md_frame)) { - LOGE("Failed in metadata Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)md_frame->mem_info, - ION_IOC_INV_CACHES); - } - - LOGD(" END\n"); -} - -mm_camera_stream_t * mm_app_add_metadata_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - LOGE("add stream failed\n"); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.stream_cb_sync = NULL; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_METADATA; - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - stream->s_config.stream_info->fmt = DEFAULT_PREVIEW_FORMAT; - stream->s_config.stream_info->dim.width = sizeof(metadata_buffer_t); - stream->s_config.stream_info->dim.height = 1; - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - LOGE("config preview stream err=%d\n", rc); - return NULL; - } - - return stream; -} - -cam_dimension_t mm_app_get_analysis_stream_dim( - const mm_camera_test_obj_t *test_obj, - const cam_dimension_t* preview_dim) -{ - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - cam_dimension_t max_analysis_dim = - cam_cap->analysis_info[CAM_ANALYSIS_INFO_FD_STILL].analysis_max_res; - cam_dimension_t analysis_dim = {0, 0}; - - if (preview_dim->width > max_analysis_dim.width || - preview_dim->height > max_analysis_dim.height) { - double max_ratio, requested_ratio; - - max_ratio = (double)max_analysis_dim.width / (double)max_analysis_dim.height; - requested_ratio = (double)preview_dim->width / (double)preview_dim->height; - - if (max_ratio < requested_ratio) { - analysis_dim.width = analysis_dim.width; - analysis_dim.height = (int32_t)((double)analysis_dim.width / requested_ratio); - } else { - analysis_dim.height = analysis_dim.height; - analysis_dim.width = (int32_t)((double)analysis_dim.height * requested_ratio); - } - analysis_dim.width &= ~0x1; - analysis_dim.height &= ~0x1; - } else { - analysis_dim = *preview_dim; - } - - LOGI("analysis stream dim (%d x %d)\n", analysis_dim.width, analysis_dim.height); - return analysis_dim; -} - -mm_camera_stream_t * mm_app_add_analysis_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - cam_dimension_t preview_dim = {0, 0}; - cam_dimension_t analysis_dim = {0, 0}; - - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - LOGE("add stream failed\n"); - return NULL; - } - - if ((test_obj->preview_resolution.user_input_display_width == 0) || - ( test_obj->preview_resolution.user_input_display_height == 0)) { - preview_dim.width = DEFAULT_PREVIEW_WIDTH; - preview_dim.height = DEFAULT_PREVIEW_HEIGHT; - } else { - preview_dim.width = test_obj->preview_resolution.user_input_display_width; - preview_dim.height = test_obj->preview_resolution.user_input_display_height; - } - - analysis_dim = mm_app_get_analysis_stream_dim(test_obj, &preview_dim); - LOGI("analysis stream dimesion: %d x %d\n", - analysis_dim.width, analysis_dim.height); - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_ANALYSIS; - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - stream->s_config.stream_info->fmt = DEFAULT_PREVIEW_FORMAT; - stream->s_config.stream_info->dim = analysis_dim; - stream->s_config.padding_info = - cam_cap->analysis_info[CAM_ANALYSIS_INFO_FD_STILL].analysis_padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - LOGE("config preview stream err=%d\n", rc); - return NULL; - } - - return stream; -} - -mm_camera_stream_t * mm_app_add_preview_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - cam_dimension_t preview_dim = {0, 0}; - cam_dimension_t analysis_dim = {0, 0}; - - if ((test_obj->preview_resolution.user_input_display_width == 0) || - ( test_obj->preview_resolution.user_input_display_height == 0)) { - preview_dim.width = DEFAULT_PREVIEW_WIDTH; - preview_dim.height = DEFAULT_PREVIEW_HEIGHT; - } else { - preview_dim.width = test_obj->preview_resolution.user_input_display_width; - preview_dim.height = test_obj->preview_resolution.user_input_display_height; - } - LOGI("preview dimesion: %d x %d\n", preview_dim.width, preview_dim.height); - - analysis_dim = mm_app_get_analysis_stream_dim(test_obj, &preview_dim); - LOGI("analysis stream dimesion: %d x %d\n", - analysis_dim.width, analysis_dim.height); - - uint32_t analysis_pp_mask = cam_cap->qcom_supported_feature_mask & - (CAM_QCOM_FEATURE_SHARPNESS | - CAM_QCOM_FEATURE_EFFECT | - CAM_QCOM_FEATURE_DENOISE2D); - LOGI("analysis stream pp mask:%x\n", analysis_pp_mask); - - cam_stream_size_info_t abc ; - memset (&abc , 0, sizeof (cam_stream_size_info_t)); - - abc.num_streams = 2; - abc.postprocess_mask[0] = 2178; - abc.stream_sizes[0].width = preview_dim.width; - abc.stream_sizes[0].height = preview_dim.height; - abc.type[0] = CAM_STREAM_TYPE_PREVIEW; - - abc.postprocess_mask[1] = analysis_pp_mask; - abc.stream_sizes[1].width = analysis_dim.width; - abc.stream_sizes[1].height = analysis_dim.height; - abc.type[1] = CAM_STREAM_TYPE_ANALYSIS; - - abc.buffer_info.min_buffers = 10; - abc.buffer_info.max_buffers = 10; - abc.is_type[0] = IS_TYPE_NONE; - - rc = setmetainfoCommand(test_obj, &abc); - if (rc != MM_CAMERA_OK) { - LOGE("meta info command failed\n"); - } - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - LOGE("add stream failed\n"); - return NULL; - } - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.stream_cb_sync = NULL; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_PREVIEW; - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - stream->s_config.stream_info->fmt = DEFAULT_PREVIEW_FORMAT; - - stream->s_config.stream_info->dim.width = preview_dim.width; - stream->s_config.stream_info->dim.height = preview_dim.height; - - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - LOGE("config preview stream err=%d\n", rc); - return NULL; - } - - return stream; -} - -mm_camera_stream_t * mm_app_add_raw_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - cam_stream_size_info_t abc ; - memset (&abc , 0, sizeof (cam_stream_size_info_t)); - - abc.num_streams = 1; - abc.postprocess_mask[0] = 0; - - if ( test_obj->buffer_width == 0 || test_obj->buffer_height == 0 ) { - abc.stream_sizes[0].width = DEFAULT_SNAPSHOT_WIDTH; - abc.stream_sizes[0].height = DEFAULT_SNAPSHOT_HEIGHT; - } else { - abc.stream_sizes[0].width = (int32_t)test_obj->buffer_width; - abc.stream_sizes[0].height = (int32_t)test_obj->buffer_height; - } - abc.type[0] = CAM_STREAM_TYPE_RAW; - - abc.buffer_info.min_buffers = num_bufs; - abc.buffer_info.max_buffers = num_bufs; - abc.is_type[0] = IS_TYPE_NONE; - - rc = setmetainfoCommand(test_obj, &abc); - if (rc != MM_CAMERA_OK) { - LOGE("meta info command failed\n"); - } - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - LOGE("add stream failed\n"); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.stream_cb_sync = NULL; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_RAW; - if (num_burst == 0) { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - } else { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_BURST; - stream->s_config.stream_info->num_of_burst = num_burst; - } - stream->s_config.stream_info->fmt = test_obj->buffer_format; - if ( test_obj->buffer_width == 0 || test_obj->buffer_height == 0 ) { - stream->s_config.stream_info->dim.width = DEFAULT_SNAPSHOT_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_SNAPSHOT_HEIGHT; - } else { - stream->s_config.stream_info->dim.width = (int32_t)test_obj->buffer_width; - stream->s_config.stream_info->dim.height = (int32_t)test_obj->buffer_height; - } - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - LOGE("config preview stream err=%d\n", rc); - return NULL; - } - - return stream; -} - -mm_camera_stream_t * mm_app_add_snapshot_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - cam_stream_size_info_t abc_snap ; - memset (&abc_snap , 0, sizeof (cam_stream_size_info_t)); - - abc_snap.num_streams = 2; - abc_snap.postprocess_mask[1] = 2178; - abc_snap.stream_sizes[1].width = DEFAULT_PREVIEW_WIDTH; - abc_snap.stream_sizes[1].height = DEFAULT_PREVIEW_HEIGHT; - abc_snap.type[1] = CAM_STREAM_TYPE_POSTVIEW; - - abc_snap.postprocess_mask[0] = 0; - abc_snap.stream_sizes[0].width = DEFAULT_SNAPSHOT_WIDTH; - abc_snap.stream_sizes[0].height = DEFAULT_SNAPSHOT_HEIGHT; - abc_snap.type[0] = CAM_STREAM_TYPE_SNAPSHOT; - - abc_snap.buffer_info.min_buffers = 7; - abc_snap.buffer_info.max_buffers = 7; - abc_snap.is_type[0] = IS_TYPE_NONE; - - rc = setmetainfoCommand(test_obj, &abc_snap); - if (rc != MM_CAMERA_OK) { - LOGE("meta info command snapshot failed\n"); - } - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - LOGE("add stream failed\n"); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.stream_cb_sync = NULL; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_SNAPSHOT; - if (num_burst == 0) { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - } else { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_BURST; - stream->s_config.stream_info->num_of_burst = num_burst; - } - stream->s_config.stream_info->fmt = DEFAULT_SNAPSHOT_FORMAT; - if ( test_obj->buffer_width == 0 || test_obj->buffer_height == 0 ) { - stream->s_config.stream_info->dim.width = DEFAULT_SNAPSHOT_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_SNAPSHOT_HEIGHT; - } else { - stream->s_config.stream_info->dim.width = DEFAULT_SNAPSHOT_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_SNAPSHOT_HEIGHT; - } - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - LOGE("config preview stream err=%d\n", rc); - return NULL; - } - - return stream; -} - -mm_camera_channel_t * mm_app_add_preview_channel(mm_camera_test_obj_t *test_obj) -{ - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_PREVIEW, - NULL, - NULL, - NULL); - if (NULL == channel) { - LOGE("add channel failed"); - return NULL; - } - - stream = mm_app_add_preview_stream(test_obj, - channel, - mm_app_preview_notify_cb, - (void *)test_obj, - PREVIEW_BUF_NUM); - if (NULL == stream) { - LOGE("add stream failed\n"); - mm_app_del_channel(test_obj, channel); - return NULL; - } - - return channel; -} - -int mm_app_stop_and_del_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - uint8_t i; - cam_stream_size_info_t abc ; - memset (&abc , 0, sizeof (cam_stream_size_info_t)); - - rc = mm_app_stop_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("Stop Preview failed rc=%d\n", rc); - } - - if (channel->num_streams <= MAX_STREAM_NUM_IN_BUNDLE) { - for (i = 0; i < channel->num_streams; i++) { - stream = &channel->streams[i]; - rc = mm_app_del_stream(test_obj, channel, stream); - if (MM_CAMERA_OK != rc) { - LOGE("del stream(%d) failed rc=%d\n", i, rc); - } - } - } else { - LOGE("num_streams = %d. Should not be more than %d\n", - channel->num_streams, MAX_STREAM_NUM_IN_BUNDLE); - } - - rc = setmetainfoCommand(test_obj, &abc); - if (rc != MM_CAMERA_OK) { - LOGE("meta info command failed\n"); - } - - rc = mm_app_del_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("delete channel failed rc=%d\n", rc); - } - - return rc; -} - -int mm_app_start_preview(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - mm_camera_stream_t *s_metadata = NULL; - mm_camera_stream_t *s_analysis = NULL; - uint8_t i; - - channel = mm_app_add_preview_channel(test_obj); - if (NULL == channel) { - LOGE("add channel failed"); - return -MM_CAMERA_E_GENERAL; - } - - s_metadata = mm_app_add_metadata_stream(test_obj, - channel, - mm_app_metadata_notify_cb, - (void *)test_obj, - PREVIEW_BUF_NUM); - if (NULL == s_metadata) { - LOGE("add metadata stream failed\n"); - mm_app_del_channel(test_obj, channel); - return rc; - } - - s_analysis = mm_app_add_analysis_stream(test_obj, - channel, - NULL, - (void *)test_obj, - PREVIEW_BUF_NUM); - if (NULL == s_analysis) { - LOGE("add metadata stream failed\n"); - mm_app_del_channel(test_obj, channel); - return rc; - } - - rc = mm_app_start_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("start preview failed rc=%d\n", rc); - if (channel->num_streams <= MAX_STREAM_NUM_IN_BUNDLE) { - for (i = 0; i < channel->num_streams; i++) { - stream = &channel->streams[i]; - mm_app_del_stream(test_obj, channel, stream); - } - } - mm_app_del_channel(test_obj, channel); - return rc; - } - - return rc; -} - -int mm_app_stop_preview(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *channel = - mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_PREVIEW); - - rc = mm_app_stop_and_del_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("Stop Preview failed rc=%d\n", rc); - } - - return rc; -} - -int mm_app_start_preview_zsl(mm_camera_test_obj_t *test_obj) -{ - int32_t rc = MM_CAMERA_OK; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *s_preview = NULL; - mm_camera_stream_t *s_metadata = NULL; - mm_camera_stream_t *s_main = NULL; - mm_camera_channel_attr_t attr; - memset(&attr, 0, sizeof(mm_camera_channel_attr_t)); - attr.notify_mode = MM_CAMERA_SUPER_BUF_NOTIFY_CONTINUOUS; - attr.look_back = 2; - attr.post_frame_skip = 0; - attr.water_mark = 2; - attr.max_unmatched_frames = 3; - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_ZSL, - &attr, - mm_app_zsl_notify_cb, - test_obj); - if (NULL == channel) { - LOGE("add channel failed"); - return -MM_CAMERA_E_GENERAL; - } - - s_preview = mm_app_add_preview_stream(test_obj, - channel, - mm_app_preview_notify_cb, - (void *)test_obj, - PREVIEW_BUF_NUM); - if (NULL == s_preview) { - LOGE("add preview stream failed\n"); - mm_app_del_channel(test_obj, channel); - return rc; - } - - s_main = mm_app_add_snapshot_stream(test_obj, - channel, - mm_app_snapshot_notify_cb, - (void *)test_obj, - PREVIEW_BUF_NUM, - 0); - if (NULL == s_main) { - LOGE("add main snapshot stream failed\n"); - mm_app_del_stream(test_obj, channel, s_preview); - mm_app_del_channel(test_obj, channel); - return rc; - } - - s_metadata = mm_app_add_metadata_stream(test_obj, - channel, - mm_app_metadata_notify_cb, - (void *)test_obj, - PREVIEW_BUF_NUM); - if (NULL == s_metadata) { - LOGE("add metadata stream failed\n"); - mm_app_del_channel(test_obj, channel); - return rc; - } - - rc = mm_app_start_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("start zsl failed rc=%d\n", rc); - mm_app_del_stream(test_obj, channel, s_preview); - mm_app_del_stream(test_obj, channel, s_metadata); - mm_app_del_stream(test_obj, channel, s_main); - mm_app_del_channel(test_obj, channel); - return rc; - } - - if ( test_obj->enable_reproc ) { - if ( NULL == mm_app_add_reprocess_channel(test_obj, s_main) ) { - LOGE("Reprocess channel failed to initialize \n"); - mm_app_del_stream(test_obj, channel, s_preview); -#ifdef USE_METADATA_STREAM - mm_app_del_stream(test_obj, channel, s_metadata); -#endif - mm_app_del_stream(test_obj, channel, s_main); - mm_app_del_channel(test_obj, channel); - return rc; - } - rc = mm_app_start_reprocess(test_obj); - if (MM_CAMERA_OK != rc) { - LOGE("reprocess start failed rc=%d\n", rc); - mm_app_del_stream(test_obj, channel, s_preview); -#ifdef USE_METADATA_STREAM - mm_app_del_stream(test_obj, channel, s_metadata); -#endif - mm_app_del_stream(test_obj, channel, s_main); - mm_app_del_channel(test_obj, channel); - return rc; - } - } - - return rc; -} - -int mm_app_stop_preview_zsl(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - - mm_camera_channel_t *channel = - mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_ZSL); - - rc = mm_app_stop_and_del_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("Stop Preview failed rc=%d\n", rc); - } - - if ( test_obj->enable_reproc ) { - rc |= mm_app_stop_reprocess(test_obj); - } - - return rc; -} - -int mm_app_initialize_fb(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - int brightness_fd; - const char brightness_level[] = BACKLIGHT_LEVEL; - void *fb_base = NULL; - - assert( ( NULL != test_obj ) && ( 0 == test_obj->fb_fd ) ); - - test_obj->fb_fd = open(FB_PATH, O_RDWR); - if ( 0 > test_obj->fb_fd ) { - LOGE("FB device open failed rc=%d, %s\n", - -errno, - strerror(errno)); - rc = -errno; - goto FAIL; - } - - rc = ioctl(test_obj->fb_fd, FBIOGET_VSCREENINFO, &test_obj->vinfo); - if ( MM_CAMERA_OK != rc ) { - LOGE("Can not retrieve screen info rc=%d, %s\n", - -errno, - strerror(errno)); - rc = -errno; - goto FAIL; - } - - if ( ( 0 == test_obj->vinfo.yres_virtual ) || - ( 0 == test_obj->vinfo.yres ) || - ( test_obj->vinfo.yres > test_obj->vinfo.yres_virtual ) ) { - LOGE("Invalid FB virtual yres: %d, yres: %d\n", - test_obj->vinfo.yres_virtual, - test_obj->vinfo.yres); - rc = MM_CAMERA_E_GENERAL; - goto FAIL; - } - - if ( ( 0 == test_obj->vinfo.xres_virtual ) || - ( 0 == test_obj->vinfo.xres ) || - ( test_obj->vinfo.xres > test_obj->vinfo.xres_virtual ) ) { - LOGE("Invalid FB virtual xres: %d, xres: %d\n", - test_obj->vinfo.xres_virtual, - test_obj->vinfo.xres); - rc = MM_CAMERA_E_GENERAL; - goto FAIL; - } - - brightness_fd = open(BACKLIGHT_CONTROL, O_RDWR); - if ( brightness_fd >= 0 ) { - write(brightness_fd, brightness_level, strlen(brightness_level)); - close(brightness_fd); - } - - test_obj->slice_size = test_obj->vinfo.xres * ( test_obj->vinfo.yres - 1 ) * DEFAULT_OV_FORMAT_BPP; - memset(&test_obj->data_overlay, 0, sizeof(struct mdp_overlay)); - test_obj->data_overlay.src.width = test_obj->buffer_width; - test_obj->data_overlay.src.height = test_obj->buffer_height; - test_obj->data_overlay.src_rect.w = test_obj->buffer_width; - test_obj->data_overlay.src_rect.h = test_obj->buffer_height; - test_obj->data_overlay.dst_rect.w = test_obj->buffer_width; - test_obj->data_overlay.dst_rect.h = test_obj->buffer_height; - test_obj->data_overlay.src.format = DEFAULT_OV_FORMAT; - test_obj->data_overlay.src_rect.x = 0; - test_obj->data_overlay.src_rect.y = 0; - test_obj->data_overlay.dst_rect.x = 0; - test_obj->data_overlay.dst_rect.y = 0; - test_obj->data_overlay.z_order = 2; - test_obj->data_overlay.alpha = 0x80; - test_obj->data_overlay.transp_mask = 0xffe0; - test_obj->data_overlay.flags = MDP_FLIP_LR | MDP_FLIP_UD; - - // Map and clear FB portion - fb_base = mmap(0, - test_obj->slice_size, - PROT_WRITE, - MAP_SHARED, - test_obj->fb_fd, - 0); - if ( MAP_FAILED == fb_base ) { - LOGE("( Error while memory mapping frame buffer %s", - strerror(errno)); - rc = -errno; - goto FAIL; - } - - memset(fb_base, 0, test_obj->slice_size); - - if (ioctl(test_obj->fb_fd, FBIOPAN_DISPLAY, &test_obj->vinfo) < 0) { - LOGE("FBIOPAN_DISPLAY failed!"); - rc = -errno; - goto FAIL; - } - - munmap(fb_base, test_obj->slice_size); - test_obj->data_overlay.id = (uint32_t)MSMFB_NEW_REQUEST; - rc = ioctl(test_obj->fb_fd, MSMFB_OVERLAY_SET, &test_obj->data_overlay); - if (rc < 0) { - LOGE("MSMFB_OVERLAY_SET failed! err=%d\n", - test_obj->data_overlay.id); - return MM_CAMERA_E_GENERAL; - } - LOGE("Overlay set with overlay id: %d", test_obj->data_overlay.id); - - return rc; - -FAIL: - - if ( 0 < test_obj->fb_fd ) { - close(test_obj->fb_fd); - } - - return rc; -} - -int mm_app_close_fb(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - - assert( ( NULL != test_obj ) && ( 0 < test_obj->fb_fd ) ); - - if (ioctl(test_obj->fb_fd, MSMFB_OVERLAY_UNSET, &test_obj->data_overlay.id)) { - LOGE("\nERROR! MSMFB_OVERLAY_UNSET failed! (Line %d)\n"); - } - - if (ioctl(test_obj->fb_fd, FBIOPAN_DISPLAY, &test_obj->vinfo) < 0) { - LOGE("ERROR: FBIOPAN_DISPLAY failed! line=%d\n"); - } - - close(test_obj->fb_fd); - test_obj->fb_fd = -1; - - return rc; -} - -void memset16(void *pDst, uint16_t value, int count) -{ - uint16_t *ptr = pDst; - while (count--) - *ptr++ = value; -} - -int mm_app_overlay_display(mm_camera_test_obj_t *test_obj, int bufferFd) -{ - int rc = MM_CAMERA_OK; - struct msmfb_overlay_data ovdata; - - - memset(&ovdata, 0, sizeof(struct msmfb_overlay_data)); - ovdata.id = test_obj->data_overlay.id; - ovdata.data.memory_id = bufferFd; - - if (ioctl(test_obj->fb_fd, MSMFB_OVERLAY_PLAY, &ovdata)) { - LOGE("MSMFB_OVERLAY_PLAY failed!"); - return MM_CAMERA_E_GENERAL; - } - - if (ioctl(test_obj->fb_fd, FBIOPAN_DISPLAY, &test_obj->vinfo) < 0) { - LOGE("FBIOPAN_DISPLAY failed!"); - return MM_CAMERA_E_GENERAL; - } - - return rc; -} diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_queue.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_queue.c deleted file mode 100644 index 61176be..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_queue.c +++ /dev/null @@ -1,168 +0,0 @@ -/* Copyright (c) 2012, 2016, The Linux Foundation. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* * Neither the name of The Linux Foundation nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -// Camera dependencies -#include "mm_qcamera_app.h" -#include "mm_qcamera_dbg.h" - -int mm_camera_queue_init(mm_camera_queue_t *queue, - release_data_fn data_rel_fn, - void *user_data) -{ - if ( NULL == queue ) { - return -1; - } - - pthread_mutex_init(&queue->m_lock, NULL); - cam_list_init(&queue->m_head.list); - queue->m_size = 0; - queue->m_dataFn = data_rel_fn; - queue->m_userData = user_data; - - return MM_CAMERA_OK; -} - -int mm_qcamera_queue_release(mm_camera_queue_t *queue) -{ - if ( NULL == queue ) { - return -1; - } - - mm_qcamera_queue_flush(queue); - pthread_mutex_destroy(&queue->m_lock); - - return MM_CAMERA_OK; -} - -int mm_qcamera_queue_isempty(mm_camera_queue_t *queue) -{ - if ( NULL == queue ) { - return 0; - } - - int flag = 1; - pthread_mutex_lock(&queue->m_lock); - if (queue->m_size > 0) { - flag = 0; - } - pthread_mutex_unlock(&queue->m_lock); - - return flag; -} - -int mm_qcamera_queue_enqueue(mm_camera_queue_t *queue, void *data) -{ - if ( NULL == queue ) { - return -1; - } - - camera_q_node *node = - (camera_q_node *)malloc(sizeof(camera_q_node)); - if (NULL == node) { - LOGE(" No memory for camera_q_node"); - return 0; - } - - memset(node, 0, sizeof(camera_q_node)); - node->data = data; - - pthread_mutex_lock(&queue->m_lock); - cam_list_add_tail_node(&node->list, &queue->m_head.list); - queue->m_size++; - pthread_mutex_unlock(&queue->m_lock); - - return 1; -} - -void* mm_qcamera_queue_dequeue(mm_camera_queue_t *queue, int bFromHead) -{ - if ( NULL == queue ) { - return NULL; - } - - camera_q_node* node = NULL; - void* data = NULL; - struct cam_list *head = NULL; - struct cam_list *pos = NULL; - - pthread_mutex_lock(&queue->m_lock); - head = &queue->m_head.list; - if (bFromHead) { - pos = head->next; - } else { - pos = head->prev; - } - if (pos != head) { - node = member_of(pos, camera_q_node, list); - cam_list_del_node(&node->list); - queue->m_size--; - } - pthread_mutex_unlock(&queue->m_lock); - - if (NULL != node) { - data = node->data; - free(node); - } - - return data; -} - -void mm_qcamera_queue_flush(mm_camera_queue_t *queue) -{ - camera_q_node* node = NULL; - struct cam_list *head = NULL; - struct cam_list *pos = NULL; - - if ( NULL == queue ) { - return; - } - - pthread_mutex_lock(&queue->m_lock); - head = &queue->m_head.list; - pos = head->next; - - while(pos != head) { - node = member_of(pos, camera_q_node, list); - pos = pos->next; - cam_list_del_node(&node->list); - queue->m_size--; - - if (NULL != node->data) { - if (queue->m_dataFn) { - queue->m_dataFn(node->data, queue->m_userData); - } - free(node->data); - } - free(node); - - } - queue->m_size = 0; - pthread_mutex_unlock(&queue->m_lock); -} - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_rdi.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_rdi.c deleted file mode 100644 index 4c07f6a..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_rdi.c +++ /dev/null @@ -1,346 +0,0 @@ -/* -Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -// System dependencies -#include <fcntl.h> - -// Camera dependencies -#include "mm_qcamera_app.h" -#include "mm_qcamera_dbg.h" - -static uint32_t rdi_len = 0; - -static void mm_app_rdi_dump_frame(mm_camera_buf_def_t *frame, - char *name, - char *ext, - uint32_t frame_idx) -{ - char file_name[FILENAME_MAX]; - int file_fd; - int i; - - if (frame != NULL) { - snprintf(file_name, sizeof(file_name), - QCAMERA_DUMP_FRM_LOCATION"%s_%03u.%s", name, frame_idx, ext); - file_fd = open(file_name, O_RDWR | O_CREAT, 0777); - if (file_fd < 0) { - LOGE(" cannot open file %s \n", file_name); - } else { - for (i = 0; i < frame->planes_buf.num_planes; i++) { - write(file_fd, - (uint8_t *)frame->buffer + frame->planes_buf.planes[i].data_offset, - rdi_len); - } - - close(file_fd); - LOGD(" dump rdi frame %s", file_name); - } - } -} - -static void mm_app_rdi_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - char file_name[FILENAME_MAX]; - mm_camera_buf_def_t *frame = bufs->bufs[0]; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - - LOGD(" BEGIN - length=%zu, frame idx = %d stream_id=%d\n", - frame->frame_len, frame->frame_idx, frame->stream_id); - snprintf(file_name, sizeof(file_name), "RDI_dump_%d", pme->cam->camera_handle); - mm_app_rdi_dump_frame(frame, file_name, "raw", frame->frame_idx); - - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - LOGE(" Failed in RDI Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); - - LOGD(" END\n"); -} - -mm_camera_stream_t * mm_app_add_rdi_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - size_t i; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - cam_format_t fmt = CAM_FORMAT_MAX; - cam_stream_buf_plane_info_t *buf_planes; - cam_stream_size_info_t abc ; - memset (&abc , 0, sizeof (cam_stream_size_info_t)); - - - - LOGE(" raw_dim w:%d height:%d\n", cam_cap->raw_dim[0].width, cam_cap->raw_dim[0].height); - for (i = 0;i < cam_cap->supported_raw_fmt_cnt;i++) { - LOGE(" supported_raw_fmts[%zd]=%d\n", - i, (int)cam_cap->supported_raw_fmts[i]); - if (((CAM_FORMAT_BAYER_MIPI_RAW_8BPP_GBRG <= cam_cap->supported_raw_fmts[i]) && - (CAM_FORMAT_BAYER_MIPI_RAW_12BPP_BGGR >= cam_cap->supported_raw_fmts[i])) || - (cam_cap->supported_raw_fmts[i] == CAM_FORMAT_META_RAW_8BIT) || - (cam_cap->supported_raw_fmts[i] == CAM_FORMAT_JPEG_RAW_8BIT) || - (cam_cap->supported_raw_fmts[i] == CAM_FORMAT_BAYER_MIPI_RAW_14BPP_BGGR)) - { - fmt = cam_cap->supported_raw_fmts[i]; - LOGE(" fmt=%d\n", fmt); - } - } - - if (CAM_FORMAT_MAX == fmt) { - LOGE(" rdi format not supported\n"); - return NULL; - } - - abc.num_streams = 1; - abc.postprocess_mask[0] = 0; - abc.stream_sizes[0].width = cam_cap->raw_dim[0].width; - abc.stream_sizes[0].height = cam_cap->raw_dim[0].height; - abc.type[0] = CAM_STREAM_TYPE_RAW; - abc.buffer_info.min_buffers = num_bufs; - abc.buffer_info.max_buffers = num_bufs; - abc.is_type[0] = IS_TYPE_NONE; - - rc = setmetainfoCommand(test_obj, &abc); - if (rc != MM_CAMERA_OK) { - LOGE(" meta info command failed\n"); - } - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - LOGE(" add stream failed\n"); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.stream_cb_sync = NULL; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_RAW; - if (num_burst == 0) { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - } else { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_BURST; - stream->s_config.stream_info->num_of_burst = num_burst; - } - stream->s_config.stream_info->fmt = DEFAULT_RAW_FORMAT; - LOGD(" RAW: w: %d, h: %d ", - cam_cap->raw_dim[0].width, cam_cap->raw_dim[0].height); - - stream->s_config.stream_info->dim.width = cam_cap->raw_dim[0].width; - stream->s_config.stream_info->dim.height = cam_cap->raw_dim[0].height; - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - LOGE("config rdi stream err=%d\n", rc); - return NULL; - } - - buf_planes = &stream->s_config.stream_info->buf_planes; - rdi_len = buf_planes->plane_info.mp[0].len; - LOGD(" plane_info %dx%d len:%d frame_len:%d\n", - buf_planes->plane_info.mp[0].stride, buf_planes->plane_info.mp[0].scanline, - buf_planes->plane_info.mp[0].len, buf_planes->plane_info.frame_len); - - return stream; -} - -mm_camera_stream_t * mm_app_add_rdi_snapshot_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - LOGE(" add stream failed\n"); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.stream_cb_sync = NULL; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_SNAPSHOT; - if (num_burst == 0) { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - } else { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_BURST; - stream->s_config.stream_info->num_of_burst = num_burst; - } - stream->s_config.stream_info->fmt = DEFAULT_SNAPSHOT_FORMAT; - stream->s_config.stream_info->dim.width = DEFAULT_SNAPSHOT_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_SNAPSHOT_HEIGHT; - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - LOGE("config rdi stream err=%d\n", rc); - return NULL; - } - - return stream; -} - -mm_camera_channel_t * mm_app_add_rdi_channel(mm_camera_test_obj_t *test_obj, uint8_t num_burst) -{ - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_RDI, - NULL, - NULL, - NULL); - if (NULL == channel) { - LOGE(" add channel failed"); - return NULL; - } - - stream = mm_app_add_rdi_stream(test_obj, - channel, - mm_app_rdi_notify_cb, - (void *)test_obj, - RDI_BUF_NUM, - num_burst); - if (NULL == stream) { - LOGE(" add stream failed\n"); - mm_app_del_channel(test_obj, channel); - return NULL; - } - - LOGD(" channel=%d stream=%d\n", channel->ch_id, stream->s_id); - return channel; -} - -int mm_app_stop_and_del_rdi_channel(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - uint8_t i; - cam_stream_size_info_t abc ; - memset (&abc , 0, sizeof (cam_stream_size_info_t)); - - rc = mm_app_stop_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("Stop RDI failed rc=%d\n", rc); - } - - if (channel->num_streams <= MAX_STREAM_NUM_IN_BUNDLE) { - for (i = 0; i < channel->num_streams; i++) { - stream = &channel->streams[i]; - rc = mm_app_del_stream(test_obj, channel, stream); - if (MM_CAMERA_OK != rc) { - LOGE("del stream(%d) failed rc=%d\n", i, rc); - } - } - } else { - LOGE(" num_streams = %d. Should not be more than %d\n", - channel->num_streams, MAX_STREAM_NUM_IN_BUNDLE); - } - rc = setmetainfoCommand(test_obj, &abc); - if (rc != MM_CAMERA_OK) { - LOGE(" meta info command failed\n"); - } - rc = mm_app_del_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("delete channel failed rc=%d\n", rc); - } - - return rc; -} - -int mm_app_start_rdi(mm_camera_test_obj_t *test_obj, uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *channel = NULL; - - channel = mm_app_add_rdi_channel(test_obj, num_burst); - if (NULL == channel) { - LOGE(" add channel failed"); - return -MM_CAMERA_E_GENERAL; - } - - rc = mm_app_start_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("start rdi failed rc=%d\n", rc); - mm_app_del_channel(test_obj, channel); - return rc; - } - - return rc; -} - -int mm_app_stop_rdi(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - - mm_camera_channel_t *channel = - mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_RDI); - - rc = mm_app_stop_and_del_rdi_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("Stop RDI failed rc=%d\n", rc); - } - - return rc; -} - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_reprocess.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_reprocess.c deleted file mode 100644 index 4ed4c5d..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_reprocess.c +++ /dev/null @@ -1,349 +0,0 @@ -/* -Copyright (c) 2012-2014, 2016, The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -// Camera dependencies -#include "mm_qcamera_app.h" -#include "mm_qcamera_dbg.h" - -static void mm_app_reprocess_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - mm_camera_buf_def_t *frame = bufs->bufs[0]; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *m_stream = NULL; - mm_camera_buf_def_t *m_frame = NULL; - mm_camera_super_buf_t *src_frame; - int i = 0; - int rc = 0; - - LOGE(" BEGIN - length=%zu, frame idx = %d\n", - frame->frame_len, frame->frame_idx); - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - if (NULL == channel) { - LOGE(" Wrong channel id (%d)", bufs->ch_id); - return; - } - - // We have only one stream and buffer - // in the reprocess channel. - m_stream = &channel->streams[0]; - m_frame = bufs->bufs[0]; - - if ( pme->encodeJpeg ) { - pme->jpeg_buf.buf.buffer = (uint8_t *)malloc(m_frame->frame_len); - if ( NULL == pme->jpeg_buf.buf.buffer ) { - LOGE(" error allocating jpeg output buffer"); - goto exit; - } - - pme->jpeg_buf.buf.frame_len = m_frame->frame_len; - /* create a new jpeg encoding session */ - rc = createEncodingSession(pme, m_stream, m_frame); - if (0 != rc) { - LOGE(" error creating jpeg session"); - free(pme->jpeg_buf.buf.buffer); - goto exit; - } - - /* start jpeg encoding job */ - LOGE("Encoding reprocessed frame!!"); - rc = encodeData(pme, bufs, m_stream); - pme->encodeJpeg = 0; - } else { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - LOGE(" Failed in Reprocess Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); - } - -exit: - -// Release source frame - src_frame = ( mm_camera_super_buf_t * ) mm_qcamera_queue_dequeue(&pme->pp_frames, 1); - if ( NULL != src_frame ) { - mm_app_release_ppinput((void *) src_frame, (void *) pme); - } - - LOGE(" END\n"); -} - -mm_camera_stream_t * mm_app_add_reprocess_stream_from_source(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_stream_t *source, - mm_camera_buf_notify_t stream_cb, - cam_pp_feature_config_t pp_config, - void *userdata, - uint8_t num_bufs) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = NULL; - cam_stream_info_t *source_stream_info; - - if ( ( NULL == test_obj ) || - ( NULL == channel ) || - ( NULL == source ) ) { - LOGE(" Invalid input\n"); - return NULL; - } - - cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - LOGE(" add stream failed\n"); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.stream_cb_sync = NULL; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - source_stream_info = (cam_stream_info_t *) source->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_OFFLINE_PROC; - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - stream->s_config.stream_info->fmt = source_stream_info->fmt; - stream->s_config.stream_info->dim = source_stream_info->dim; - stream->s_config.padding_info = cam_cap->padding_info; - - - stream->s_config.stream_info->reprocess_config.pp_type = CAM_ONLINE_REPROCESS_TYPE; - stream->s_config.stream_info->reprocess_config.online.input_stream_id = source->s_config.stream_info->stream_svr_id; - stream->s_config.stream_info->reprocess_config.online.input_stream_type = source->s_config.stream_info->stream_type; - stream->s_config.stream_info->reprocess_config.pp_feature_config = pp_config; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - LOGE("config preview stream err=%d\n", rc); - return NULL; - } - - return stream; -} - -mm_camera_channel_t * mm_app_add_reprocess_channel(mm_camera_test_obj_t *test_obj, - mm_camera_stream_t *source_stream) -{ - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - - if ( NULL == source_stream ) { - LOGE(" add reprocess stream failed\n"); - return NULL; - } - - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_REPROCESS, - NULL, - NULL, - NULL); - if (NULL == channel) { - LOGE(" add channel failed"); - return NULL; - } - - // pp feature config - cam_pp_feature_config_t pp_config; - memset(&pp_config, 0, sizeof(cam_pp_feature_config_t)); - - cam_capability_t *caps = ( cam_capability_t * ) ( test_obj->cap_buf.buf.buffer ); - if (caps->qcom_supported_feature_mask & CAM_QCOM_FEATURE_SHARPNESS) { - pp_config.feature_mask |= CAM_QCOM_FEATURE_SHARPNESS; - pp_config.sharpness = test_obj->reproc_sharpness; - } - - if (test_obj->reproc_wnr.denoise_enable) { - pp_config.feature_mask |= CAM_QCOM_FEATURE_DENOISE2D; - pp_config.denoise2d = test_obj->reproc_wnr; - } - - if (test_obj->enable_CAC) { - pp_config.feature_mask |= CAM_QCOM_FEATURE_CAC; - } - - uint8_t minStreamBufNum = source_stream->num_of_bufs; - stream = mm_app_add_reprocess_stream_from_source(test_obj, - channel, - source_stream, - mm_app_reprocess_notify_cb, - pp_config, - (void *)test_obj, - minStreamBufNum); - if (NULL == stream) { - LOGE(" add reprocess stream failed\n"); - mm_app_del_channel(test_obj, channel); - return NULL; - } - test_obj->reproc_stream = stream; - - return channel; -} - -int mm_app_start_reprocess(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *r_ch = NULL; - - mm_camera_queue_init(&test_obj->pp_frames, - mm_app_release_ppinput, - ( void * ) test_obj); - - r_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_REPROCESS); - if (MM_CAMERA_OK != rc) { - LOGE(" No initialized reprocess channel d rc=%d\n", rc); - return rc; - } - - rc = mm_app_start_channel(test_obj, r_ch); - if (MM_CAMERA_OK != rc) { - LOGE("start reprocess failed rc=%d\n", rc); - mm_app_del_channel(test_obj, r_ch); - return rc; - } - - return rc; -} - -int mm_app_stop_reprocess(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *r_ch = NULL; - - r_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_REPROCESS); - if (MM_CAMERA_OK != rc) { - LOGE(" No initialized reprocess channel d rc=%d\n", rc); - return rc; - } - - rc = mm_app_stop_and_del_channel(test_obj, r_ch); - if (MM_CAMERA_OK != rc) { - LOGE("Stop Preview failed rc=%d\n", rc); - } - - mm_qcamera_queue_release(&test_obj->pp_frames); - test_obj->reproc_stream = NULL; - - return rc; -} - -int mm_app_do_reprocess(mm_camera_test_obj_t *test_obj, - mm_camera_buf_def_t *frame, - uint32_t meta_idx, - mm_camera_super_buf_t *super_buf, - mm_camera_stream_t *src_meta) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *r_ch = NULL; - mm_camera_super_buf_t *src_buf = NULL; - - if ( ( NULL == test_obj ) || - ( NULL == frame ) || - ( NULL == super_buf )) { - LOGE(" Invalid input rc=%d\n", rc); - return rc; - } - - if ( NULL == test_obj->reproc_stream ) { - LOGE(" No reprocess stream rc=%d\n", rc); - return rc; - } - - r_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_REPROCESS); - if (MM_CAMERA_OK != rc) { - LOGE(" No reprocess channel rc=%d\n", rc); - return rc; - } - - src_buf = ( mm_camera_super_buf_t * ) malloc(sizeof(mm_camera_super_buf_t)); - if ( NULL == src_buf ) { - LOGE(" No resources for src frame rc=%d\n", rc); - return -1; - } - memcpy(src_buf, super_buf, sizeof(mm_camera_super_buf_t)); - mm_qcamera_queue_enqueue(&test_obj->pp_frames, src_buf); - - cam_stream_parm_buffer_t param; - memset(¶m, 0, sizeof(cam_stream_parm_buffer_t)); - param.type = CAM_STREAM_PARAM_TYPE_DO_REPROCESS; - param.reprocess.buf_index = frame->buf_idx; - param.reprocess.frame_idx = frame->frame_idx; - if (src_meta != NULL) { - param.reprocess.meta_present = 1; - param.reprocess.meta_stream_handle = src_meta->s_config.stream_info->stream_svr_id; - param.reprocess.meta_buf_index = meta_idx; - } else { - LOGE(" No metadata source stream rc=%d\n", rc); - } - - test_obj->reproc_stream->s_config.stream_info->parm_buf = param; - rc = test_obj->cam->ops->set_stream_parms(test_obj->cam->camera_handle, - r_ch->ch_id, - test_obj->reproc_stream->s_id, - &test_obj->reproc_stream->s_config.stream_info->parm_buf); - - return rc; -} - -void mm_app_release_ppinput(void *data, void *user_data) -{ - uint32_t i = 0; - mm_camera_super_buf_t *recvd_frame = ( mm_camera_super_buf_t * ) data; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - - for ( i = 0 ; i < recvd_frame->num_bufs ; i++) { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->cam->camera_handle, - recvd_frame->ch_id, - recvd_frame->bufs[i])) { - LOGE(" Failed in Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *) recvd_frame->bufs[i]->mem_info, - ION_IOC_INV_CACHES); - } -} - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_snapshot.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_snapshot.c deleted file mode 100644 index b56e6b4..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_snapshot.c +++ /dev/null @@ -1,711 +0,0 @@ -/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -// Camera dependencies -#include "mm_qcamera_app.h" -#include "mm_qcamera_dbg.h" - -/* This callback is received once the complete JPEG encoding is done */ -static void jpeg_encode_cb(jpeg_job_status_t status, - uint32_t client_hdl, - uint32_t jobId, - mm_jpeg_output_t *p_buf, - void *userData) -{ - uint32_t i = 0; - mm_camera_test_obj_t *pme = NULL; - LOGD(" BEGIN\n"); - - pme = (mm_camera_test_obj_t *)userData; - if (pme->jpeg_hdl != client_hdl || - jobId != pme->current_job_id || - !pme->current_job_frames) { - LOGE(" NULL current job frames or not matching job ID (%d, %d)", - jobId, pme->current_job_id); - return; - } - - /* dump jpeg img */ - LOGE(" job %d, status=%d", jobId, status); - if (status == JPEG_JOB_STATUS_DONE && p_buf != NULL) { - mm_app_dump_jpeg_frame(p_buf->buf_vaddr, p_buf->buf_filled_len, "jpeg", "jpg", jobId); - } - - /* buf done current encoding frames */ - pme->current_job_id = 0; - for (i = 0; i < pme->current_job_frames->num_bufs; i++) { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(pme->current_job_frames->camera_handle, - pme->current_job_frames->ch_id, - pme->current_job_frames->bufs[i])) { - LOGE(" Failed in Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *) pme->current_job_frames->bufs[i]->mem_info, - ION_IOC_INV_CACHES); - } - - free(pme->jpeg_buf.buf.buffer); - free(pme->current_job_frames); - pme->current_job_frames = NULL; - - /* signal snapshot is done */ - mm_camera_app_done(); -} - -int encodeData(mm_camera_test_obj_t *test_obj, mm_camera_super_buf_t* recvd_frame, - mm_camera_stream_t *m_stream) -{ - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - int rc = -MM_CAMERA_E_GENERAL; - mm_jpeg_job_t job; - - /* remember current frames being encoded */ - test_obj->current_job_frames = - (mm_camera_super_buf_t *)malloc(sizeof(mm_camera_super_buf_t)); - if (!test_obj->current_job_frames) { - LOGE(" No memory for current_job_frames"); - return rc; - } - *(test_obj->current_job_frames) = *recvd_frame; - - memset(&job, 0, sizeof(job)); - job.job_type = JPEG_JOB_TYPE_ENCODE; - job.encode_job.session_id = test_obj->current_jpeg_sess_id; - - // TODO: Rotation should be set according to - // sensor&device orientation - job.encode_job.rotation = 0; - if (cam_cap->position == CAM_POSITION_BACK) { - job.encode_job.rotation = 270; - } - - /* fill in main src img encode param */ - job.encode_job.main_dim.src_dim = m_stream->s_config.stream_info->dim; - job.encode_job.main_dim.dst_dim = m_stream->s_config.stream_info->dim; - job.encode_job.src_index = 0; - - job.encode_job.thumb_dim.src_dim = m_stream->s_config.stream_info->dim; - job.encode_job.thumb_dim.dst_dim.width = DEFAULT_PREVIEW_WIDTH; - job.encode_job.thumb_dim.dst_dim.height = DEFAULT_PREVIEW_HEIGHT; - - /* fill in sink img param */ - job.encode_job.dst_index = 0; - - if (test_obj->metadata != NULL) { - job.encode_job.p_metadata = test_obj->metadata; - } else { - LOGE(" Metadata null, not set for jpeg encoding"); - } - - rc = test_obj->jpeg_ops.start_job(&job, &test_obj->current_job_id); - if ( 0 != rc ) { - free(test_obj->current_job_frames); - test_obj->current_job_frames = NULL; - } - - return rc; -} - -int createEncodingSession(mm_camera_test_obj_t *test_obj, - mm_camera_stream_t *m_stream, - mm_camera_buf_def_t *m_frame) -{ - mm_jpeg_encode_params_t encode_param; - - memset(&encode_param, 0, sizeof(mm_jpeg_encode_params_t)); - encode_param.jpeg_cb = jpeg_encode_cb; - encode_param.userdata = (void*)test_obj; - encode_param.encode_thumbnail = 0; - encode_param.quality = 85; - encode_param.color_format = MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2; - encode_param.thumb_color_format = MM_JPEG_COLOR_FORMAT_YCRCBLP_H2V2; - - /* fill in main src img encode param */ - encode_param.num_src_bufs = 1; - encode_param.src_main_buf[0].index = 0; - encode_param.src_main_buf[0].buf_size = m_frame->frame_len; - encode_param.src_main_buf[0].buf_vaddr = (uint8_t *)m_frame->buffer; - encode_param.src_main_buf[0].fd = m_frame->fd; - encode_param.src_main_buf[0].format = MM_JPEG_FMT_YUV; - encode_param.src_main_buf[0].offset = m_stream->offset; - - /* fill in sink img param */ - encode_param.num_dst_bufs = 1; - encode_param.dest_buf[0].index = 0; - encode_param.dest_buf[0].buf_size = test_obj->jpeg_buf.buf.frame_len; - encode_param.dest_buf[0].buf_vaddr = (uint8_t *)test_obj->jpeg_buf.buf.buffer; - encode_param.dest_buf[0].fd = test_obj->jpeg_buf.buf.fd; - encode_param.dest_buf[0].format = MM_JPEG_FMT_YUV; - - /* main dimension */ - encode_param.main_dim.src_dim = m_stream->s_config.stream_info->dim; - encode_param.main_dim.dst_dim = m_stream->s_config.stream_info->dim; - - return test_obj->jpeg_ops.create_session(test_obj->jpeg_hdl, - &encode_param, - &test_obj->current_jpeg_sess_id); -} - -/** mm_app_snapshot_metadata_notify_cb - * @bufs: Pointer to super buffer - * @user_data: Pointer to user data - * - * - **/ -__unused -static void mm_app_snapshot_metadata_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - uint32_t i = 0; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *p_stream = NULL; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_buf_def_t *frame; - metadata_buffer_t *pMetadata; - - if (NULL == bufs || NULL == user_data) { - LOGE(" bufs or user_data are not valid "); - return; - } - frame = bufs->bufs[0]; - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - - if (NULL == channel) { - LOGE(" Channel object is null"); - return; - } - - /* find meta stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_METADATA) { - p_stream = &channel->streams[i]; - break; - } - } - - if (NULL == p_stream) { - LOGE(" cannot find metadata stream"); - return; - } - - /* find meta frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == p_stream->s_id) { - frame = bufs->bufs[i]; - break; - } - } - - if (!pme->metadata) { - /* The app will free the metadata, we don't need to bother here */ - pme->metadata = malloc(sizeof(metadata_buffer_t)); - if (NULL == pme->metadata) { - LOGE(" malloc failed"); - return; - } - } - - memcpy(pme->metadata , frame->buffer, sizeof(metadata_buffer_t)); - - pMetadata = (metadata_buffer_t *)frame->buffer; - - IF_META_AVAILABLE(cam_auto_focus_data_t, focus_data, - CAM_INTF_META_AUTOFOCUS_DATA, pMetadata) { - if (focus_data->focus_state == CAM_AF_STATE_FOCUSED_LOCKED) { - LOGE(" AutoFocus Done Call Back Received\n"); - mm_camera_app_done(); - } else if (focus_data->focus_state == CAM_AF_STATE_NOT_FOCUSED_LOCKED) { - LOGE(" AutoFocus failed\n"); - mm_camera_app_done(); - } - } - - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - LOGE(" Failed in Preview Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); -} - -static void mm_app_snapshot_notify_cb_raw(mm_camera_super_buf_t *bufs, - void *user_data) -{ - - int rc; - uint32_t i = 0; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *m_stream = NULL; - mm_camera_buf_def_t *m_frame = NULL; - - LOGD(" BEGIN\n"); - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - if (NULL == channel) { - LOGE(" Wrong channel id (%d)", bufs->ch_id); - rc = -1; - goto EXIT; - } - - /* find snapshot stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_RAW) { - m_stream = &channel->streams[i]; - break; - } - } - if (NULL == m_stream) { - LOGE(" cannot find snapshot stream"); - rc = -1; - goto EXIT; - } - - /* find snapshot frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == m_stream->s_id) { - m_frame = bufs->bufs[i]; - break; - } - } - if (NULL == m_frame) { - LOGE(" main frame is NULL"); - rc = -1; - goto EXIT; - } - - mm_app_dump_frame(m_frame, "main", "raw", m_frame->frame_idx); - -EXIT: - for (i=0; i<bufs->num_bufs; i++) { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - bufs->bufs[i])) { - LOGE(" Failed in Qbuf\n"); - } - } - - mm_camera_app_done(); - - LOGD(" END\n"); -} - -static void mm_app_snapshot_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - - int rc = 0; - uint32_t i = 0; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *p_stream = NULL; - mm_camera_stream_t *m_stream = NULL; - mm_camera_buf_def_t *p_frame = NULL; - mm_camera_buf_def_t *m_frame = NULL; - - /* find channel */ - for (i = 0; i < MM_CHANNEL_TYPE_MAX; i++) { - if (pme->channels[i].ch_id == bufs->ch_id) { - channel = &pme->channels[i]; - break; - } - } - if (NULL == channel) { - LOGE(" Wrong channel id (%d)", bufs->ch_id); - rc = -1; - goto error; - } - - /* find snapshot stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_SNAPSHOT) { - m_stream = &channel->streams[i]; - break; - } - } - if (NULL == m_stream) { - LOGE(" cannot find snapshot stream"); - rc = -1; - goto error; - } - - /* find snapshot frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == m_stream->s_id) { - m_frame = bufs->bufs[i]; - break; - } - } - if (NULL == m_frame) { - LOGE(" main frame is NULL"); - rc = -1; - goto error; - } - - mm_app_dump_frame(m_frame, "main", "yuv", m_frame->frame_idx); - - /* find postview stream */ - for (i = 0; i < channel->num_streams; i++) { - if (channel->streams[i].s_config.stream_info->stream_type == CAM_STREAM_TYPE_POSTVIEW) { - p_stream = &channel->streams[i]; - break; - } - } - if (NULL != p_stream) { - /* find preview frame */ - for (i = 0; i < bufs->num_bufs; i++) { - if (bufs->bufs[i]->stream_id == p_stream->s_id) { - p_frame = bufs->bufs[i]; - break; - } - } - if (NULL != p_frame) { - mm_app_dump_frame(p_frame, "postview", "yuv", p_frame->frame_idx); - } - } - - mm_app_cache_ops((mm_camera_app_meminfo_t *)m_frame->mem_info, - ION_IOC_CLEAN_INV_CACHES); - - pme->jpeg_buf.buf.buffer = (uint8_t *)malloc(m_frame->frame_len); - if ( NULL == pme->jpeg_buf.buf.buffer ) { - LOGE(" error allocating jpeg output buffer"); - goto error; - } - - pme->jpeg_buf.buf.frame_len = m_frame->frame_len; - /* create a new jpeg encoding session */ - rc = createEncodingSession(pme, m_stream, m_frame); - if (0 != rc) { - LOGE(" error creating jpeg session"); - free(pme->jpeg_buf.buf.buffer); - goto error; - } - - /* start jpeg encoding job */ - rc = encodeData(pme, bufs, m_stream); - if (0 != rc) { - LOGE(" error creating jpeg session"); - free(pme->jpeg_buf.buf.buffer); - goto error; - } - -error: - /* buf done rcvd frames in error case */ - if ( 0 != rc ) { - for (i=0; i<bufs->num_bufs; i++) { - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - bufs->bufs[i])) { - LOGE(" Failed in Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)bufs->bufs[i]->mem_info, - ION_IOC_INV_CACHES); - } - } - - LOGD(" END\n"); -} - -mm_camera_channel_t * mm_app_add_snapshot_channel(mm_camera_test_obj_t *test_obj) -{ - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_SNAPSHOT, - NULL, - NULL, - NULL); - if (NULL == channel) { - LOGE(" add channel failed"); - return NULL; - } - - stream = mm_app_add_snapshot_stream(test_obj, - channel, - mm_app_snapshot_notify_cb, - (void *)test_obj, - 1, - 1); - if (NULL == stream) { - LOGE(" add snapshot stream failed\n"); - mm_app_del_channel(test_obj, channel); - return NULL; - } - - return channel; -} - -mm_camera_stream_t * mm_app_add_postview_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs, - uint8_t num_burst) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - LOGE(" add stream failed\n"); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.stream_cb_sync = NULL; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_POSTVIEW; - if (num_burst == 0) { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - } else { - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_BURST; - stream->s_config.stream_info->num_of_burst = num_burst; - } - stream->s_config.stream_info->fmt = DEFAULT_PREVIEW_FORMAT; - stream->s_config.stream_info->dim.width = DEFAULT_PREVIEW_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_PREVIEW_HEIGHT; - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - LOGE("config postview stream err=%d\n", rc); - return NULL; - } - - return stream; -} - -int mm_app_start_capture_raw(mm_camera_test_obj_t *test_obj, uint8_t num_snapshots) -{ - int32_t rc = MM_CAMERA_OK; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *s_main = NULL; - mm_camera_channel_attr_t attr; - - memset(&attr, 0, sizeof(mm_camera_channel_attr_t)); - attr.notify_mode = MM_CAMERA_SUPER_BUF_NOTIFY_BURST; - attr.max_unmatched_frames = 3; - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_CAPTURE, - &attr, - mm_app_snapshot_notify_cb_raw, - test_obj); - if (NULL == channel) { - LOGE(" add channel failed"); - return -MM_CAMERA_E_GENERAL; - } - - test_obj->buffer_format = DEFAULT_RAW_FORMAT; - s_main = mm_app_add_raw_stream(test_obj, - channel, - mm_app_snapshot_notify_cb_raw, - test_obj, - num_snapshots, - num_snapshots); - if (NULL == s_main) { - LOGE(" add main snapshot stream failed\n"); - mm_app_del_channel(test_obj, channel); - return rc; - } - - rc = mm_app_start_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("start zsl failed rc=%d\n", rc); - mm_app_del_stream(test_obj, channel, s_main); - mm_app_del_channel(test_obj, channel); - return rc; - } - - return rc; -} - -int mm_app_stop_capture_raw(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *ch = NULL; - int i; - cam_stream_size_info_t abc ; - memset (&abc , 0, sizeof (cam_stream_size_info_t)); - - ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_CAPTURE); - - rc = mm_app_stop_channel(test_obj, ch); - if (MM_CAMERA_OK != rc) { - LOGE("stop recording failed rc=%d\n", rc); - } - - for ( i = 0 ; i < ch->num_streams ; i++ ) { - mm_app_del_stream(test_obj, ch, &ch->streams[i]); - } - rc = setmetainfoCommand(test_obj, &abc); - if (rc != MM_CAMERA_OK) { - LOGE(" meta info command failed\n"); - } - mm_app_del_channel(test_obj, ch); - - return rc; -} - -int mm_app_start_capture(mm_camera_test_obj_t *test_obj, - uint8_t num_snapshots) -{ - int32_t rc = MM_CAMERA_OK; - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *s_main = NULL; - mm_camera_stream_t *s_post = NULL; - mm_camera_channel_attr_t attr; - memset(&attr, 0, sizeof(mm_camera_channel_attr_t)); - attr.notify_mode = MM_CAMERA_SUPER_BUF_NOTIFY_CONTINUOUS; - attr.max_unmatched_frames = 3; - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_CAPTURE, - &attr, - mm_app_snapshot_notify_cb, - test_obj); - if (NULL == channel) { - LOGE(" add channel failed"); - return -MM_CAMERA_E_GENERAL; - } - - s_main = mm_app_add_snapshot_stream(test_obj, - channel, - mm_app_snapshot_notify_cb, - (void *)test_obj, - CAPTURE_BUF_NUM, - num_snapshots); - if (NULL == s_main) { - LOGE(" add main snapshot stream failed\n"); - mm_app_del_channel(test_obj, channel); - return rc; - } - - s_post = mm_app_add_postview_stream(test_obj, - channel, - NULL, - NULL, - CAPTURE_BUF_NUM, - num_snapshots); - if (NULL == s_main) { - LOGE(" add main postview stream failed\n"); - mm_app_del_channel(test_obj, channel); - return rc; - } - - rc = mm_app_start_channel(test_obj, channel); - if (MM_CAMERA_OK != rc) { - LOGE("start zsl failed rc=%d\n", rc); - mm_app_del_stream(test_obj, channel, s_main); - mm_app_del_channel(test_obj, channel); - return rc; - } - - return rc; -} - -int mm_app_stop_capture(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *ch = NULL; - - ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_CAPTURE); - - rc = mm_app_stop_and_del_channel(test_obj, ch); - if (MM_CAMERA_OK != rc) { - LOGE("stop capture channel failed rc=%d\n", rc); - } - - return rc; -} - -int mm_app_take_picture(mm_camera_test_obj_t *test_obj, uint8_t is_burst_mode) -{ - LOGH("\nEnter %s!!\n"); - int rc = MM_CAMERA_OK; - uint8_t num_snapshot = 1; - int num_rcvd_snapshot = 0; - - if (is_burst_mode) - num_snapshot = 6; - - //stop preview before starting capture. - rc = mm_app_stop_preview(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" stop preview failed before capture!!, err=%d\n", rc); - return rc; - } - - rc = mm_app_start_capture(test_obj, num_snapshot); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_start_capture(), err=%d\n", rc); - return rc; - } - while (num_rcvd_snapshot < num_snapshot) { - LOGH("\nWaiting mm_camera_app_wait !!\n"); - mm_camera_app_wait(); - num_rcvd_snapshot++; - } - rc = mm_app_stop_capture(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_stop_capture(), err=%d\n", rc); - return rc; - } - //start preview after capture. - rc = mm_app_start_preview(test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" start preview failed after capture!!, err=%d\n",rc); - } - return rc; -} diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_socket.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_socket.c deleted file mode 100644 index 81c377f..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_socket.c +++ /dev/null @@ -1,881 +0,0 @@ -/* Copyright (c) 2012-2014, 2016, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -// System dependencies -#include <errno.h> -#include <sys/socket.h> -#include <fcntl.h> - -// Camera dependencies -#include "mm_qcamera_socket.h" -#include "mm_qcamera_commands.h" -#include "mm_qcamera_dbg.h" - -#define IP_ADDR "127.0.0.1" -#define TUNING_CHROMATIX_PORT 55555 -#define TUNING_PREVIEW_PORT 55556 - -#define CURRENT_COMMAND_ACK_SUCCESS 1 -#define CURRENT_COMMAND_ACK_FAILURE 2 - -pthread_t eztune_thread_id; - -static ssize_t tuneserver_send_command_rsp(tuningserver_t *tsctrl, - char *send_buf, uint32_t send_len) -{ - ssize_t rc; - - /* send ack back to client upon req */ - if (send_len <= 0) { - LOGE("Invalid send len \n"); - return -1; - } - if (send_buf == NULL) { - LOGE("Invalid send buf \n"); - return -1; - } - - rc = send(tsctrl->clientsocket_id, send_buf, send_len, 0); - if (rc < 0) { - LOGE("RSP send returns error %s\n", strerror(errno)); - } else { - rc = 0; - } - - if (send_buf != NULL) { - free(send_buf); - send_buf = NULL; - } - return rc; -} - -static void release_eztune_prevcmd_rsp(eztune_prevcmd_rsp *pHead) -{ - if (pHead != NULL ) { - release_eztune_prevcmd_rsp((eztune_prevcmd_rsp *)pHead->next); - free(pHead); - } -} - -static ssize_t tuneserver_ack(uint16_t a, uint32_t b, tuningserver_t *tsctrl) -{ - ssize_t rc; - char ack_1[6]; - /*Ack the command here*/ - memcpy(ack_1, &a, 2); - memcpy(ack_1+2, &b, 4); - /* send echo back to client upon accept */ - rc = send(tsctrl->clientsocket_id, &ack_1, sizeof(ack_1), 0); - if (rc < 0) { - LOGE(" eztune_server_run: send returns error %s\n", - strerror(errno)); - return rc; - } else if (rc < (int32_t)sizeof(ack_1)) { - /*Shouldn't hit this for packets <1K; need to re-send if we do*/ - } - return 0; -} - -static ssize_t tuneserver_send_command_ack( uint8_t ack, - tuningserver_t *tsctrl) -{ - ssize_t rc; - /* send ack back to client upon req */ - rc = send(tsctrl->clientsocket_id, &ack, sizeof(ack), 0); - if (rc < 0) { - LOGE("ACK send returns error %s\n", strerror(errno)); - return rc; - } - return 0; -} - -/** tuneserver_process_command - * @tsctrl: the server control object - * - * Processes the command that the client sent - * - * Return: >=0 on success, -1 on failure. - **/ -static int32_t tuneserver_process_command(tuningserver_t *tsctrl, - char *send_buf, uint32_t send_len) -{ - tuneserver_protocol_t *p = tsctrl->proto; - int result = 0; - - LOGD(" Current command is %d\n", p->current_cmd); - switch (p->current_cmd) { - case TUNESERVER_GET_LIST: - if(tuneserver_send_command_ack(CURRENT_COMMAND_ACK_SUCCESS, tsctrl)) { - LOGE(" Ack Failed for cmd %d\n", p->current_cmd); - return -1; - } - result = tuneserver_process_get_list_cmd(tsctrl, p->recv_buf, - send_buf, send_len); - if (result < 0) { - LOGE(" RSP processing Failed for cmd %d\n", p->current_cmd); - return -1; - } - if(tuneserver_send_command_rsp(tsctrl, send_buf, send_len)) { - LOGE(" RSP Failed for cmd %d\n", p->current_cmd); - return -1; - } - break; - - case TUNESERVER_GET_PARMS: - if(tuneserver_send_command_ack(CURRENT_COMMAND_ACK_SUCCESS, tsctrl)) { - LOGE(" Ack Failed for cmd %d\n", p->current_cmd); - return -1; - } - result = tuneserver_process_get_params_cmd(tsctrl, p->recv_buf, - send_buf, send_len); - if (result < 0) { - LOGE(" RSP processing Failed for cmd %d\n", p->current_cmd); - return -1; - } - if(tuneserver_send_command_rsp(tsctrl, send_buf, send_len)) { - LOGE(" RSP Failed for cmd %d\n", p->current_cmd); - return -1; - } - break; - - case TUNESERVER_SET_PARMS: - if(tuneserver_send_command_ack(CURRENT_COMMAND_ACK_SUCCESS, tsctrl)) { - LOGE(" Ack Failed for cmd %d\n", p->current_cmd); - return -1; - } - result = tuneserver_process_set_params_cmd(tsctrl, p->recv_buf, - send_buf, send_len); - if (result < 0) { - LOGE(" RSP processing Failed for cmd %d\n", p->current_cmd); - return -1; - } - if(tuneserver_send_command_rsp(tsctrl, send_buf, send_len)) { - LOGE(" RSP Failed for cmd %d\n", p->current_cmd); - return -1; - } - break; - - case TUNESERVER_MISC_CMDS: { - if(tuneserver_send_command_ack(CURRENT_COMMAND_ACK_SUCCESS, tsctrl)) { - LOGE(" Ack Failed for cmd %d\n", p->current_cmd); - return -1; - } - result = tuneserver_process_misc_cmd(tsctrl, p->recv_buf, - send_buf, send_len); - if (result < 0) { - LOGE(" RSP processing Failed for cmd %d\n", p->current_cmd); - return -1; - } - if(tuneserver_send_command_rsp(tsctrl, send_buf, send_len)) { - LOGE(" RSP Failed for cmd %d\n", p->current_cmd); - return -1; - } - break; - } - - default: - if(tuneserver_send_command_ack(CURRENT_COMMAND_ACK_SUCCESS, tsctrl)) { - LOGE(" Ack Failed for cmd %d\n", p->current_cmd); - return -1; - } - LOGE(" p->current_cmd: default\n"); - result = -1; - break; - } - - return result; -} - -/** tuneserver_process_client_message - * @recv_buffer: received message from the client - * @tsctrl: the server control object - * - * Processes the message from client and prepares for next - * message. - * - * Return: >=0 on success, -1 on failure. - **/ -static int32_t tuneserver_process_client_message(void *recv_buffer, - tuningserver_t *tsctrl) -{ - int rc = 0; - tuneserver_protocol_t *p = tsctrl->proto; - - switch (tsctrl->proto->next_recv_code) { - case TUNESERVER_RECV_COMMAND: - p->current_cmd = *(uint16_t *)recv_buffer; - p->next_recv_code = TUNESERVER_RECV_PAYLOAD_SIZE; - p->next_recv_len = sizeof(uint32_t); - break; - - case TUNESERVER_RECV_PAYLOAD_SIZE: - p->next_recv_code = TUNESERVER_RECV_PAYLOAD; - p->next_recv_len = *(uint32_t *)recv_buffer; - p->recv_len = p->next_recv_len; - if (p->next_recv_len > TUNESERVER_MAX_RECV) - return -1; - if (p->next_recv_len == 0) { - p->next_recv_code = TUNESERVER_RECV_RESPONSE; - p->next_recv_len = sizeof(uint32_t); - } - break; - - case TUNESERVER_RECV_PAYLOAD: - p->recv_buf = malloc(p->next_recv_len); - if (!p->recv_buf) { - LOGE("Error allocating memory for recv_buf %s\n", - strerror(errno)); - return -1; - } - memcpy(p->recv_buf, recv_buffer, p->next_recv_len); - p->next_recv_code = TUNESERVER_RECV_RESPONSE; - p->next_recv_len = sizeof(uint32_t); - /*Process current command at this point*/ - break; - - case TUNESERVER_RECV_RESPONSE: - p->next_recv_code = TUNESERVER_RECV_COMMAND; - p->next_recv_len = 2; - p->send_len = *(uint32_t *)recv_buffer; - p->send_buf = (char *)calloc(p->send_len, sizeof(char *)); - if (!p->send_buf) { - LOGE("Error allocating memory for send_buf %s\n", - strerror(errno)); - return -1; - } - rc = tuneserver_process_command(tsctrl, p->send_buf, p->send_len); - free(p->recv_buf); - p->recv_buf = NULL; - p->recv_len = 0; - break; - - default: - LOGE(" p->next_recv_code: default\n"); - rc = -1; - break; - } - - return rc; -} - -/** tuneserver_ack_onaccept_initprotocol - * @tsctrl: the server control object - * - * Acks a connection from the cient and sets up the - * protocol object to start receiving commands. - * - * Return: >=0 on success, -1 on failure. - **/ -static ssize_t tuneserver_ack_onaccept_initprotocol(tuningserver_t *tsctrl) -{ - ssize_t rc = 0; - uint32_t ack_status; - - LOGE("starts\n"); -/* - if(tsctrl->camera_running) { - ack_status = 1; - } else { - ack_status = 2; - } -*/ - ack_status = 1; - - rc = tuneserver_ack(1, ack_status, tsctrl); - - tsctrl->proto = malloc(sizeof(tuneserver_protocol_t)); - if (!tsctrl->proto) { - LOGE(" malloc returns NULL with error %s\n", strerror(errno)); - return -1; - } - - tsctrl->proto->current_cmd = 0xFFFF; - tsctrl->proto->next_recv_code = TUNESERVER_RECV_COMMAND; - tsctrl->proto->next_recv_len = 2; - tsctrl->proto->recv_buf = NULL; - tsctrl->proto->send_buf = NULL; - - LOGD("X\n"); - - return rc; -} - -/** tuneserver_check_status - * @tsctrl: the server control object - * - * Checks if camera is running and stops it. - * - * Return: >=0 on success, -1 on failure. - **/ -#if 0 -static void tuneserver_check_status(tuningserver_t *tsctrl) -{ - if (tsctrl->camera_running == 1) { - /*TODO: Stop camera here*/ - tuneserver_stop_cam(&tsctrl->lib_handle); - } - tsctrl->camera_running = 0; - - tuneserver_close_cam(&tsctrl->lib_handle); -} -#endif - -static ssize_t prevserver_send_command_rsp(tuningserver_t *tsctrl, - char *send_buf, uint32_t send_len) -{ - ssize_t rc; - - /* send ack back to client upon req */ - if (send_len <= 0) { - LOGE("Invalid send len \n"); - return -1; - } - if (send_buf == NULL) { - LOGE("Invalid send buf \n"); - return -1; - } - - rc = send(tsctrl->pr_clientsocket_id, send_buf, send_len, 0); - if (rc < 0) { - LOGE("RSP send returns error %s\n", strerror(errno)); - } else { - rc = 0; - } - if (send_buf != NULL) { - free(send_buf); - send_buf = NULL; - } - return rc; -} - -static void prevserver_init_protocol(tuningserver_t *tsctrl) -{ - tsctrl->pr_proto = malloc(sizeof(prserver_protocol_t)); - if (!tsctrl->pr_proto) { - LOGE(" malloc returns NULL with error %s\n", - strerror(errno)); - return; - } - - tsctrl->pr_proto->current_cmd = 0xFFFF; - tsctrl->pr_proto->next_recv_code = TUNE_PREV_RECV_COMMAND; - tsctrl->pr_proto->next_recv_len = 2; -} - -static int32_t prevserver_process_command( - tuningserver_t *tsctrl, char **send_buf, uint32_t *send_len) -{ - prserver_protocol_t *p = tsctrl->pr_proto; - int result = 0; - eztune_prevcmd_rsp *rsp_ptr=NULL, *rspn_ptr=NULL, *head_ptr=NULL; - - LOGD(" Current command is %d\n", p->current_cmd); - switch (p->current_cmd) { - case TUNE_PREV_GET_INFO: - result = tuneserver_preview_getinfo(tsctrl, send_buf, send_len); - if (result < 0) { - LOGE(" RSP processing Failed for cmd %d\n", - p->current_cmd); - return -1; - } - rsp_ptr = (eztune_prevcmd_rsp *)*send_buf; - if ((!rsp_ptr) || (!rsp_ptr->send_buf)) { - LOGE(" RSP ptr is NULL %d\n", p->current_cmd); - return -1; - } - if (prevserver_send_command_rsp(tsctrl, - rsp_ptr->send_buf, rsp_ptr->send_len)) { - LOGE(" RSP Failed for TUNE_PREV_GET_INFO ver cmd %d\n", - p->current_cmd); - return -1; - } - rspn_ptr = (eztune_prevcmd_rsp *)rsp_ptr->next; - if ((!rspn_ptr) || (!rspn_ptr->send_buf)) { - LOGE(" RSP1 ptr is NULL %d\n", p->current_cmd); - return -1; - } - if (prevserver_send_command_rsp(tsctrl, - rspn_ptr->send_buf, rspn_ptr->send_len)) { - LOGE(" RSP Failed for TUNE_PREV_GET_INFO caps cmd %d\n", - p->current_cmd); - return -1; - } - free(rspn_ptr); - free(rsp_ptr); - break; - - case TUNE_PREV_CH_CNK_SIZE: - result = tuneserver_preview_getchunksize(tsctrl, send_buf, send_len); - if (result < 0) { - LOGE(" RSP processing Failed for cmd %d\n", p->current_cmd); - return -1; - } - if (prevserver_send_command_rsp(tsctrl, *send_buf, *send_len)) { - LOGE(" RSP Failed for TUNE_PREV_CH_CNK_SIZE cmd %d\n", - p->current_cmd); - return -1; - } - break; - - case TUNE_PREV_GET_PREV_FRAME: - result = tuneserver_preview_getframe(tsctrl, send_buf, send_len); - if (result < 0) { - LOGE(" RSP processing Failed for cmd %d\n", p->current_cmd); - return -1; - } - rsp_ptr = (eztune_prevcmd_rsp *)*send_buf; - if ((!rsp_ptr) || (!rsp_ptr->send_buf)) { - LOGE(" RSP ptr is NULL %d\n", p->current_cmd); - return -1; - } - head_ptr = rsp_ptr; - - while (rsp_ptr != NULL) { - if ((!rsp_ptr) || (!rsp_ptr->send_buf)) { - LOGE(" RSP ptr is NULL %d\n", p->current_cmd); - return -1; - } - if (prevserver_send_command_rsp(tsctrl, - rsp_ptr->send_buf, rsp_ptr->send_len)) { - LOGE(" RSP Failed for TUNE_PREV_GET_INFO ver cmd %d\n", - p->current_cmd); - return -1; - } - rsp_ptr = (eztune_prevcmd_rsp *)rsp_ptr->next; - } - release_eztune_prevcmd_rsp(head_ptr); - break; - - case TUNE_PREV_GET_JPG_SNAP: - case TUNE_PREV_GET_RAW_SNAP: - case TUNE_PREV_GET_RAW_PREV: - result = tuneserver_preview_unsupported(tsctrl, send_buf, send_len); - if (result < 0) { - LOGE("RSP processing Failed for cmd %d\n", p->current_cmd); - return -1; - } - if (prevserver_send_command_rsp(tsctrl, *send_buf, *send_len)) { - LOGE("RSP Failed for UNSUPPORTED cmd %d\n", p->current_cmd); - return -1; - } - break; - - default: - LOGE(" p->current_cmd: default\n"); - result = -1; - break; - } - - return result; -} - -/** previewserver_process_client_message - * @recv_buffer: received message from the client - * @tsctrl: the server control object - * - * Processes the message from client and prepares for next - * message. - * - * Return: >=0 on success, -1 on failure. - **/ -static int32_t prevserver_process_client_message(void *recv_buffer, - tuningserver_t *tsctrl) -{ - int rc = 0; - prserver_protocol_t *p = tsctrl->pr_proto; - - LOGD("command = %d", p->next_recv_code); - - switch (p->next_recv_code) { - case TUNE_PREV_RECV_COMMAND: - p->current_cmd = *(uint16_t *)recv_buffer; - if(p->current_cmd != TUNE_PREV_CH_CNK_SIZE) { - rc = prevserver_process_command(tsctrl, - &p->send_buf, (uint32_t *)&p->send_len); - break; - } - p->next_recv_code = TUNE_PREV_RECV_NEWCNKSIZE; - p->next_recv_len = sizeof(uint32_t); - LOGD("TUNE_PREV_COMMAND X\n"); - break; - case TUNE_PREV_RECV_NEWCNKSIZE: - p->new_cnk_size = *(uint32_t *)recv_buffer; - p->next_recv_code = TUNE_PREV_RECV_COMMAND; - p->next_recv_len = 2; - rc = prevserver_process_command(tsctrl, - &p->send_buf, (uint32_t *)&p->send_len); - break; - default: - LOGE("prev_proc->next_recv_code: default\n"); - rc = -1; - break; - } - - return rc; -} - -/** tunning_server_socket_listen - * @ip_addr: the ip addr to listen - * @port: the port to listen - * - * Setup a listen socket for eztune. - * - * Return: >0 on success, <=0 on failure. - **/ -int tunning_server_socket_listen(const char* ip_addr, uint16_t port) -{ - int sock_fd = -1; - mm_qcamera_sock_addr_t server_addr; - int result; - int option; - int socket_flag; - - memset(&server_addr, 0, sizeof(server_addr)); - server_addr.addr_in.sin_family = AF_INET; - server_addr.addr_in.sin_port = (__be16) htons(port); - server_addr.addr_in.sin_addr.s_addr = inet_addr(ip_addr); - - if (server_addr.addr_in.sin_addr.s_addr == INADDR_NONE) { - LOGE(" invalid address.\n"); - return -1; - } - - /* Create an AF_INET stream socket to receive incoming connection ON */ - sock_fd = socket(AF_INET, SOCK_STREAM, 0); - if (sock_fd < 0) { - LOGE(" socket failed\n"); - return sock_fd; - } - - // set listen socket to non-block, but why?? - socket_flag = fcntl(sock_fd, F_GETFL, 0); - fcntl(sock_fd, F_SETFL, socket_flag | O_NONBLOCK); - - /* reuse in case it is in timeout */ - option = 1; - result = setsockopt(sock_fd, SOL_SOCKET, SO_REUSEADDR, - &option, sizeof(option)); - - if (result < 0) { - LOGE("eztune setsockopt failed"); - close(sock_fd); - sock_fd = -1; - return sock_fd; - } - - result = bind(sock_fd, &server_addr.addr, sizeof(server_addr.addr_in)); - if (result < 0) { - LOGE("eztune socket bind failed"); - close(sock_fd); - sock_fd = -1; - return sock_fd; - } - - result = listen(sock_fd, 1); - if (result < 0) { - LOGE("eztune socket listen failed"); - close(sock_fd); - sock_fd = -1; - return sock_fd; - } - - LOGH("sock_fd: %d, listen at port: %d\n", sock_fd, port); - - return sock_fd; -} - -/** main - * - * Creates the server, and starts waiting for - * connections/messages from a prospective - * client - * - **/ -void *eztune_proc(void *data) -{ - int server_socket = -1, client_socket = -1; - int prev_server_socket = -1, prev_client_socket = -1; - - mm_qcamera_sock_addr_t addr_client_inet; - socklen_t addr_client_len = sizeof(addr_client_inet.addr_in); - int result; - fd_set tsfds; - int num_fds = 0; - ssize_t recv_bytes; - char buf[TUNESERVER_MAX_RECV]; - - mm_camera_lib_handle *lib_handle = (mm_camera_lib_handle *)data; - - LOGE(">>> Starting tune server <<< \n"); - - // for eztune chromatix params - server_socket = tunning_server_socket_listen(IP_ADDR, TUNING_CHROMATIX_PORT); - if (server_socket <= 0) { - LOGE("[ERR] fail to setup listen socket for eztune chromatix parms..."); - return NULL; - } - prev_server_socket = tunning_server_socket_listen(IP_ADDR, TUNING_PREVIEW_PORT); - if (prev_server_socket <= 0) { - LOGE("[ERR] fail to setup listen socket for eztune preview...\n"); - return NULL; - } - num_fds = TUNESERVER_MAX(server_socket, prev_server_socket); - LOGH("num_fds = %d\n", num_fds); - - do { - FD_ZERO(&tsfds); - FD_SET(server_socket, &tsfds); - FD_SET(prev_server_socket, &tsfds); - if (client_socket > 0) { - FD_SET(client_socket, &tsfds); - } - if (prev_client_socket > 0) { - FD_SET( prev_client_socket, &tsfds); - } - - /* no timeout */ - result = select(num_fds + 1, &tsfds, NULL, NULL, NULL); - if (result < 0) { - LOGE("select failed: %s\n", strerror(errno)); - continue; - } - - /* - ** (1) CHROMATIX SERVER - */ - if (FD_ISSET(server_socket, &tsfds)) { - LOGD("Receiving New client connection\n"); - - client_socket = accept(server_socket, - &addr_client_inet.addr, &addr_client_len); - if (client_socket == -1) { - LOGE("accept failed %s", strerror(errno)); - continue; - } - - if (client_socket >= FD_SETSIZE) { - LOGE("client_socket is out of range. client_socket=%d",client_socket); - continue; - } - - LOGE("accept a new connect on 55555, sd(%d)\n", client_socket); - num_fds = TUNESERVER_MAX(num_fds, client_socket); - - // open camera and get handle - this is needed to - // be able to set parameters without starting - // preview stream - /*if (!tsctrl.camera_running) { - result = tuneserver_open_cam(&tsctrl.lib_handle, &tsctrl); - if(result) { - printf("\n Camera Open Fail !!! \n"); - close(server_socket); - return EXIT_FAILURE; - } - }*/ - result = tuneserver_open_cam(lib_handle); - if(result) { - LOGE("\n Tuning Library open failed!!!\n"); - close(server_socket); - return NULL; - } - lib_handle->tsctrl.clientsocket_id = client_socket; - if (tuneserver_ack_onaccept_initprotocol(&lib_handle->tsctrl) < 0) { - LOGE(" Error while acking\n"); - close(client_socket); - continue; - } - tuneserver_initialize_tuningp(lib_handle, client_socket, - lib_handle->tsctrl.proto->send_buf, lib_handle->tsctrl.proto->send_len); - } - - if ((client_socket < FD_SETSIZE) && (FD_ISSET(client_socket, &tsfds))) { - if (lib_handle->tsctrl.proto == NULL) { - LOGE(" Cannot receive msg without connect\n"); - continue; - } - - /*Receive message and process it*/ - recv_bytes = recv(client_socket, (void *)buf, - lib_handle->tsctrl.proto->next_recv_len, 0); - LOGD("Receive %lld bytes \n", (long long int) recv_bytes); - - if (recv_bytes == -1) { - LOGE(" Receive failed with error %s\n", strerror(errno)); - //tuneserver_check_status(&tsctrl); - continue; - } else if (recv_bytes == 0) { - LOGE("connection has been terminated\n"); - - tuneserver_deinitialize_tuningp(&lib_handle->tsctrl, client_socket, - lib_handle->tsctrl.proto->send_buf, - lib_handle->tsctrl.proto->send_len); - free(lib_handle->tsctrl.proto); - lib_handle->tsctrl.proto = NULL; - - close(client_socket); - client_socket = -1; - //tuneserver_check_status(&tsctrl); - } else { - LOGD(" Processing socket command\n"); - - result = tuneserver_process_client_message(buf, &lib_handle->tsctrl); - - if (result < 0) { - LOGE("Protocol violated\n"); - - free(lib_handle->tsctrl.proto); - lib_handle->tsctrl.proto = NULL; - - close(client_socket); - client_socket = -1; - //tuneserver_check_status(&tsctrl); - continue; - } - } - } - - /* - ** (2) PREVIEW SERVER - */ - if (FD_ISSET(prev_server_socket, &tsfds)) { - LOGD("Receiving New Preview client connection\n"); - - prev_client_socket = accept(prev_server_socket, - &addr_client_inet.addr, &addr_client_len); - if (prev_client_socket == -1) { - LOGE("accept failed %s", strerror(errno)); - continue; - } - if (prev_client_socket >= FD_SETSIZE) { - LOGE("prev_client_socket is out of range. prev_client_socket=%d",prev_client_socket); - continue; - } - - lib_handle->tsctrl.pr_clientsocket_id = prev_client_socket; - - LOGD("Accepted a new connection, fd(%d)\n", prev_client_socket); - num_fds = TUNESERVER_MAX(num_fds, prev_client_socket); - - // start camera - /*if (!tsctrl.camera_running) { - result = 0; - result = tuneserver_open_cam(&tsctrl.lib_handle, &tsctrl); - if(result) { - printf("\n Camera Open Fail !!! \n"); - return EXIT_FAILURE; - } - }*/ - cam_dimension_t dim; - //dim.width = lib_handle->test_obj.buffer_width; - //dim.height = lib_handle->test_obj.buffer_height; - dim.width = DEFAULT_PREVIEW_WIDTH; - dim.height = DEFAULT_PREVIEW_HEIGHT; - - LOGD("preview dimension info: w(%d), h(%d)\n", dim.width, dim.height); - // we have to make sure that camera is running, before init connection, - // because we need to know the frame size for allocating the memory. - prevserver_init_protocol(&lib_handle->tsctrl); - - result = tuneserver_initialize_prevtuningp(lib_handle, prev_client_socket, - dim, (char **)&lib_handle->tsctrl.proto->send_buf, - &lib_handle->tsctrl.proto->send_len); - if (result < 0) { - LOGE("tuneserver_initialize_prevtuningp error!"); - close(prev_client_socket); - prev_client_socket = -1; - } - } - - if ((prev_client_socket < FD_SETSIZE) && (FD_ISSET(prev_client_socket, &tsfds))) { - recv_bytes = recv(prev_client_socket, (void *)buf, - lib_handle->tsctrl.pr_proto->next_recv_len, 0); - - LOGD("prev_client_socket=%d\n", prev_client_socket); - LOGD("next_recv_len=%d\n", buf[0]+buf[1]*256); - - if (recv_bytes <= 0) { - if (recv_bytes == 0) { - LOGE("client close the connection.\n"); - } else { - LOGE("receive error: %s\n", strerror(errno)); - } - - //tuneserver_check_status(&tsctrl); - // if recv error, we should close the connection, free the proto data, - // AND wait for a new connecton.. - // close_connection(); - // stop_camera() - // cleanup_proto_data(); - tuneserver_deinitialize_prevtuningp(&lib_handle->tsctrl, - (char **)&lib_handle->tsctrl.proto->send_buf, - &lib_handle->tsctrl.proto->send_len); - close(prev_client_socket); - prev_client_socket = -1; - } else { - result = prevserver_process_client_message((void *)buf, - &lib_handle->tsctrl); - if (result < 0) { - LOGE("Protocol violated\n"); - - //free(tsctrl->preivew_proto); - //free(tsctrl); - //max_fd = ezt_parms_listen_sd + 1; - tuneserver_deinitialize_prevtuningp(&lib_handle->tsctrl, - (char **)&lib_handle->tsctrl.proto->send_buf, - &lib_handle->tsctrl.proto->send_len); - close(prev_client_socket); - prev_client_socket = -1; - //tuneserver_check_status(&tsctrl); - } - //sleep(1); - } - } - } while (1); - - if (server_socket >= 0) { - close(server_socket); - } - if (client_socket >= 0) { - close(client_socket); - } - if (prev_server_socket >= 0) { - close(prev_server_socket); - } - if (prev_client_socket >= 0) { - close(prev_client_socket); - } - - return EXIT_SUCCESS; -} - -int eztune_server_start (void *lib_handle) -{ - return pthread_create(&eztune_thread_id, NULL, eztune_proc, lib_handle); -} - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_unit_test.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_unit_test.c deleted file mode 100644 index c6eaab7..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_unit_test.c +++ /dev/null @@ -1,695 +0,0 @@ -/* Copyright (c) 2013, 2016, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -// Camera dependencies -#include "mm_qcamera_app.h" -#include "mm_qcamera_dbg.h" - -#define MM_QCAMERA_APP_UTEST_MAX_MAIN_LOOP 1 -#define MM_QCAMERA_APP_UTEST_OUTER_LOOP 1 -#define MM_QCAMERA_APP_UTEST_INNER_LOOP 1 -#define MM_QCAM_APP_TEST_NUM 128 - -static mm_app_tc_t mm_app_tc[MM_QCAM_APP_TEST_NUM]; - -int mm_app_tc_open_close(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying open/close cameras...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - i, rc); - break; - } - sleep(1); - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_close() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_tc_start_stop_preview(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying start/stop preview...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_start_preview() cam_idx=%d, err=%d\n", - i, rc); - break; - } - sleep(1); - rc = mm_app_stop_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_stop_preview() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - - rc |= mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_close() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_tc_start_stop_zsl(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying start/stop preview...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - for (j = 0; j < 1; j++) { - rc = mm_app_start_preview_zsl(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_start_preview_zsl() cam_idx=%d, err=%d\n", - i, rc); - break; - } - sleep(1); - rc = mm_app_stop_preview_zsl(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_stop_preview_zsl() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_close() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_tc_start_stop_video_preview(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying start/stop video preview...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_start_record_preview() cam_idx=%d, err=%d\n", - i, rc); - break; - } - sleep(1); - rc = mm_app_stop_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_stop_record_preview() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_close() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_tc_start_stop_video_record(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying start/stop recording...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - rc = mm_app_start_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_start_record_preview() cam_idx=%d, err=%d\n", - i, rc); - mm_app_close(&test_obj); - break; - } - - sleep(1); - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_record(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_start_record() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - sleep(1); - - rc = mm_app_stop_record(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_stop_record() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - if (rc != MM_CAMERA_OK) { - LOGE("start/stop record cam_idx=%d, err=%d\n", - i, rc); - mm_app_stop_record_preview(&test_obj); - mm_app_close(&test_obj); - break; - } - - rc = mm_app_stop_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_stop_record_preview() cam_idx=%d, err=%d\n", - i, rc); - mm_app_close(&test_obj); - break; - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_close() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_tc_start_stop_live_snapshot(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying start/stop live snapshot...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - rc = mm_app_start_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_start_record_preview() cam_idx=%d, err=%d\n", - i, rc); - mm_app_close(&test_obj); - break; - } - - sleep(1); - - rc = mm_app_start_record(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_start_record() cam_idx=%d, err=%d\n", - i, rc); - mm_app_stop_record_preview(&test_obj); - mm_app_close(&test_obj); - break; - } - - sleep(1); - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_live_snapshot(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_start_live_snapshot() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - /* wait for jpeg is done */ - mm_camera_app_wait(); - - rc = mm_app_stop_live_snapshot(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_stop_live_snapshot() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - if (rc != MM_CAMERA_OK) { - LOGE("start/stop live snapshot cam_idx=%d, err=%d\n", - i, rc); - mm_app_stop_record(&test_obj); - mm_app_stop_record_preview(&test_obj); - mm_app_close(&test_obj); - break; - } - - rc = mm_app_stop_record(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_stop_record() cam_idx=%d, err=%d\n", - i, rc); - mm_app_stop_record_preview(&test_obj); - mm_app_close(&test_obj); - break; - } - - sleep(1); - - rc = mm_app_stop_record_preview(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_stop_record_preview() cam_idx=%d, err=%d\n", - i, rc); - mm_app_close(&test_obj); - break; - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_close() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_tc_capture_raw(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - uint8_t num_snapshot = 1; - uint8_t num_rcvd_snapshot = 0; - - printf("\n Verifying raw capture...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_capture_raw(&test_obj, num_snapshot); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_start_capture() cam_idx=%d, err=%d\n", - i, rc); - break; - } - while (num_rcvd_snapshot < num_snapshot) { - mm_camera_app_wait(); - num_rcvd_snapshot++; - } - rc = mm_app_stop_capture_raw(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_stop_capture() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - - rc |= mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_close() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_tc_capture_regular(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - uint8_t num_snapshot = 1; - uint8_t num_rcvd_snapshot = 0; - - printf("\n Verifying capture...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_capture(&test_obj, num_snapshot); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_start_capture() cam_idx=%d, err=%d\n", - i, rc); - break; - } - while (num_rcvd_snapshot < num_snapshot) { - mm_camera_app_wait(); - num_rcvd_snapshot++; - } - rc = mm_app_stop_capture(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_stop_capture() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_close() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_tc_capture_burst(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - uint8_t num_snapshot = 3; - uint8_t num_rcvd_snapshot = 0; - - printf("\n Verifying capture...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_capture(&test_obj, num_snapshot); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_start_capture() cam_idx=%d, err=%d\n", - i, rc); - break; - } - while (num_rcvd_snapshot < num_snapshot) { - mm_camera_app_wait(); - num_rcvd_snapshot++; - } - rc = mm_app_stop_capture(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_stop_capture() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - - rc = mm_app_close(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_close() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_tc_rdi_burst(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK, rc2 = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying rdi burst (3) capture...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_rdi(&test_obj, 3); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_start_preview() cam_idx=%d, err=%d\n", - i, rc); - break; - } - sleep(1); - rc = mm_app_stop_rdi(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_stop_preview() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - - rc2 = mm_app_close(&test_obj); - if (rc2 != MM_CAMERA_OK) { - LOGE("mm_app_close() cam_idx=%d, err=%d\n", - i, rc2); - if (rc == MM_CAMERA_OK) { - rc = rc2; - } - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_tc_rdi_cont(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK, rc2 = MM_CAMERA_OK; - int i, j; - mm_camera_test_obj_t test_obj; - - printf("\n Verifying rdi continuous capture...\n"); - for (i = 0; i < cam_app->num_cameras; i++) { - memset(&test_obj, 0, sizeof(mm_camera_test_obj_t)); - rc = mm_app_open(cam_app, i, &test_obj); - if (rc != MM_CAMERA_OK) { - LOGE("mm_app_open() cam_idx=%d, err=%d\n", - i, rc); - break; - } - - for (j = 0; j < MM_QCAMERA_APP_UTEST_INNER_LOOP; j++) { - rc = mm_app_start_rdi(&test_obj, 0); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_start_preview() cam_idx=%d, err=%d\n", - i, rc); - break; - } - sleep(1); - rc = mm_app_stop_rdi(&test_obj); - if (rc != MM_CAMERA_OK) { - LOGE(" mm_app_stop_preview() cam_idx=%d, err=%d\n", - i, rc); - break; - } - } - - rc2 = mm_app_close(&test_obj); - if (rc2 != MM_CAMERA_OK) { - LOGE("mm_app_close() cam_idx=%d, err=%d\n", - i, rc2); - if (rc == MM_CAMERA_OK) { - rc = rc2; - } - break; - } - } - if (rc == MM_CAMERA_OK) { - printf("\nPassed\n"); - } else { - printf("\nFailed\n"); - } - LOGD("END, rc = %d\n", rc); - return rc; -} - -int mm_app_gen_test_cases() -{ - int tc = 0; - memset(mm_app_tc, 0, sizeof(mm_app_tc)); - if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_open_close; - if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_preview; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_zsl; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_video_preview; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_video_record; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_start_stop_live_snapshot; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_capture_regular; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_capture_burst; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_rdi_cont; - //if (tc < MM_QCAM_APP_TEST_NUM) mm_app_tc[tc++].f = mm_app_tc_rdi_burst; - - return tc; -} - -int mm_app_unit_test_entry(mm_camera_app_t *cam_app) -{ - int rc = MM_CAMERA_OK; - int i, j, tc = 0; - - tc = mm_app_gen_test_cases(); - LOGD("Running %d test cases\n",tc); - for (i = 0; i < tc; i++) { - for (j = 0; j < MM_QCAMERA_APP_UTEST_OUTER_LOOP; j++) { - mm_app_tc[i].r = mm_app_tc[i].f(cam_app); - if (mm_app_tc[i].r != MM_CAMERA_OK) { - printf(" test case %d (iteration %d) error = %d, abort unit testing engine!!!!\n", - i, j, mm_app_tc[i].r); - rc = mm_app_tc[i].r; - goto end; - } - } - } -end: - printf("nTOTAL_TSET_CASE = %d, NUM_TEST_RAN = %d, rc=%d\n", tc, i, rc); - return rc; -} - - - - diff --git a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_video.c b/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_video.c deleted file mode 100644 index ba0a57f..0000000 --- a/camera/QCamera2/stack/mm-camera-test/src/mm_qcamera_video.c +++ /dev/null @@ -1,258 +0,0 @@ -/* -Copyright (c) 2012-2014, 2016, The Linux Foundation. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - * Neither the name of The Linux Foundation nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -// Camera dependencies -#include "mm_qcamera_app.h" -#include "mm_qcamera_dbg.h" - -static void mm_app_video_notify_cb(mm_camera_super_buf_t *bufs, - void *user_data) -{ - char file_name[64]; - mm_camera_buf_def_t *frame = bufs->bufs[0]; - mm_camera_test_obj_t *pme = (mm_camera_test_obj_t *)user_data; - - LOGD("BEGIN - length=%zu, frame idx = %d\n", - frame->frame_len, frame->frame_idx); - snprintf(file_name, sizeof(file_name), "V_C%d", pme->cam->camera_handle); - mm_app_dump_frame(frame, file_name, "yuv", frame->frame_idx); - - if (MM_CAMERA_OK != pme->cam->ops->qbuf(bufs->camera_handle, - bufs->ch_id, - frame)) { - LOGE("Failed in Preview Qbuf\n"); - } - mm_app_cache_ops((mm_camera_app_meminfo_t *)frame->mem_info, - ION_IOC_INV_CACHES); - - LOGD("END\n"); -} - -mm_camera_stream_t * mm_app_add_video_stream(mm_camera_test_obj_t *test_obj, - mm_camera_channel_t *channel, - mm_camera_buf_notify_t stream_cb, - void *userdata, - uint8_t num_bufs) -{ - int rc = MM_CAMERA_OK; - mm_camera_stream_t *stream = NULL; - cam_capability_t *cam_cap = (cam_capability_t *)(test_obj->cap_buf.buf.buffer); - - stream = mm_app_add_stream(test_obj, channel); - if (NULL == stream) { - LOGE("add stream failed\n"); - return NULL; - } - - stream->s_config.mem_vtbl.get_bufs = mm_app_stream_initbuf; - stream->s_config.mem_vtbl.put_bufs = mm_app_stream_deinitbuf; - stream->s_config.mem_vtbl.clean_invalidate_buf = - mm_app_stream_clean_invalidate_buf; - stream->s_config.mem_vtbl.invalidate_buf = mm_app_stream_invalidate_buf; - stream->s_config.mem_vtbl.user_data = (void *)stream; - stream->s_config.stream_cb = stream_cb; - stream->s_config.stream_cb_sync = NULL; - stream->s_config.userdata = userdata; - stream->num_of_bufs = num_bufs; - - stream->s_config.stream_info = (cam_stream_info_t *)stream->s_info_buf.buf.buffer; - memset(stream->s_config.stream_info, 0, sizeof(cam_stream_info_t)); - stream->s_config.stream_info->stream_type = CAM_STREAM_TYPE_VIDEO; - stream->s_config.stream_info->streaming_mode = CAM_STREAMING_MODE_CONTINUOUS; - stream->s_config.stream_info->fmt = DEFAULT_VIDEO_FORMAT; - stream->s_config.stream_info->dim.width = DEFAULT_VIDEO_WIDTH; - stream->s_config.stream_info->dim.height = DEFAULT_VIDEO_HEIGHT; - stream->s_config.padding_info = cam_cap->padding_info; - - rc = mm_app_config_stream(test_obj, channel, stream, &stream->s_config); - if (MM_CAMERA_OK != rc) { - LOGE("config preview stream err=%d\n", rc); - return NULL; - } - - return stream; -} - -mm_camera_channel_t * mm_app_add_video_channel(mm_camera_test_obj_t *test_obj) -{ - mm_camera_channel_t *channel = NULL; - mm_camera_stream_t *stream = NULL; - - channel = mm_app_add_channel(test_obj, - MM_CHANNEL_TYPE_VIDEO, - NULL, - NULL, - NULL); - if (NULL == channel) { - LOGE("add channel failed"); - return NULL; - } - - stream = mm_app_add_video_stream(test_obj, - channel, - mm_app_video_notify_cb, - (void *)test_obj, - 1); - if (NULL == stream) { - LOGE("add video stream failed\n"); - mm_app_del_channel(test_obj, channel); - return NULL; - } - - return channel; -} - -int mm_app_start_record_preview(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *p_ch = NULL; - mm_camera_channel_t *v_ch = NULL; - mm_camera_channel_t *s_ch = NULL; - - p_ch = mm_app_add_preview_channel(test_obj); - if (NULL == p_ch) { - LOGE("add preview channel failed"); - return -MM_CAMERA_E_GENERAL; - } - - v_ch = mm_app_add_video_channel(test_obj); - if (NULL == v_ch) { - LOGE("add video channel failed"); - mm_app_del_channel(test_obj, p_ch); - return -MM_CAMERA_E_GENERAL; - } - - s_ch = mm_app_add_snapshot_channel(test_obj); - if (NULL == s_ch) { - LOGE("add snapshot channel failed"); - mm_app_del_channel(test_obj, p_ch); - mm_app_del_channel(test_obj, v_ch); - return -MM_CAMERA_E_GENERAL; - } - - rc = mm_app_start_channel(test_obj, p_ch); - if (MM_CAMERA_OK != rc) { - LOGE("start preview failed rc=%d\n", rc); - mm_app_del_channel(test_obj, p_ch); - mm_app_del_channel(test_obj, v_ch); - mm_app_del_channel(test_obj, s_ch); - return rc; - } - - return rc; -} - -int mm_app_stop_record_preview(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *p_ch = NULL; - mm_camera_channel_t *v_ch = NULL; - mm_camera_channel_t *s_ch = NULL; - - p_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_PREVIEW); - v_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_VIDEO); - s_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_SNAPSHOT); - - rc = mm_app_stop_and_del_channel(test_obj, p_ch); - if (MM_CAMERA_OK != rc) { - LOGE("Stop Preview failed rc=%d\n", rc); - } - - rc = mm_app_stop_and_del_channel(test_obj, v_ch); - if (MM_CAMERA_OK != rc) { - LOGE("Stop Preview failed rc=%d\n", rc); - } - - rc = mm_app_stop_and_del_channel(test_obj, s_ch); - if (MM_CAMERA_OK != rc) { - LOGE("Stop Preview failed rc=%d\n", rc); - } - - return rc; -} - -int mm_app_start_record(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *v_ch = NULL; - - v_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_VIDEO); - - rc = mm_app_start_channel(test_obj, v_ch); - if (MM_CAMERA_OK != rc) { - LOGE("start recording failed rc=%d\n", rc); - } - - return rc; -} - -int mm_app_stop_record(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *v_ch = NULL; - - v_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_VIDEO); - - rc = mm_app_stop_channel(test_obj, v_ch); - if (MM_CAMERA_OK != rc) { - LOGE("stop recording failed rc=%d\n", rc); - } - - return rc; -} - -int mm_app_start_live_snapshot(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *s_ch = NULL; - - s_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_SNAPSHOT); - - rc = mm_app_start_channel(test_obj, s_ch); - if (MM_CAMERA_OK != rc) { - LOGE("start recording failed rc=%d\n", rc); - } - - return rc; -} - -int mm_app_stop_live_snapshot(mm_camera_test_obj_t *test_obj) -{ - int rc = MM_CAMERA_OK; - mm_camera_channel_t *s_ch = NULL; - - s_ch = mm_app_get_channel_by_type(test_obj, MM_CHANNEL_TYPE_SNAPSHOT); - - rc = mm_app_stop_channel(test_obj, s_ch); - if (MM_CAMERA_OK != rc) { - LOGE("stop recording failed rc=%d\n", rc); - } - - return rc; -} |