1 /*
2 * Copyright (C) 2014 The Android Open Source Project
3 * Copyright@ Samsung Electronics Co. LTD
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /*!
19 * \file libscaler-common.h
20 * \brief source file for Scaler HAL
21 * \author Cho KyongHo <pullip.cho@samsung.com>
22 * \date 2014/05/08
23 *
24 * <b>Revision History: </b>
25 * - 2014.05.08 : Cho KyongHo (pullip.cho@samsung.com) \n
26 * Create
27 */
28 #ifndef _LIBSCALER_COMMON_H_
29 #define _LIBSCALER_COMMON_H_
30
31 #define LOG_TAG "libexynosscaler"
32 #include <log/log.h>
33 #include <cerrno>
34 #include <cstring>
35
36 //#define LOG_NDEBUG 0
37
38 #ifdef __GNUC__
39 # define __UNUSED__ __attribute__((__unused__))
40 #else
41 # define __UNUSED__
42 #endif
43
44 #define SC_LOGERR(fmt, args...) ((void)ALOG(LOG_ERROR, LOG_TAG, "%s: " fmt " [%s]", __func__, ##args, strerror(errno)))
45 #define SC_LOGE(fmt, args...) ((void)ALOG(LOG_ERROR, LOG_TAG, "%s: " fmt, __func__, ##args))
46 #define SC_LOGI(fmt, args...) ((void)ALOG(LOG_INFO, LOG_TAG, "%s: " fmt, __func__, ##args))
47 #define SC_LOGI_IF(cond, fmt, args...) do { \
48 if (cond) \
49 SC_LOGI(fmt, ##args); \
50 } while (0)
51 #define SC_LOGE_IF(cond, fmt, args...) do { \
52 if (cond) \
53 SC_LOGE(fmt, ##args); \
54 } while (0)
55 #define SC_LOG_ASSERT(cont, fmt, args...) ((void)ALOG_ASSERT(cond, "%s: " fmt, __func__, ##args))
56
57 #ifdef SC_DEBUG
58 #define SC_LOGD(args...) ((void)ALOG(LOG_INFO, LOG_TAG, ##args))
59 #define SC_LOGD_IF(cond, fmt, args...) do { \
60 if (cond) \
61 SC_LOGD(fmt, ##args); \
62 } while (0)
63 #else
64 #define SC_LOGD(args...) do { } while (0)
65 #define SC_LOGD_IF(cond, fmt, args...) do { } while (0)
66 #endif
67
68 #define ARRSIZE(arr) (sizeof(arr)/sizeof(arr[0]))
69
70
71
72 namespace LibScaler {
73 template <typename T>
min(T a,T b)74 static inline T min (T a, T b) {
75 return (a > b) ? b : a;
76 }
77
78 template <typename T>
swap(T & a,T & b)79 static inline void swap(T &a, T &b) {
80 T t = a;
81 a = b;
82 b = t;
83 }
84
UnderOne16thScaling(unsigned int srcw,unsigned int srch,unsigned int dstw,unsigned int dsth,unsigned int rot)85 static inline bool UnderOne16thScaling(unsigned int srcw, unsigned int srch,
86 unsigned int dstw, unsigned int dsth, unsigned int rot) {
87 if ((rot == 90) || (rot == 270))
88 swap(srcw, srch);
89
90 return ((srcw > (dstw * 16)) || (srch > (dsth * 16)));
91 }
92
93 };
94 // marker for output parameters
95 #define __out
96
97 #define V4L2_CID_2D_SRC_BLEND_SET_FMT (V4L2_CID_EXYNOS_BASE + 116)
98 #define V4L2_CID_2D_SRC_BLEND_SET_H_POS (V4L2_CID_EXYNOS_BASE + 117)
99 #define V4L2_CID_2D_SRC_BLEND_SET_V_POS (V4L2_CID_EXYNOS_BASE + 118)
100 #define V4L2_CID_2D_SRC_BLEND_FMT_PREMULTI (V4L2_CID_EXYNOS_BASE + 119)
101 #define V4L2_CID_2D_SRC_BLEND_SET_STRIDE (V4L2_CID_EXYNOS_BASE + 120)
102 #define V4L2_CID_2D_SRC_BLEND_SET_WIDTH (V4L2_CID_EXYNOS_BASE + 121)
103 #define V4L2_CID_2D_SRC_BLEND_SET_HEIGHT (V4L2_CID_EXYNOS_BASE + 122)
104
105 #ifndef V4L2_CID_GLOBAL_ALPHA
106 #define V4L2_CID_GLOBAL_ALPHA (V4L2_CID_EXYNOS_BASE + 1)
107 #endif
108 #ifndef V4L2_CID_2D_BLEND_OP
109 #define V4L2_CID_2D_BLEND_OP (V4L2_CID_EXYNOS_BASE + 103)
110 #endif
111 #ifndef V4L2_CID_2D_COLOR_FILL
112 #define V4L2_CID_2D_COLOR_FILL (V4L2_CID_EXYNOS_BASE + 104)
113 #endif
114 #ifndef V4L2_CID_2D_DITH
115 #define V4L2_CID_2D_DITH (V4L2_CID_EXYNOS_BASE + 105)
116 #endif
117 #ifndef V4L2_CID_2D_FMT_PREMULTI
118 #define V4L2_CID_2D_FMT_PREMULTI (V4L2_CID_EXYNOS_BASE + 106)
119 #endif
120
121 #define SC_CID_FRAMERATE (V4L2_CID_EXYNOS_BASE + 110)
122
123 #define LIBSC_V4L2_CID_DNOISE_FT (V4L2_CID_EXYNOS_BASE + 150)
124 #define LIBSC_M2M1SHOT_OP_FILTER_SHIFT (28)
125 #define LIBSC_M2M1SHOT_OP_FILTER_MASK (0xf << 28)
126
127 #endif //_LIBSCALER_COMMON_H_
128