1 /*Copyright (c) 2016, The Linux Foundation. All rights reserved. 2 * 3 * Redistribution and use in source and binary forms, with or without 4 * modification, are permitted provided that the following conditions are 5 * met: 6 * * Redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer. 8 * * Redistributions in binary form must reproduce the above 9 * copyright notice, this list of conditions and the following 10 * disclaimer in the documentation and/or other materials provided 11 * with the distribution. 12 * * Neither the name of The Linux Foundation nor the names of its 13 * contributors may be used to endorse or promote products derived 14 * from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 #ifndef __HAL3APP_H__ 30 #define __HAL3APP_H__ 31 32 #include <hardware/hardware.h> 33 #include <dlfcn.h> 34 #include <hardware/camera3.h> 35 #include <sys/stat.h> 36 #include <ctype.h> 37 #include <list> 38 #include <camera/CameraMetadata.h> 39 #include <linux/msm_ion.h> 40 #include <errno.h> 41 #include <fcntl.h> 42 #include <system/window.h> 43 #include <stdio.h> 44 #include <pthread.h> 45 #include <poll.h> 46 #include "QCamera3VendorTags.h" 47 48 extern "C" { 49 #include "mm_camera_dbg.h" 50 } 51 52 #define HAL3_DATASPACE_UNKNOWN 0x0 53 #define HAL3_DATASPACE_ARBITRARY 0x1 54 #define HAL3_DATASPACE_JFIF 0x101 55 #define FLAGS_VIDEO_ENCODER 0x00010000 56 57 #define PREVIEW_WIDTH 1440 58 #define PREVIEW_HEIGHT 1080 59 60 #define VIDEO_WIDTH 1920 61 #define VIDEO_HEIGHT 1080 62 63 #define SNAPSHOT_CAPTURE_WIDTH 5344 64 #define SNAPSHOT_CAPTURE_HEIGHT 4008 65 66 #define RAWSNAPSHOT_CAPTURE_WIDTH 5344 67 #define RAWSNAPSHOT_CAPTURE_HEIGHT 4016 68 69 namespace qcamera { 70 71 typedef enum { 72 HAL3_CAM_OK, 73 HAL3_CAM_E_GENERAL, 74 HAL3_CAM_E_NO_MEMORY, 75 HAL3_CAM_E_NOT_SUPPORTED, 76 HAL3_CAM_E_INVALID_INPUT, 77 HAL3_CAM_E_INVALID_OPERATION, 78 HAL3_CAM_E_ENCODE, 79 HAL3_CAM_E_BUFFER_REG, 80 HAL3_CAM_E_PMEM_ALLOC, 81 HAL3_CAM_E_CAPTURE_FAILED, 82 HAL3_CAM_E_CAPTURE_TIMEOUT, 83 } hal3_camera_status_type_t; 84 85 typedef enum { 86 PROCESS_BUFFER, 87 } buffer_thread_msg_type_t; 88 89 typedef struct { 90 camera3_device_t *device; 91 camera3_callback_ops callback_ops; 92 struct camera_info cam_info; 93 camera_module_callbacks_t module_cb; 94 } hal3_camera_test_obj_t; 95 96 typedef struct { 97 int fd; 98 int ion_fd; 99 ion_user_handle_t ion_handle; 100 size_t size; 101 } hal3_camtest_meminfo_t; 102 103 typedef struct { 104 buffer_thread_msg_type_t msg; 105 bool stop_thread; 106 } buffer_thread_msg_t; 107 108 typedef struct { 109 void *ptr; 110 camera_module_t* halModule_t; 111 } hal3_interface_lib_t; 112 113 typedef struct { 114 uint8_t num_cameras; 115 vendor_tag_ops_t mVendorTagOps; 116 hal3_interface_lib_t hal3_lib; 117 } hal3_camera_app_t; 118 119 typedef struct { 120 hal3_camera_app_t app_obj; 121 hal3_camera_test_obj_t test_obj; 122 } hal3_camera_lib_test; 123 124 typedef struct { 125 pthread_t td; 126 pthread_mutex_t mutex; 127 pthread_cond_t cond; 128 int32_t readfd; 129 int32_t writefd; 130 void *data_obj; 131 bool is_thread_started; 132 int testcase; 133 } buffer_thread_t; 134 135 extern int32_t pfd[2]; 136 typedef hal3_camera_lib_test hal3_camera_lib_handle; 137 138 class CameraHAL3Base 139 { 140 friend class MainTestContext; 141 protected: 142 int mCameraIndex; 143 public: 144 CameraHAL3Base(); 145 CameraHAL3Base(int cameraIndex); 146 hal3_camera_lib_test *mLibHandle; 147 int mFrameCount; 148 int fps; 149 int mSecElapsed; 150 int mTestCaseSelected; 151 int mPreviewRunning; 152 int mVideoRunning; 153 int mSnapShotRunning; 154 bool ir_mode; 155 bool svhdr_mode; 156 camera_info camcap_info; 157 camera_metadata_entry entry_hal3app; 158 android::CameraMetadata hal3app_cam_settings; 159 int hal3appCamInitialize(int camid, hal3_camera_test_obj_t *my_test_obj); 160 void hal3appCamCapabilityGet(hal3_camera_lib_test *handle,int camid); 161 int hal3appCameraLibOpen(int ); 162 int hal3appTestLoad(hal3_camera_app_t *); 163 int hal3appCamOpen(hal3_camera_app_t *, 164 int, 165 hal3_camera_test_obj_t *); 166 int hal3appCameraPreviewInit(int, int, int, int); 167 int hal3appCameraVideoInit(int, int camid, int w, int h); 168 void display_capability(); 169 int hal3appCameraCaptureInit(hal3_camera_lib_test *, int, int); 170 int hal3appRawCaptureInit(hal3_camera_lib_test *handle, int camid, int ); 171 int hal3appCameraTestLoad(); 172 void hal3appCheckStream(int testcase, int camid); 173 }; 174 175 } 176 #endif