codeworkx | f1be2fe | 2012-03-24 17:38:29 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 65 | namespace android { |
| 66 | |
| 67 | class SecHdmi: virtual public RefBase |
| 68 | { |
| 69 | public : |
| 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 | |
| 78 | private : |
| 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; |
codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [diff] [blame^] | 162 | unsigned int mFBIndex; |
codeworkx | f1be2fe | 2012-03-24 17:38:29 +0100 | [diff] [blame] | 163 | int mHdmiFd[HDMI_LAYER_MAX]; |
| 164 | |
| 165 | int mDstWidth[HDMI_LAYER_MAX]; |
| 166 | int mDstHeight[HDMI_LAYER_MAX]; |
| 167 | int mPrevDstWidth[HDMI_LAYER_MAX]; |
| 168 | int mPrevDstHeight[HDMI_LAYER_MAX]; |
| 169 | |
| 170 | int mDefaultFBFd; |
| 171 | int mDisplayWidth; |
| 172 | int mDisplayHeight; |
| 173 | |
| 174 | struct v4l2_rect mDstRect; |
| 175 | |
| 176 | public : |
| 177 | |
| 178 | SecHdmi(); |
| 179 | virtual ~SecHdmi(); |
| 180 | bool create(int width, int height); |
| 181 | bool destroy(void); |
| 182 | inline bool flagCreate(void) { return mFlagCreate; } |
| 183 | |
| 184 | bool connect(void); |
| 185 | bool disconnect(void); |
| 186 | |
| 187 | bool flagConnected(void); |
| 188 | |
| 189 | bool flush(int srcW, int srcH, int srcColorFormat, |
| 190 | unsigned int srcYAddr, unsigned int srcCbAddr, unsigned int srcCrAddr, |
| 191 | int dstX, int dstY, |
| 192 | int hdmiLayer, |
| 193 | int num_of_hwc_layer); |
| 194 | |
| 195 | bool clear(int hdmiLayer); |
| 196 | |
| 197 | bool setHdmiOutputMode(int hdmiOutputMode, bool forceRun = false); |
| 198 | bool setHdmiResolution(unsigned int hdmiResolutionValue, bool forceRun = false); |
| 199 | bool setHdcpMode(bool hdcpMode, bool forceRun = false); |
| 200 | bool setUIRotation(unsigned int rotVal, unsigned int hwcLayer); |
| 201 | bool setDisplaySize(int width, int height); |
| 202 | |
| 203 | private: |
| 204 | |
| 205 | bool m_reset(int w, int h, int colorFormat, int hdmiLayer, int hwcLayer); |
| 206 | bool m_startHdmi(int hdmiLayer, unsigned int num_of_plane); |
| 207 | bool m_startHdmi(int hdmiLayer); |
| 208 | bool m_stopHdmi(int hdmiLayer); |
| 209 | bool m_setHdmiOutputMode(int hdmiOutputMode); |
| 210 | bool m_setHdmiResolution(unsigned int hdmiResolutionValue); |
| 211 | bool m_setCompositeResolution(unsigned int compositeStdId); |
| 212 | bool m_setHdcpMode(bool hdcpMode); |
| 213 | bool m_setAudioMode(int audioMode); |
| 214 | |
| 215 | int m_resolutionValueIndex(unsigned int ResolutionValue); |
| 216 | bool m_flagHWConnected(void); |
| 217 | }; |
| 218 | |
| 219 | }; // namespace android |
| 220 | |
| 221 | #endif //__SEC_HDMI_H__ |