blob: 61585c220facd433c4a5dcc4e6c64a493bc141e1 [file] [log] [blame]
codeworkxf1be2fe2012-03-24 17:38:29 +01001/*
2 * Copyright@ Samsung Electronics Co. LTD
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*!
18 * \file SecFimc.h
19 * \brief header file for Fimc HAL MODULE
20 * \author Hyunkyung, Kim(hk310.kim@samsung.com)
21 * \date 2010/10/13
22 *
23 * <b>Revision History: </b>
24 * - 2010/10/13 : Hyunkyung, Kim(hk310.kim@samsung.com) \n
25 * Initial version
26 *
27 * - 2011/11/15 : Sunmi, Lee(carrotsm.lee@samsung.com) \n
28 * Adjust V4L2 architecture \n
29 */
30
31#ifndef __SEC_FIMC_H__
32#define __SEC_FIMC_H__
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38#include <linux/fb.h>
39
40#include <stdint.h>
41#include <string.h>
42#include <unistd.h>
43#include <errno.h>
44#include <fcntl.h>
45#include <asm/sizes.h>
46
47#include <sys/ioctl.h>
48#include <sys/types.h>
49#include <sys/poll.h>
50#include <sys/mman.h>
51#include <hardware/hardware.h>
52
53#include "utils/Timers.h"
54
55#ifdef BOARD_USE_V4L2
56#include "s5p_fimc_v4l2.h"
57#include "sec_utils_v4l2.h"
58#else
59#include "s5p_fimc.h"
60#include "sec_utils.h"
61#endif
62#include "sec_format.h"
63
64#include "SecBuffer.h"
65#include "SecRect.h"
66
67#define PFX_NODE_FIMC "/dev/video"
68#define MAX_DST_BUFFERS (3)
69#define MAX_SRC_BUFFERS (1)
70#define MAX_PLANES (3)
71
72#ifdef __cplusplus
73}
74
75class SecFimc
76{
77public:
78 enum DEV {
79 DEV_0 = 0,
80 DEV_1,
81 DEV_2,
82 DEV_3,
83 DEV_MAX,
84 };
85
86 enum MODE {
87 MODE_NONE = 0,
88 MODE_SINGLE_BUF,
89 MODE_MULTI_BUF,
90 MODE_DMA_AUTO,
91 MODE_MAX,
92 };
93
94private:
95 bool mFlagCreate;
96 int mDev;
97 int mFimcMode;
98 int mNumOfBuf;
99
100 int mRealDev;
101 int mFd;
102 int mHwVersion;
103 int mRotVal;
104 bool mFlagGlobalAlpha;
105 int mGlobalAlpha;
106 bool mFlagLocalAlpha;
107 bool mFlagColorKey;
108 int mColorKey;
109 bool mFlagSetSrcParam;
110 bool mFlagSetDstParam;
111 bool mFlagStreamOn;
112
113 s5p_fimc_t mS5pFimc;
114 struct v4l2_capability mFimcCap;
115
116 SecBuffer mSrcBuffer;
117 SecBuffer mDstBuffer[MAX_DST_BUFFERS];
118
119public:
120 SecFimc();
121 virtual ~SecFimc();
122
123 virtual bool create(enum DEV dev, enum MODE mode, int numOfBuf);
124 virtual bool destroy(void);
125 bool flagCreate(void);
126
127 int getFd(void);
128
129 SecBuffer * getMemAddr(int index = 0);
130
131 int getHWVersion(void);
132
133 virtual bool setSrcParams(unsigned int width, unsigned int height,
134 unsigned int cropX, unsigned int cropY,
135 unsigned int *cropWidth, unsigned int *cropHeight,
136 int colorFormat,
137 bool forceChange = true);
138
139 virtual bool getSrcParams(unsigned int *width, unsigned int *height,
140 unsigned int *cropX, unsigned int *cropY,
141 unsigned int *cropWidth, unsigned int *cropHeight,
142 int *colorFormat);
143
144 virtual bool setSrcAddr(unsigned int physYAddr,
145 unsigned int physCbAddr = 0,
146 unsigned int physCrAddr = 0,
147 int colorFormat = 0);
148
149 virtual bool setDstParams(unsigned int width, unsigned int height,
150 unsigned int cropX, unsigned int cropY,
151 unsigned int *cropWidth, unsigned int *cropHeight,
152 int colorFormat,
153 bool forceChange = true);
154
155 virtual bool getDstParams(unsigned int *width, unsigned int *height,
156 unsigned int *cropX, unsigned int *cropY,
157 unsigned int *cropWidth, unsigned int *cropHeight,
158 int *colorFormat);
159
160 virtual bool setDstAddr(unsigned int physYAddr, unsigned int physCbAddr = 0, unsigned int physCrAddr = 0, int buf_index = 0);
161
162 virtual bool setRotVal(unsigned int rotVal);
163 virtual bool setGlobalAlpha(bool enable = true, int alpha = 0xff);
164 virtual bool setLocalAlpha(bool enable);
165 virtual bool setColorKey(bool enable = true, int colorKey = 0xff);
166
167 virtual bool draw(int src_index, int dst_index);
168
169private:
170 bool m_streamOn(void);
171 bool m_checkSrcSize(unsigned int width, unsigned int height,
172 unsigned int cropX, unsigned int cropY,
173 unsigned int *cropWidth, unsigned int *cropHeight,
174 int colorFormat,
175 bool forceChange = false);
176
177 bool m_checkDstSize(unsigned int width, unsigned int height,
178 unsigned int cropX, unsigned int cropY,
179 unsigned int *cropWidth, unsigned int *cropHeight,
180 int colorFormat,
181 int rotVal,
182 bool forceChange = false);
183 int m_widthOfFimc(int v4l2ColorFormat, int width);
184 int m_heightOfFimc(int v4l2ColorFormat, int height);
185 int m_getYuvBpp(unsigned int fmt);
186 int m_getYuvPlanes(unsigned int fmt);
187};
188#endif
189
190#endif //__SEC_FIMC_H__