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