blob: 67c33789c1152b4585b5a6130e75282e90c865d5 [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** @author Sangwoo, Park(sw5771.park@samsung.com)
17** @date 2010-09-10
18**
19*/
20
21#ifndef __SEC_HDMI_H__
22#define __SEC_HDMI_H__
23
24#include <sys/types.h>
25#include <sys/stat.h>
26#include <sys/ioctl.h>
27#include <sys/mman.h>
28#include <fcntl.h>
29#include <ctype.h>
30#include <unistd.h>
31#include <string.h>
32#include <errno.h>
33#include <signal.h>
34#include <pthread.h>
35
36#ifdef BOARD_USE_V4L2
37#include "s5p_tvout_v4l2.h"
38#else
39#include "s5p_tvout.h"
40#endif
41#if defined(BOARD_USES_FIMGAPI)
42#include "sec_g2d.h"
43#endif
44#include "s3c_lcd.h"
45#include "SecBuffer.h"
46#include "SecFimc.h"
47
48#include "../libhdmi/libsForhdmi/libedid/libedid.h"
49#include "../libhdmi/libsForhdmi/libcec/libcec.h"
50
51#include "../libhdmi/SecHdmi/SecHdmiCommon.h"
52#include "../libhdmi/SecHdmi/SecHdmiV4L2Utils.h"
53
54#if defined(BOARD_USES_FIMGAPI)
55#include "FimgApi.h"
56#endif
57
58#include <linux/fb.h>
59
60#include <hardware/hardware.h>
61
62#include <utils/threads.h>
63
64
65namespace android {
66
67class SecHdmi: virtual public RefBase
68{
69public :
70 enum HDMI_LAYER {
71 HDMI_LAYER_BASE = 0,
72 HDMI_LAYER_VIDEO,
73 HDMI_LAYER_GRAPHIC_0,
74 HDMI_LAYER_GRAPHIC_1,
75 HDMI_LAYER_MAX,
76 };
77
78private :
79 class CECThread: public Thread
80 {
81 public:
82 bool mFlagRunning;
83
84 private:
85 sp<SecHdmi> mSecHdmi;
86 Mutex mThreadLoopLock;
87 Mutex mThreadControlLock;
88 virtual bool threadLoop();
89 enum CECDeviceType mDevtype;
90 int mLaddr;
91 int mPaddr;
92
93 public:
94 CECThread(sp<SecHdmi> secHdmi)
95 :Thread(false),
96 mFlagRunning(false),
97 mSecHdmi(secHdmi),
98 mDevtype(CEC_DEVICE_PLAYER),
99 mLaddr(0),
100 mPaddr(0){
101 };
102 virtual ~CECThread();
103
104 bool start();
105 bool stop();
106
107 };
108
109 Mutex mLock;
110
111 sp<CECThread> mCECThread;
112
113 bool mFlagCreate;
114 bool mFlagConnected;
115 bool mFlagLayerEnable[HDMI_LAYER_MAX];
116 bool mFlagHdmiStart[HDMI_LAYER_MAX];
117
118 int mSrcWidth[HDMI_LAYER_MAX];
119 int mSrcHeight[HDMI_LAYER_MAX];
120 int mSrcColorFormat[HDMI_LAYER_MAX];
121 int mHdmiResolutionWidth[HDMI_LAYER_MAX];
122 int mHdmiResolutionHeight[HDMI_LAYER_MAX];
123
124 int mHdmiDstWidth;
125 int mHdmiDstHeight;
126
127 unsigned int mHdmiSrcYAddr;
128 unsigned int mHdmiSrcCbCrAddr;
129
130 int mHdmiOutputMode;
131 unsigned int mHdmiResolutionValue;
132
133 unsigned int mHdmiPresetId;
134 v4l2_std_id mHdmiStdId;
135 unsigned int mCompositeStd;
136
137 bool mHdcpMode;
138 int mAudioMode;
139 unsigned int mUIRotVal;
140 unsigned int mG2DUIRotVal;
141
142 int mCurrentHdmiOutputMode;
143 unsigned int mCurrentHdmiResolutionValue;
144 bool mCurrentHdcpMode;
145 int mCurrentAudioMode;
146 bool mHdmiInfoChange;
147
148 int mFimcDstColorFormat;
149
150 SecBuffer mFimcReservedMem[HDMI_FIMC_OUTPUT_BUF_NUM];
151 unsigned int mFimcCurrentOutBufIndex;
152 SecFimc mSecFimc;
153
154 unsigned int mHdmiResolutionValueList[14];
155 int mHdmiSizeOfResolutionValueList;
156
157 SecBuffer mMixerBuffer[HDMI_LAYER_MAX][MAX_BUFFERS_MIXER];
158
159 void *mFBaddr;
160 unsigned int mFBsize;
161 int mFBionfd;
162 int mHdmiFd[HDMI_LAYER_MAX];
163
164 int mDstWidth[HDMI_LAYER_MAX];
165 int mDstHeight[HDMI_LAYER_MAX];
166 int mPrevDstWidth[HDMI_LAYER_MAX];
167 int mPrevDstHeight[HDMI_LAYER_MAX];
168
169 int mDefaultFBFd;
170 int mDisplayWidth;
171 int mDisplayHeight;
172
173 struct v4l2_rect mDstRect;
174
175public :
176
177 SecHdmi();
178 virtual ~SecHdmi();
179 bool create(int width, int height);
180 bool destroy(void);
181 inline bool flagCreate(void) { return mFlagCreate; }
182
183 bool connect(void);
184 bool disconnect(void);
185
186 bool flagConnected(void);
187
188 bool flush(int srcW, int srcH, int srcColorFormat,
189 unsigned int srcYAddr, unsigned int srcCbAddr, unsigned int srcCrAddr,
190 int dstX, int dstY,
191 int hdmiLayer,
192 int num_of_hwc_layer);
193
194 bool clear(int hdmiLayer);
195
196 bool setHdmiOutputMode(int hdmiOutputMode, bool forceRun = false);
197 bool setHdmiResolution(unsigned int hdmiResolutionValue, bool forceRun = false);
198 bool setHdcpMode(bool hdcpMode, bool forceRun = false);
199 bool setUIRotation(unsigned int rotVal, unsigned int hwcLayer);
200 bool setDisplaySize(int width, int height);
201
202private:
203
204 bool m_reset(int w, int h, int colorFormat, int hdmiLayer, int hwcLayer);
205 bool m_startHdmi(int hdmiLayer, unsigned int num_of_plane);
206 bool m_startHdmi(int hdmiLayer);
207 bool m_stopHdmi(int hdmiLayer);
208 bool m_setHdmiOutputMode(int hdmiOutputMode);
209 bool m_setHdmiResolution(unsigned int hdmiResolutionValue);
210 bool m_setCompositeResolution(unsigned int compositeStdId);
211 bool m_setHdcpMode(bool hdcpMode);
212 bool m_setAudioMode(int audioMode);
213
214 int m_resolutionValueIndex(unsigned int ResolutionValue);
215 bool m_flagHWConnected(void);
216};
217
218}; // namespace android
219
220#endif //__SEC_HDMI_H__