codeworkx | 62f02ba | 2012-05-20 12:00:36 +0200 | [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 | |
| 17 | #ifndef __SEC_GSC_OUT_H__ |
| 18 | #define __SEC_GSC_OUT_H__ |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | #include <linux/fb.h> |
| 25 | |
| 26 | #include <stdint.h> |
| 27 | #include <string.h> |
| 28 | #include <unistd.h> |
| 29 | #include <errno.h> |
| 30 | #include <fcntl.h> |
| 31 | #include <asm/sizes.h> |
| 32 | |
| 33 | #include <sys/ioctl.h> |
| 34 | #include <sys/types.h> |
| 35 | #include <sys/stat.h> |
| 36 | #include <sys/poll.h> |
| 37 | #include <sys/mman.h> |
| 38 | #include <hardware/hardware.h> |
| 39 | |
| 40 | #include "utils/Timers.h" |
| 41 | |
| 42 | #include "s5p_fimc_v4l2.h" |
| 43 | #include "sec_utils_v4l2.h" |
| 44 | #include "media.h" |
| 45 | #include "v4l2-subdev.h" |
| 46 | |
| 47 | #include "sec_format.h" |
| 48 | |
| 49 | #include "SecBuffer.h" |
| 50 | |
| 51 | #define PFX_NODE_MEDIADEV "/dev/media" |
| 52 | #define PFX_NODE_SUBDEV "/dev/v4l-subdev" |
| 53 | #define PFX_NODE_VIDEODEV "/dev/video" |
| 54 | #define PFX_ENTITY_SUBDEV_GSC "exynos-gsc-sd.%d" |
| 55 | #define PFX_ENTITY_OUTPUTDEV_GSC "exynos-gsc.%d.output" |
| 56 | |
| 57 | #define GSC_SUBDEV_PAD_SINK (0) |
| 58 | #define GSC_SUBDEV_PAD_SOURCE (1) |
| 59 | #define GSC_VIDEODEV_PAD_SOURCE (0) |
| 60 | #define MAX_BUFFERS_GSCALER (2) |
| 61 | #define MAX_PLANES_GSCALER (3) |
| 62 | |
| 63 | #ifdef __cplusplus |
| 64 | } |
| 65 | |
| 66 | class SecGscaler |
| 67 | { |
| 68 | public: |
| 69 | enum DEV { |
| 70 | DEV_0 = 0, |
| 71 | DEV_1, |
| 72 | DEV_2, |
| 73 | DEV_3, |
| 74 | DEV_MAX, |
| 75 | }; |
| 76 | |
| 77 | enum MODE { |
| 78 | MODE_NONE = 0, |
| 79 | MODE_SINGLE_BUF, |
| 80 | MODE_MULTI_BUF, |
| 81 | MODE_DMA_AUTO, |
| 82 | MODE_MAX, |
| 83 | }; |
| 84 | |
| 85 | private: |
| 86 | bool mFlagCreate; |
| 87 | int mDev; |
| 88 | int mVideoNodeNum; |
| 89 | int mSubdevNodeNum; |
| 90 | int mVideodevFd; |
| 91 | int mMediadevFd; |
| 92 | int mSubdevFd; |
| 93 | unsigned int mNumOfBuf; |
| 94 | unsigned int mSrcIndex; |
| 95 | int mRotVal; |
| 96 | bool mFlagGlobalAlpha; |
| 97 | int mGlobalAlpha; |
| 98 | bool mFlagLocalAlpha; |
| 99 | bool mFlagColorKey; |
| 100 | int mColorKey; |
| 101 | bool mFlagSetSrcParam; |
| 102 | bool mFlagSetDstParam; |
| 103 | bool mFlagStreamOn; |
| 104 | |
| 105 | s5p_fimc_t mS5pFimc; |
| 106 | SecBuffer mSrcBuffer[MAX_BUFFERS_GSCALER]; |
| 107 | |
| 108 | __u32 mSubdevEntity; |
| 109 | __u32 mVideodevEntity; |
| 110 | //struct media_link_desc mlink_desc; |
| 111 | |
| 112 | public: |
| 113 | SecGscaler(); |
| 114 | virtual ~SecGscaler(); |
| 115 | |
| 116 | bool create(enum DEV dev, enum MODE mode, unsigned int numOfBuf); |
| 117 | bool create(enum DEV dev, unsigned int numOfBuf); |
| 118 | |
| 119 | bool destroy(void); |
| 120 | bool flagCreate(void); |
| 121 | |
| 122 | int getFd(void); |
| 123 | int getVideodevFd(void); |
| 124 | bool openVideodevFd(void); |
| 125 | bool closeVideodevFd(void); |
| 126 | |
| 127 | int getSubdevFd(void); |
| 128 | __u32 getSubdevEntity(void); |
| 129 | __u32 getVideodevEntity(void); |
| 130 | bool getFlagSteamOn(void); |
| 131 | |
| 132 | SecBuffer * getSrcBufferAddr(int index); |
| 133 | |
| 134 | bool setSrcParams(unsigned int width, unsigned int height, |
| 135 | unsigned int cropX, unsigned int cropY, |
| 136 | unsigned int *cropWidth, unsigned int *cropHeight, |
| 137 | int colorFormat, |
| 138 | bool forceChange = true); |
| 139 | |
| 140 | bool getSrcParams(unsigned int *width, unsigned int *height, |
| 141 | unsigned int *cropX, unsigned int *cropY, |
| 142 | unsigned int *cropWidth, unsigned int *cropHeight, |
| 143 | int *v4l2colorFormat); |
| 144 | |
| 145 | bool setSrcAddr(unsigned int YAddr, |
| 146 | unsigned int CbAddr = 0, |
| 147 | unsigned int CrAddr = 0, |
| 148 | int colorFormat = 0); |
| 149 | |
| 150 | bool setDstParams(unsigned int width, unsigned int height, |
| 151 | unsigned int cropX, unsigned int cropY, |
| 152 | unsigned int *cropWidth, unsigned int *cropHeight, |
| 153 | int colorFormat, |
| 154 | bool forceChange = true); |
| 155 | |
| 156 | bool getDstParams(unsigned int *width, unsigned int *height, |
| 157 | unsigned int *cropX, unsigned int *cropY, |
| 158 | unsigned int *cropWidth, unsigned int *cropHeight, |
| 159 | int *mbusColorFormat); |
| 160 | |
| 161 | bool setDstAddr(unsigned int YAddr, |
| 162 | unsigned int CbAddr = 0, |
| 163 | unsigned int CrAddr = 0, |
| 164 | int buf_index = 0); |
| 165 | |
| 166 | bool setRotVal(unsigned int rotVal); |
| 167 | bool setGlobalAlpha(bool enable = true, int alpha = 0xff); |
| 168 | bool setLocalAlpha(bool enable); |
| 169 | bool setColorKey(bool enable = true, int colorKey = 0xff); |
| 170 | |
| 171 | bool run(void); |
| 172 | bool streamOn(void); |
| 173 | bool streamOff(void); |
| 174 | |
| 175 | private: |
| 176 | bool m_checkSrcSize(unsigned int width, unsigned int height, |
| 177 | unsigned int cropX, unsigned int cropY, |
| 178 | unsigned int *cropWidth, unsigned int *cropHeight, |
| 179 | int colorFormat, |
| 180 | bool forceChange = false); |
| 181 | |
| 182 | bool m_checkDstSize(unsigned int width, unsigned int height, |
| 183 | unsigned int cropX, unsigned int cropY, |
| 184 | unsigned int *cropWidth, unsigned int *cropHeight, |
| 185 | int colorFormat, |
| 186 | int rotVal, |
| 187 | bool forceChange = false); |
| 188 | int m_widthOfFimc(int v4l2ColorFormat, int width); |
| 189 | int m_heightOfFimc(int v4l2ColorFormat, int height); |
| 190 | int m_getYuvBpp(unsigned int fmt); |
| 191 | int m_getYuvPlanes(unsigned int fmt); |
| 192 | }; |
| 193 | #endif |
| 194 | |
| 195 | #endif //__SEC_GSC_OUT_H__ |