1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HOS_CAMERA_TEMP_H 17 #define HOS_CAMERA_TEMP_H 18 19 #include <cstdint> 20 #include <functional> 21 #include <iostream> 22 #include <memory> 23 #include <stdint.h> 24 #include <stdio.h> 25 #include <stdlib.h> 26 #include <hdf_log.h> 27 28 namespace OHOS::Camera { 29 enum CameraBufferStatus { 30 CAMERA_BUFFER_STATUS_OK = 0, 31 CAMERA_BUFFER_STATUS_DROP, 32 CAMERA_BUFFER_STATUS_INVALID, 33 }; 34 class IBuffer { 35 public: IBuffer()36 IBuffer() {} ~IBuffer()37 ~IBuffer() {} 38 GetIndex()39 int32_t GetIndex() 40 { 41 return index_; 42 } GetSize()43 uint32_t GetSize() 44 { 45 return size_; 46 } GetVirAddress()47 void* GetVirAddress() 48 { 49 return virAddr_; 50 } 51 GetUsage()52 uint64_t GetUsage() 53 { 54 return usage_; 55 } 56 SetIndex(const uint32_t index)57 void SetIndex(const uint32_t index) 58 { 59 index_ = index; 60 return; 61 } 62 SetSize(const uint32_t size)63 void SetSize(const uint32_t size) 64 { 65 size_ = size; 66 return; 67 } 68 SetVirAddress(void * addr)69 void SetVirAddress(void* addr) 70 { 71 virAddr_ = addr; 72 return; 73 } 74 SetUsage(const uint64_t usage)75 void SetUsage(const uint64_t usage) 76 { 77 usage_ = usage; 78 return; 79 } SetBufferStatus(const CameraBufferStatus flag)80 void SetBufferStatus(const CameraBufferStatus flag) 81 { 82 (void)flag; 83 } 84 85 private: 86 int32_t index_ = -1; 87 uint32_t size_ = 0; 88 void* virAddr_ = nullptr; 89 uint64_t usage_ = 0; 90 }; 91 92 using FrameSpec = struct { 93 int64_t bufferPoolId_; 94 std::shared_ptr<IBuffer> buffer_; 95 }; 96 97 98 enum AdapterCmd : uint32_t { 99 CMD_AE_EXPO, 100 CMD_AWB_MODE, 101 CMD_AWB_LOCK, 102 CMD_AE_EXPOTIME, 103 CMD_AE_LOCK, 104 CMD_EXPOSURE_MODE, 105 CMD_EXPOSURE_COMPENSATION, 106 CMD_EXPOSURE_STATE, 107 CMD_EXPOSURE_LOCK, 108 CMD_AWB_COLORGAINS, 109 CMD_FOCUS_MODE, 110 CMD_FOCUS_REGION, 111 CMD_FOCUS_LOCK, 112 CMD_METER_MODE, 113 CMD_METER_POINT, 114 CMD_FLASH_MODE, 115 CMD_FPS_RANGE 116 }; 117 118 #ifdef DISABLE_LOGD 119 #define CAMERA_LOGD(...) 120 #else 121 #define CAMERA_LOGD(fmt, ...) \ 122 do { \ 123 HDF_LOGD("INFO:" fmt "\n", ##__VA_ARGS__); \ 124 } while (0) 125 #endif 126 127 #define CAMERA_LOGE(fmt, ...) \ 128 do { \ 129 HDF_LOGD("ERROR:" fmt "\n", ##__VA_ARGS__); \ 130 } while (0) 131 132 enum RetCode { 133 RC_OK = 0, 134 RC_ERROR, 135 }; 136 137 #define CHECK_IF_NOT_EQUAL_RETURN_VALUE(arg1, arg2, ret) \ 138 if ((arg1) != (arg2)) { \ 139 CAMERA_LOGE("%{public}u, %{public}s is not equal to %{public}s, return %{public}s", __LINE__, #arg1, #arg2, \ 140 #ret); \ 141 return (ret); \ 142 } 143 144 #define CHECK_IF_EQUAL_RETURN_VALUE(arg1, arg2, ret) \ 145 if ((arg1) == (arg2)) { \ 146 CAMERA_LOGE("%{public}u, %{public}s is equal to %{public}s, return %{public}s", __LINE__, #arg1, #arg2, #ret); \ 147 return (ret); \ 148 } 149 150 #define CHECK_IF_PTR_NULL_RETURN_VALUE(ptr, ret) CHECK_IF_EQUAL_RETURN_VALUE(ptr, nullptr, ret) 151 152 #define CHECK_IF_NOT_EQUAL_RETURN_VOID(arg1, arg2) \ 153 if ((arg1) != (arg2)) { \ 154 CAMERA_LOGE("%{public}u, %{public}s is not equal to %{public}s, return", __LINE__, #arg1, #arg2); \ 155 return; \ 156 } 157 158 #define CHECK_IF_EQUAL_RETURN_VOID(arg1, arg2) \ 159 if ((arg1) == (arg2)) { \ 160 CAMERA_LOGE("%{public}u, %{public}s is equal to %{public}s, return", __LINE__, #arg1, #arg2); \ 161 return; \ 162 } 163 164 #define CHECK_IF_PTR_NULL_RETURN_VOID(ptr) CHECK_IF_EQUAL_RETURN_VOID(ptr, nullptr) 165 } // namespace OHOS::Camera 166 #endif // HOS_CAMERA_TEMP_H 167