blob: a65bda602003a1df498f2379d75f3fa6be501956 [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>
codeworkxf1be2fe2012-03-24 17:38:29 +010045
46#include <sys/ioctl.h>
47#include <sys/types.h>
48#include <sys/poll.h>
49#include <sys/mman.h>
50#include <hardware/hardware.h>
51
52#include "utils/Timers.h"
53
54#ifdef BOARD_USE_V4L2
55#include "s5p_fimc_v4l2.h"
56#include "sec_utils_v4l2.h"
57#else
58#include "s5p_fimc.h"
59#include "sec_utils.h"
60#endif
61#include "sec_format.h"
62
63#include "SecBuffer.h"
64#include "SecRect.h"
65
66#define PFX_NODE_FIMC "/dev/video"
67#define MAX_DST_BUFFERS (3)
68#define MAX_SRC_BUFFERS (1)
69#define MAX_PLANES (3)
70
71#ifdef __cplusplus
72}
73
74class SecFimc
75{
76public:
77 enum DEV {
78 DEV_0 = 0,
79 DEV_1,
80 DEV_2,
81 DEV_3,
82 DEV_MAX,
83 };
84
85 enum MODE {
86 MODE_NONE = 0,
87 MODE_SINGLE_BUF,
88 MODE_MULTI_BUF,
89 MODE_DMA_AUTO,
90 MODE_MAX,
91 };
92
93private:
94 bool mFlagCreate;
95 int mDev;
96 int mFimcMode;
97 int mNumOfBuf;
98
99 int mRealDev;
100 int mFd;
101 int mHwVersion;
102 int mRotVal;
103 bool mFlagGlobalAlpha;
104 int mGlobalAlpha;
105 bool mFlagLocalAlpha;
106 bool mFlagColorKey;
107 int mColorKey;
108 bool mFlagSetSrcParam;
109 bool mFlagSetDstParam;
110 bool mFlagStreamOn;
111
112 s5p_fimc_t mS5pFimc;
113 struct v4l2_capability mFimcCap;
114
115 SecBuffer mSrcBuffer;
116 SecBuffer mDstBuffer[MAX_DST_BUFFERS];
117
118public:
119 SecFimc();
120 virtual ~SecFimc();
121
122 virtual bool create(enum DEV dev, enum MODE mode, int numOfBuf);
123 virtual bool destroy(void);
124 bool flagCreate(void);
125
126 int getFd(void);
127
128 SecBuffer * getMemAddr(int index = 0);
129
130 int getHWVersion(void);
131
132 virtual bool setSrcParams(unsigned int width, unsigned int height,
133 unsigned int cropX, unsigned int cropY,
134 unsigned int *cropWidth, unsigned int *cropHeight,
135 int colorFormat,
136 bool forceChange = true);
137
138 virtual bool getSrcParams(unsigned int *width, unsigned int *height,
139 unsigned int *cropX, unsigned int *cropY,
140 unsigned int *cropWidth, unsigned int *cropHeight,
141 int *colorFormat);
142
143 virtual bool setSrcAddr(unsigned int physYAddr,
144 unsigned int physCbAddr = 0,
145 unsigned int physCrAddr = 0,
146 int colorFormat = 0);
147
148 virtual bool setDstParams(unsigned int width, unsigned int height,
149 unsigned int cropX, unsigned int cropY,
150 unsigned int *cropWidth, unsigned int *cropHeight,
151 int colorFormat,
152 bool forceChange = true);
153
154 virtual bool getDstParams(unsigned int *width, unsigned int *height,
155 unsigned int *cropX, unsigned int *cropY,
156 unsigned int *cropWidth, unsigned int *cropHeight,
157 int *colorFormat);
158
159 virtual bool setDstAddr(unsigned int physYAddr, unsigned int physCbAddr = 0, unsigned int physCrAddr = 0, int buf_index = 0);
160
161 virtual bool setRotVal(unsigned int rotVal);
162 virtual bool setGlobalAlpha(bool enable = true, int alpha = 0xff);
163 virtual bool setLocalAlpha(bool enable);
164 virtual bool setColorKey(bool enable = true, int colorKey = 0xff);
165
166 virtual bool draw(int src_index, int dst_index);
167
168private:
169 bool m_streamOn(void);
170 bool m_checkSrcSize(unsigned int width, unsigned int height,
171 unsigned int cropX, unsigned int cropY,
172 unsigned int *cropWidth, unsigned int *cropHeight,
173 int colorFormat,
174 bool forceChange = false);
175
176 bool m_checkDstSize(unsigned int width, unsigned int height,
177 unsigned int cropX, unsigned int cropY,
178 unsigned int *cropWidth, unsigned int *cropHeight,
179 int colorFormat,
180 int rotVal,
181 bool forceChange = false);
182 int m_widthOfFimc(int v4l2ColorFormat, int width);
183 int m_heightOfFimc(int v4l2ColorFormat, int height);
184 int m_getYuvBpp(unsigned int fmt);
185 int m_getYuvPlanes(unsigned int fmt);
186};
187#endif
188
189#endif //__SEC_FIMC_H__