libhwjpeg: resolve compilation errors
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos.git] / include / exynos_blender_obj.h
1 /*
2 * Copyright (C) 2013 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 exynos_blender_obj.h
20 * \brief Class definition for Exynos Blender library
21 * \author Eunseok Choi (es10.choi@samsung.com)
22 * \date 2013/09/21
23 *
24 * <b>Revision History: </b>
25 * - 2013.09.21 : Eunseok Choi (eunseok.choi@samsung.com) \n
26 * Create
27 *
28 */
29 #ifndef __EXYNOS_BLENDER_OBJ_H__
30 #define __EXYNOS_BLENDER_OBJ_H__
31
32 #include <cstring>
33 #include <cstdlib>
34 #include <system/graphics.h>
35 #include <cutils/log.h>
36 #include "exynos_blender.h"
37
38 #define BL_LOGERR(fmt, args...) \
39 ((void)ALOG(LOG_ERROR, LOG_TAG, "%s: " fmt " [%s]", __func__, ##args, strerror(errno)))
40 #define BL_LOGE(fmt, args...) \
41 ((void)ALOG(LOG_ERROR, LOG_TAG, "%s: " fmt, __func__, ##args))
42
43 //#define BL_DEBUG
44
45 #ifdef BL_DEBUG
46 #define BL_LOGD(args...) ((void)ALOG(LOG_INFO, LOG_TAG, ##args))
47 #else
48 #define BL_LOGD(args...)
49 #endif
50
51 #define UNIMPL { BL_LOGE("Unimplemented Operation %p\n", this); return -1; }
52
53 #define SRC_BUFTYPE V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
54 #define DST_BUFTYPE V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
55
56 class CBlender {
57 public:
58 enum BL_PORT { SRC, DST, NUM_PORTS };
59
60 protected:
61 enum { BL_MAX_NODENAME = 14 };
62 enum BL_FLAGS {
63 F_FILL,
64 F_ROTATE,
65 F_BLEND,
66 F_GALPHA,
67 F_DITHER,
68 F_BLUSCR,
69 F_SCALE,
70 F_REPEAT,
71 F_CLIP,
72 F_CSC_SPEC,
73 F_CTRL_ANY = 10,
74
75 F_SRC_FMT,
76 F_DST_FMT,
77 F_SRC_MEMORY,
78 F_DST_MEMORY,
79
80 F_SRC_REQBUFS,
81 F_DST_REQBUFS,
82 F_SRC_QBUF,
83 F_DST_QBUF,
84 F_SRC_STREAMON,
85 F_DST_STREAMON,
86
87 F_FLAGS_END = 32
88 };
89
90 struct BL_FrameInfo {
91 struct {
92 v4l2_buf_type type;
93 uint32_t width, height;
94 uint32_t crop_x, crop_y, crop_width, crop_height;
95 uint32_t color_format;
96 void *addr[BL_MAX_PLANES];
97 v4l2_memory memory;
98 int out_num_planes;
99 unsigned long out_plane_size[BL_MAX_PLANES];
100 } port[NUM_PORTS];
101 } m_Frame;
102
103 struct BL_Control {
104 struct {
105 bool enable;
106 uint32_t color_argb8888;
107 } fill;
108 BL_ROTATE rot;
109 bool hflip;
110 bool vflip;
111 BL_OP_TYPE op;
112 bool premultiplied;
113 struct {
114 bool enable;
115 unsigned char val;
116 } global_alpha;
117 bool dither;
118 struct {
119 BL_BLUESCREEN mode;
120 uint32_t bg_color;
121 uint32_t bs_color;
122 } bluescreen;
123 struct {
124 BL_SCALE mode;
125 uint32_t src_w;
126 uint32_t dst_w;
127 uint32_t src_h;
128 uint32_t dst_h;
129 } scale;
130 BL_REPEAT repeat;
131 struct {
132 bool enable;
133 uint32_t x;
134 uint32_t y;
135 uint32_t width;
136 uint32_t height;
137 } clip;
138 struct {
139 bool enable; // set 'true' for user-defined
140 enum v4l2_colorspace space;
141 bool wide;
142 } csc_spec;
143 } m_Ctrl;
144 unsigned long m_Flags;
145
146 int m_fdBlender;
147 int m_iDeviceID;
148 int m_fdValidate;
149
150 char m_cszNode[BL_MAX_NODENAME]; // /dev/videoXX
151 static const char *m_cszPortName[NUM_PORTS];
152
153 inline void SetFlag(int f) { m_Flags |= (1 << f); }
154 inline void ResetFlag(void) { m_Flags = 0; }
155
156 inline bool IsFlagSet(int f)
157 {
158 if (f == F_CTRL_ANY)
159 return m_Flags & ((1 << f) - 1);
160 else
161 return m_Flags & (1 << f);
162 }
163
164 inline void ClearFlag(int f)
165 {
166 if (f == F_CTRL_ANY) {
167 m_Flags &= ~((1 << f) - 1);
168 } else {
169 m_Flags &= ~(1 << f);
170 }
171 }
172
173 public:
174 CBlender()
175 {
176 m_fdBlender = -1;
177 m_iDeviceID = -1;
178 memset(&m_Frame, 0, sizeof(m_Frame));
179 memset(&m_Ctrl, 0, sizeof(m_Ctrl));
180 m_Flags = 0;
181 m_fdValidate = 0;
182 memset(m_cszNode, 0, sizeof(m_cszNode));
183 }
184 virtual ~CBlender() {};
185
186 bool Valid() { return (m_fdBlender >= 0) && (m_fdBlender == -m_fdValidate); }
187 int GetDeviceID() { return m_iDeviceID; }
188
189 int SetColorFill(bool enable, uint32_t color_argb8888);
190 int SetRotate(BL_ROTATE rot, bool hflip, bool vflip);
191 int SetBlend(BL_OP_TYPE op, bool premultiplied);
192 int SetGlobalAlpha(bool enable, unsigned char g_alpha);
193 int SetDither(bool enable);
194 int SetBluescreen(BL_BLUESCREEN mode, uint32_t bg_color, uint32_t bs_color = 0);
195 int SetScale(BL_SCALE mode, uint32_t src_w, uint32_t dst_w, uint32_t src_h, uint32_t dst_h);
196 int SetRepeat(BL_REPEAT mode);
197 int SetClipRect(bool enable, uint32_t x, uint32_t y, uint32_t width, uint32_t height);
198 int SetCscSpec(bool enable, enum v4l2_colorspace space, bool wide);
199
200 int SetAddr(BL_PORT port, void *addr[BL_MAX_PLANES], v4l2_memory type);
201 int SetImageFormat(BL_PORT port, unsigned int width, unsigned int height,
202 unsigned int crop_x, unsigned int crop_y,
203 unsigned int crop_width, unsigned int crop_height,
204 unsigned int v4l2_colorformat);
205
206 virtual int DoStart() = 0;
207 virtual int DoStop() = 0;
208 virtual int Deactivate(bool deact) UNIMPL;
209 };
210
211 #endif // __EXYNOS_BLENER_OBJ_H__