• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
27 namespace OHOS::Camera {
28 class IBuffer {
29 public:
IBuffer()30     IBuffer() {}
~IBuffer()31     ~IBuffer() {}
32 
GetIndex()33     int32_t GetIndex()
34     {
35         return index_;
36     }
GetSize()37     uint32_t GetSize()
38     {
39         return size_;
40     }
GetOffset()41     uint32_t GetOffset()
42     {
43         return offset_;
44     }
GetLength()45     uint32_t GetLength()
46     {
47         return length_;
48     }
GetVirAddress()49     void* GetVirAddress()
50     {
51         return virAddr_;
52     }
53 
GetUsage()54     uint64_t GetUsage()
55     {
56         return usage_;
57     }
58 
SetIndex(const uint32_t index)59     void SetIndex(const uint32_t index)
60     {
61         index_ = index;
62         return;
63     }
64 
SetSize(const uint32_t size)65     void SetSize(const uint32_t size)
66     {
67         size_ = size;
68         return;
69     }
SetOffset(const uint32_t offset)70     void SetOffset(const uint32_t offset)
71     {
72         offset_ = offset;
73         return;
74     }
75 
SetLength(const uint32_t length)76     void SetLength(const uint32_t length)
77     {
78         length_ = length;
79         return;
80     }
SetVirAddress(void * addr)81     void SetVirAddress(void* addr)
82     {
83         virAddr_ = addr;
84         return;
85     }
86 
SetUsage(const uint64_t usage)87     void SetUsage(const uint64_t usage)
88     {
89         usage_ = usage;
90         return;
91     }
92 
93 private:
94     int32_t index_ = -1;
95     uint32_t size_ = 0;
96     void* virAddr_ = nullptr;
97     uint64_t usage_ = 0;
98     uint32_t offset_ = 0;
99     uint32_t length_ = 0;
100 };
101 
102 struct FrameSpec {
103     int64_t bufferPoolId_;
104     std::shared_ptr<IBuffer> buffer_;
105 };
106 
107 using FrameSpec = struct FrameSpec;
108 
109 enum AdapterCmd : uint32_t {
110     CMD_AE_EXPO,
111     CMD_AWB_MODE,
112     CMD_AE_EXPOTIME,
113     CMD_AWB_COLORGAINS
114 };
115 
116 #ifdef DISABLE_LOGD
117 #define CAMERA_LOGD(...)
118 #else
119 #define CAMERA_LOGD(fmt, ...)                    \
120     do {                                         \
121         printf("INFO:" fmt "\n", ##__VA_ARGS__); \
122     } while (0)
123 #endif
124 
125 #define CAMERA_LOGE(fmt, ...)                     \
126     do {                                          \
127         printf("ERROR:" fmt "\n", ##__VA_ARGS__); \
128     } while (0)
129 
130 enum RetCode {
131     RC_OK = 0,
132     RC_ERROR,
133 };
134 
135 #define CHECK_IF_NOT_EQUAL_RETURN_VALUE(arg1, arg2, ret)                                                            \
136     if ((arg1) != (arg2)) {                                                                                         \
137         CAMERA_LOGE("%{public}u, %{public}s is not equal to %{public}s, return %{public}s", __LINE__, #arg1, #arg2, \
138                     #ret);                                                                                          \
139         return (ret);                                                                                               \
140     }
141 
142 #define CHECK_IF_EQUAL_RETURN_VALUE(arg1, arg2, ret)                                                                   \
143     if ((arg1) == (arg2)) {                                                                                            \
144         CAMERA_LOGE("%{public}u, %{public}s is equal to %{public}s, return %{public}s", __LINE__, #arg1, #arg2, #ret); \
145         return (ret);                                                                                                  \
146     }
147 
148 #define CHECK_IF_PTR_NULL_RETURN_VALUE(ptr, ret) CHECK_IF_EQUAL_RETURN_VALUE(ptr, nullptr, ret)
149 
150 #define CHECK_IF_NOT_EQUAL_RETURN_VOID(arg1, arg2)                                                        \
151     if ((arg1) != (arg2)) {                                                                               \
152         CAMERA_LOGE("%{public}u, %{public}s is not equal to %{public}s, return", __LINE__, #arg1, #arg2); \
153         return;                                                                                           \
154     }
155 
156 #define CHECK_IF_EQUAL_RETURN_VOID(arg1, arg2)                                                        \
157     if ((arg1) == (arg2)) {                                                                           \
158         CAMERA_LOGE("%{public}u, %{public}s is equal to %{public}s, return", __LINE__, #arg1, #arg2); \
159         return;                                                                                       \
160     }
161 
162 #define CHECK_IF_PTR_NULL_RETURN_VOID(ptr) CHECK_IF_EQUAL_RETURN_VOID(ptr, nullptr)
163 } // namespace OHOS::Camera
164 #endif // HOS_CAMERA_TEMP_H
165