Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
| 13 | * * Neither the name of Code Aurora Forum, Inc. nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #ifndef OVERLAY_M3D_EXT_PIPE_H |
| 31 | #define OVERLAY_M3D_EXT_PIPE_H |
| 32 | |
| 33 | #include "overlayGenPipe.h" |
| 34 | #include "overlayUtils.h" |
| 35 | |
| 36 | namespace overlay { |
| 37 | |
| 38 | ///////////// M3DExt Pipe //////////////////////////// |
| 39 | /** |
| 40 | * A specific impl of GenericPipe for 3D. |
| 41 | * Whenever needed to have a pass through - we do it. |
| 42 | * If there is a special need for special/diff behavior |
| 43 | * do it here |
| 44 | * PANEL is always EXTERNAL for this pipe. |
| 45 | * CHAN = 0,1 it's either Channel 1 or channel 2 needed for |
| 46 | * 3D crop and position */ |
| 47 | template <int CHAN> |
| 48 | class M3DExtPipe : utils::NoCopy { |
| 49 | public: |
| 50 | /* Please look at overlayGenPipe.h for info */ |
| 51 | explicit M3DExtPipe(); |
| 52 | ~M3DExtPipe(); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 53 | bool init(RotatorBase* rot); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 54 | bool close(); |
| 55 | bool commit(); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 56 | bool queueBuffer(int fd, uint32_t offset); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 57 | bool waitForVsync(); |
| 58 | bool setCrop(const utils::Dim& d); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 59 | bool setPosition(const utils::Dim& dim); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 60 | bool setTransform(const utils::eTransform& param); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 61 | bool setSource(const utils::PipeArgs& args); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 62 | utils::eOverlayPipeType getOvPipeType() const; |
| 63 | void dump() const; |
| 64 | private: |
| 65 | overlay::GenericPipe<utils::EXTERNAL> mM3d; |
| 66 | // Cache the M3D format |
| 67 | uint32_t mM3Dfmt; |
| 68 | }; |
| 69 | |
| 70 | ///////////// M3DPrimary Pipe //////////////////////////// |
| 71 | /** |
| 72 | * A specific impl of GenericPipe for 3D. |
| 73 | * Whenever needed to have a pass through - we do it. |
| 74 | * If there is a special need for special/diff behavior |
| 75 | * do it here |
| 76 | * PANEL is always PRIMARY for this pipe. |
| 77 | * CHAN = 0,1 it's either Channel 1 or channel 2 needed for |
| 78 | * 3D crop and position */ |
| 79 | template <int CHAN> |
| 80 | class M3DPrimaryPipe : utils::NoCopy { |
| 81 | public: |
| 82 | /* Please look at overlayGenPipe.h for info */ |
| 83 | explicit M3DPrimaryPipe(); |
| 84 | ~M3DPrimaryPipe(); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 85 | bool init(RotatorBase* rot); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 86 | bool close(); |
| 87 | bool commit(); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 88 | bool queueBuffer(int fd, uint32_t offset); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 89 | bool waitForVsync(); |
| 90 | bool setCrop(const utils::Dim& d); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 91 | bool setPosition(const utils::Dim& dim); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 92 | bool setTransform(const utils::eTransform& param); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 93 | bool setSource(const utils::PipeArgs& args); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 94 | utils::eOverlayPipeType getOvPipeType() const; |
| 95 | void dump() const; |
| 96 | private: |
| 97 | overlay::GenericPipe<utils::PRIMARY> mM3d; |
| 98 | // Cache the M3D format |
| 99 | uint32_t mM3Dfmt; |
| 100 | }; |
| 101 | |
| 102 | ///////////// S3DExt Pipe //////////////////////////////// |
| 103 | /** |
| 104 | * A specific impl of GenericPipe for 3D. |
| 105 | * Whenever needed to have a pass through - we do it. |
| 106 | * If there is a special need for special/diff behavior |
| 107 | * do it here. |
| 108 | * PANEL is always EXTERNAL for this pipe. |
| 109 | * CHAN = 0,1 it's either Channel 1 or channel 2 needed for |
| 110 | * 3D crop and position */ |
| 111 | template <int CHAN> |
| 112 | class S3DExtPipe : utils::NoCopy { |
| 113 | public: |
| 114 | /* Please look at overlayGenPipe.h for info */ |
| 115 | explicit S3DExtPipe(); |
| 116 | ~S3DExtPipe(); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 117 | bool init(RotatorBase* rot); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 118 | bool close(); |
| 119 | bool commit(); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 120 | bool queueBuffer(int fd, uint32_t offset); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 121 | bool waitForVsync(); |
| 122 | bool setCrop(const utils::Dim& d); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 123 | bool setPosition(const utils::Dim& dim); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 124 | bool setTransform(const utils::eTransform& param); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 125 | bool setSource(const utils::PipeArgs& args); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 126 | utils::eOverlayPipeType getOvPipeType() const; |
| 127 | void dump() const; |
| 128 | private: |
| 129 | overlay::GenericPipe<utils::EXTERNAL> mS3d; |
| 130 | // Cache the 3D format |
| 131 | uint32_t mS3Dfmt; |
| 132 | }; |
| 133 | |
| 134 | ///////////// S3DPrimary Pipe //////////////////////////// |
| 135 | /** |
| 136 | * A specific impl of GenericPipe for 3D. |
| 137 | * Whenever needed to have a pass through - we do it. |
| 138 | * If there is a special need for special/diff behavior |
| 139 | * do it here |
| 140 | * PANEL is always PRIMARY for this pipe. |
| 141 | * CHAN = 0,1 it's either Channel 1 or channel 2 needed for |
| 142 | * 3D crop and position */ |
| 143 | template <int CHAN> |
| 144 | class S3DPrimaryPipe : utils::NoCopy { |
| 145 | public: |
| 146 | /* Please look at overlayGenPipe.h for info */ |
| 147 | explicit S3DPrimaryPipe(); |
| 148 | ~S3DPrimaryPipe(); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 149 | bool init(RotatorBase* rot); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 150 | bool close(); |
| 151 | bool commit(); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 152 | bool queueBuffer(int fd, uint32_t offset); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 153 | bool waitForVsync(); |
| 154 | bool setCrop(const utils::Dim& d); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 155 | bool setPosition(const utils::Dim& dim); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 156 | bool setTransform(const utils::eTransform& param); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 157 | bool setSource(const utils::PipeArgs& args); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 158 | utils::eOverlayPipeType getOvPipeType() const; |
| 159 | void dump() const; |
| 160 | private: |
| 161 | /* needed for 3D related IOCTL */ |
| 162 | MdpCtrl3D mCtrl3D; |
| 163 | overlay::GenericPipe<utils::PRIMARY> mS3d; |
| 164 | // Cache the 3D format |
| 165 | uint32_t mS3Dfmt; |
| 166 | }; |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | //------------------------Inlines and Templates-------------------------- |
| 172 | |
| 173 | |
| 174 | ///////////// M3DExt Pipe //////////////////////////// |
| 175 | template <int CHAN> |
| 176 | inline M3DExtPipe<CHAN>::M3DExtPipe() : mM3Dfmt(0) {} |
| 177 | template <int CHAN> |
| 178 | inline M3DExtPipe<CHAN>::~M3DExtPipe() { close(); } |
| 179 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 180 | inline bool M3DExtPipe<CHAN>::init(RotatorBase* rot) { |
| 181 | ALOGE_IF(DEBUG_OVERLAY, "M3DExtPipe init"); |
| 182 | if(!mM3d.init(rot)) { |
| 183 | ALOGE("3Dpipe failed to init"); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 184 | return false; |
| 185 | } |
| 186 | return true; |
| 187 | } |
| 188 | template <int CHAN> |
| 189 | inline bool M3DExtPipe<CHAN>::close() { |
| 190 | return mM3d.close(); |
| 191 | } |
| 192 | template <int CHAN> |
| 193 | inline bool M3DExtPipe<CHAN>::commit() { return mM3d.commit(); } |
| 194 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 195 | inline bool M3DExtPipe<CHAN>::queueBuffer(int fd, uint32_t offset) { |
| 196 | return mM3d.queueBuffer(fd, offset); |
| 197 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 198 | template <int CHAN> |
| 199 | inline bool M3DExtPipe<CHAN>::waitForVsync() { |
| 200 | return mM3d.waitForVsync(); } |
| 201 | template <int CHAN> |
| 202 | inline bool M3DExtPipe<CHAN>::setCrop(const utils::Dim& d) { |
| 203 | utils::Dim _dim; |
| 204 | if(!utils::getCropS3D<CHAN>(d, _dim, mM3Dfmt)){ |
| 205 | ALOGE("M3DExtPipe setCrop failed to getCropS3D"); |
| 206 | _dim = d; |
| 207 | } |
| 208 | return mM3d.setCrop(_dim); |
| 209 | } |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 210 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 211 | template <int CHAN> |
| 212 | inline bool M3DExtPipe<CHAN>::setPosition(const utils::Dim& d) { |
| 213 | utils::Dim _dim; |
| 214 | // original setPositionHandleState has getPositionS3D(...,true) |
| 215 | // which means format is HAL_3D_OUT_SBS_MASK |
| 216 | // HAL_3D_OUT_SBS_MASK is 0x1000 >> 12 == 0x1 as the orig |
| 217 | // code suggets |
| 218 | utils::Whf _whf(mM3d.getScreenInfo().mFBWidth, |
| 219 | mM3d.getScreenInfo().mFBHeight, |
| 220 | mM3Dfmt); |
| 221 | if(!utils::getPositionS3D<CHAN>(_whf, _dim)) { |
| 222 | ALOGE("S3DPrimaryPipe setPosition err in getPositionS3D"); |
| 223 | _dim = d; |
| 224 | } |
| 225 | return mM3d.setPosition(_dim); |
| 226 | } |
| 227 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 228 | inline bool M3DExtPipe<CHAN>::setTransform(const utils::eTransform& param) { |
| 229 | return mM3d.setTransform(param); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 230 | } |
| 231 | template <int CHAN> |
| 232 | inline bool M3DExtPipe<CHAN>::setSource(const utils::PipeArgs& args) |
| 233 | { |
| 234 | // extract 3D fmt |
| 235 | mM3Dfmt = utils::format3DInput(utils::getS3DFormat(args.whf.format)) | |
| 236 | utils::HAL_3D_OUT_MONOS_MASK; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 237 | return mM3d.setSource(args); |
| 238 | } |
| 239 | template <int CHAN> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 240 | inline utils::eOverlayPipeType M3DExtPipe<CHAN>::getOvPipeType() const { |
| 241 | return utils::OV_PIPE_TYPE_M3D_EXTERNAL; |
| 242 | } |
| 243 | template <int CHAN> |
| 244 | inline void M3DExtPipe<CHAN>::dump() const { |
| 245 | ALOGE("M3DExtPipe Pipe fmt=%d", mM3Dfmt); |
| 246 | mM3d.dump(); |
| 247 | } |
| 248 | |
| 249 | |
| 250 | ///////////// M3DPrimary Pipe //////////////////////////// |
| 251 | template <int CHAN> |
| 252 | inline M3DPrimaryPipe<CHAN>::M3DPrimaryPipe() : mM3Dfmt(0) {} |
| 253 | template <int CHAN> |
| 254 | inline M3DPrimaryPipe<CHAN>::~M3DPrimaryPipe() { close(); } |
| 255 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 256 | inline bool M3DPrimaryPipe<CHAN>::init(RotatorBase* rot) { |
| 257 | ALOGE_IF(DEBUG_OVERLAY, "M3DPrimaryPipe init"); |
| 258 | if(!mM3d.init(rot)) { |
| 259 | ALOGE("3Dpipe failed to init"); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 260 | return false; |
| 261 | } |
| 262 | return true; |
| 263 | } |
| 264 | template <int CHAN> |
| 265 | inline bool M3DPrimaryPipe<CHAN>::close() { |
| 266 | return mM3d.close(); |
| 267 | } |
| 268 | template <int CHAN> |
| 269 | inline bool M3DPrimaryPipe<CHAN>::commit() { return mM3d.commit(); } |
| 270 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 271 | inline bool M3DPrimaryPipe<CHAN>::queueBuffer(int fd, uint32_t offset) { |
| 272 | return mM3d.queueBuffer(fd, offset); |
| 273 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 274 | template <int CHAN> |
| 275 | inline bool M3DPrimaryPipe<CHAN>::waitForVsync() { |
| 276 | return mM3d.waitForVsync(); } |
| 277 | template <int CHAN> |
| 278 | inline bool M3DPrimaryPipe<CHAN>::setCrop(const utils::Dim& d) { |
| 279 | utils::Dim _dim; |
| 280 | if(!utils::getCropS3D<CHAN>(d, _dim, mM3Dfmt)){ |
| 281 | ALOGE("M3DPrimaryPipe setCrop failed to getCropS3D"); |
| 282 | _dim = d; |
| 283 | } |
| 284 | return mM3d.setCrop(_dim); |
| 285 | } |
| 286 | template <int CHAN> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 287 | inline bool M3DPrimaryPipe<CHAN>::setPosition(const utils::Dim& d) { |
| 288 | return mM3d.setPosition(d); |
| 289 | } |
| 290 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 291 | inline bool M3DPrimaryPipe<CHAN>::setTransform(const utils::eTransform& param) { |
| 292 | return mM3d.setTransform(param); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 293 | } |
| 294 | template <int CHAN> |
| 295 | inline bool M3DPrimaryPipe<CHAN>::setSource(const utils::PipeArgs& args) |
| 296 | { |
| 297 | // extract 3D fmt |
| 298 | mM3Dfmt = utils::format3DInput(utils::getS3DFormat(args.whf.format)) | |
| 299 | utils::HAL_3D_OUT_MONOS_MASK; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 300 | return mM3d.setSource(args); |
| 301 | } |
| 302 | template <int CHAN> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 303 | inline utils::eOverlayPipeType M3DPrimaryPipe<CHAN>::getOvPipeType() const { |
| 304 | return utils::OV_PIPE_TYPE_M3D_PRIMARY; |
| 305 | } |
| 306 | template <int CHAN> |
| 307 | inline void M3DPrimaryPipe<CHAN>::dump() const { |
| 308 | ALOGE("M3DPrimaryPipe Pipe fmt=%d", mM3Dfmt); |
| 309 | mM3d.dump(); |
| 310 | } |
| 311 | |
| 312 | ///////////// S3DExt Pipe //////////////////////////////// |
| 313 | template <int CHAN> |
| 314 | inline S3DExtPipe<CHAN>::S3DExtPipe() : mS3Dfmt(0) {} |
| 315 | template <int CHAN> |
| 316 | inline S3DExtPipe<CHAN>::~S3DExtPipe() { close(); } |
| 317 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 318 | inline bool S3DExtPipe<CHAN>::init(RotatorBase* rot) { |
| 319 | ALOGE_IF(DEBUG_OVERLAY, "S3DExtPipe init"); |
| 320 | if(!mS3d.init(rot)) { |
| 321 | ALOGE("3Dpipe failed to init"); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 322 | return false; |
| 323 | } |
| 324 | return true; |
| 325 | } |
| 326 | template <int CHAN> |
| 327 | inline bool S3DExtPipe<CHAN>::close() { |
| 328 | if(!utils::send3DInfoPacket(0)) { |
| 329 | ALOGE("S3DExtPipe close failed send3D info packet"); |
| 330 | } |
| 331 | return mS3d.close(); |
| 332 | } |
| 333 | template <int CHAN> |
| 334 | inline bool S3DExtPipe<CHAN>::commit() { return mS3d.commit(); } |
| 335 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 336 | inline bool S3DExtPipe<CHAN>::queueBuffer(int fd, uint32_t offset) { |
| 337 | return mS3d.queueBuffer(fd, offset); |
| 338 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 339 | template <int CHAN> |
| 340 | inline bool S3DExtPipe<CHAN>::waitForVsync() { |
| 341 | return mS3d.waitForVsync(); } |
| 342 | template <int CHAN> |
| 343 | inline bool S3DExtPipe<CHAN>::setCrop(const utils::Dim& d) { |
| 344 | utils::Dim _dim; |
| 345 | if(!utils::getCropS3D<CHAN>(d, _dim, mS3Dfmt)){ |
| 346 | ALOGE("S3DExtPipe setCrop failed to getCropS3D"); |
| 347 | _dim = d; |
| 348 | } |
| 349 | return mS3d.setCrop(_dim); |
| 350 | } |
| 351 | template <int CHAN> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 352 | inline bool S3DExtPipe<CHAN>::setPosition(const utils::Dim& d) |
| 353 | { |
| 354 | utils::Dim _dim; |
| 355 | utils::Whf _whf(mS3d.getScreenInfo().mFBWidth, |
| 356 | mS3d.getScreenInfo().mFBHeight, |
| 357 | mS3Dfmt); |
| 358 | if(!utils::getPositionS3D<CHAN>(_whf, _dim)) { |
| 359 | ALOGE("S3DExtPipe setPosition err in getPositionS3D"); |
| 360 | _dim = d; |
| 361 | } |
| 362 | return mS3d.setPosition(_dim); |
| 363 | } |
| 364 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 365 | inline bool S3DExtPipe<CHAN>::setTransform(const utils::eTransform& param) { |
| 366 | return mS3d.setTransform(param); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 367 | } |
| 368 | template <int CHAN> |
| 369 | inline bool S3DExtPipe<CHAN>::setSource(const utils::PipeArgs& args) { |
| 370 | mS3Dfmt = utils::getS3DFormat(args.whf.format); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 371 | return mS3d.setSource(args); |
| 372 | } |
| 373 | template <int CHAN> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 374 | inline utils::eOverlayPipeType S3DExtPipe<CHAN>::getOvPipeType() const { |
| 375 | return utils::OV_PIPE_TYPE_S3D_EXTERNAL; |
| 376 | } |
| 377 | template <int CHAN> |
| 378 | inline void S3DExtPipe<CHAN>::dump() const { |
| 379 | ALOGE("S3DExtPipe Pipe fmt=%d", mS3Dfmt); |
| 380 | mS3d.dump(); |
| 381 | } |
| 382 | |
| 383 | ///////////// S3DPrimary Pipe //////////////////////////// |
| 384 | template <int CHAN> |
| 385 | inline S3DPrimaryPipe<CHAN>::S3DPrimaryPipe() : mS3Dfmt(0) {} |
| 386 | template <int CHAN> |
| 387 | inline S3DPrimaryPipe<CHAN>::~S3DPrimaryPipe() { close(); } |
| 388 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 389 | inline bool S3DPrimaryPipe<CHAN>::init(RotatorBase* rot) { |
| 390 | ALOGE_IF(DEBUG_OVERLAY, "S3DPrimaryPipe init"); |
| 391 | if(!mS3d.init(rot)) { |
| 392 | ALOGE("3Dpipe failed to init"); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 393 | return false; |
| 394 | } |
| 395 | // set the ctrl fd |
| 396 | mCtrl3D.setFd(mS3d.getCtrlFd()); |
| 397 | return true; |
| 398 | } |
| 399 | template <int CHAN> |
| 400 | inline bool S3DPrimaryPipe<CHAN>::close() { |
| 401 | if(!utils::enableBarrier(0)) { |
| 402 | ALOGE("S3DExtPipe close failed enable barrier"); |
| 403 | } |
| 404 | mCtrl3D.close(); |
| 405 | return mS3d.close(); |
| 406 | } |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 407 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 408 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 409 | inline bool S3DPrimaryPipe<CHAN>::commit() { |
| 410 | uint32_t fmt = mS3Dfmt & utils::OUTPUT_3D_MASK; |
| 411 | if(!utils::send3DInfoPacket(fmt)){ |
| 412 | ALOGE("Error S3DExtPipe start error send3DInfoPacket %d", fmt); |
| 413 | return false; |
| 414 | } |
| 415 | return mS3d.commit(); |
| 416 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 417 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 418 | inline bool S3DPrimaryPipe<CHAN>::queueBuffer(int fd, uint32_t offset) { |
| 419 | return mS3d.queueBuffer(fd, offset); |
| 420 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 421 | template <int CHAN> |
| 422 | inline bool S3DPrimaryPipe<CHAN>::waitForVsync() { |
| 423 | return mS3d.waitForVsync(); } |
| 424 | template <int CHAN> |
| 425 | inline bool S3DPrimaryPipe<CHAN>::setCrop(const utils::Dim& d) { |
| 426 | utils::Dim _dim; |
| 427 | if(!utils::getCropS3D<CHAN>(d, _dim, mS3Dfmt)){ |
| 428 | ALOGE("S3DPrimaryPipe setCrop failed to getCropS3D"); |
| 429 | _dim = d; |
| 430 | } |
| 431 | return mS3d.setCrop(_dim); |
| 432 | } |
| 433 | template <int CHAN> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 434 | inline bool S3DPrimaryPipe<CHAN>::setPosition(const utils::Dim& d) |
| 435 | { |
| 436 | utils::Whf fbwhf(mS3d.getScreenInfo().mFBWidth, |
| 437 | mS3d.getScreenInfo().mFBHeight, |
| 438 | 0 /* fmt dont care*/); |
| 439 | mCtrl3D.setWh(fbwhf); |
| 440 | if(!mCtrl3D.useVirtualFB()) { |
| 441 | ALOGE("Failed to use VFB on %d (non fatal)", utils::FB0); |
| 442 | return false; |
| 443 | } |
| 444 | utils::Dim _dim; |
| 445 | // original setPositionHandleState has getPositionS3D(...,true) |
| 446 | // which means format is HAL_3D_OUT_SBS_MASK |
| 447 | // HAL_3D_OUT_SBS_MASK is 0x1000 >> 12 == 0x1 as the orig |
| 448 | // code suggets |
| 449 | utils::Whf _whf(d.w, d.h, utils::HAL_3D_OUT_SBS_MASK); |
| 450 | if(!utils::getPositionS3D<CHAN>(_whf, _dim)) { |
| 451 | ALOGE("S3DPrimaryPipe setPosition err in getPositionS3D"); |
| 452 | _dim = d; |
| 453 | } |
| 454 | return mS3d.setPosition(_dim); |
| 455 | } |
| 456 | |
| 457 | /* for S3DPrimaryPipe, we need to have barriers once |
| 458 | * So the easiest way to achieve it, is to make sure FB0 is having it before |
| 459 | * setParam is running */ |
| 460 | template <> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 461 | inline bool S3DPrimaryPipe<utils::OV_PIPE0>::setTransform( |
| 462 | const utils::eTransform& param) { |
| 463 | uint32_t barrier=0; |
| 464 | switch(param) { |
| 465 | case utils::OVERLAY_TRANSFORM_ROT_90: |
| 466 | case utils::OVERLAY_TRANSFORM_ROT_270: |
| 467 | barrier = utils::BARRIER_LAND; |
| 468 | break; |
| 469 | default: |
| 470 | barrier = utils::BARRIER_PORT; |
| 471 | break; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 472 | } |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 473 | if(!utils::enableBarrier(barrier)) { |
| 474 | ALOGE("S3DPrimaryPipe setTransform failed to enable barrier"); |
| 475 | } |
| 476 | return mS3d.setTransform(param); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | template <int CHAN> |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame^] | 480 | inline bool S3DPrimaryPipe<CHAN>::setTransform(const utils::eTransform& param) { |
| 481 | return mS3d.setTransform(param); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 482 | } |
| 483 | template <int CHAN> |
| 484 | inline bool S3DPrimaryPipe<CHAN>::setSource(const utils::PipeArgs& args) |
| 485 | { |
| 486 | mS3Dfmt = utils::getS3DFormat(args.whf.format); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 487 | return mS3d.setSource(args); |
| 488 | } |
| 489 | template <int CHAN> |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 490 | inline utils::eOverlayPipeType S3DPrimaryPipe<CHAN>::getOvPipeType() const { |
| 491 | return utils::OV_PIPE_TYPE_S3D_PRIMARY; |
| 492 | } |
| 493 | template <int CHAN> |
| 494 | inline void S3DPrimaryPipe<CHAN>::dump() const { |
| 495 | ALOGE("S3DPrimaryPipe Pipe fmt=%d", mS3Dfmt); |
| 496 | mS3d.dump(); |
| 497 | } |
| 498 | |
| 499 | } // overlay |
| 500 | |
| 501 | #endif // OVERLAY_M3D_EXT_PIPE_H |