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(); |
| 53 | bool open(RotatorBase* rot); |
| 54 | bool close(); |
| 55 | bool commit(); |
| 56 | void setId(int id); |
| 57 | void setMemoryId(int id); |
| 58 | bool queueBuffer(uint32_t offset); |
| 59 | bool dequeueBuffer(void*& buf); |
| 60 | bool waitForVsync(); |
| 61 | bool setCrop(const utils::Dim& d); |
| 62 | bool start(const utils::PipeArgs& args); |
| 63 | bool setPosition(const utils::Dim& dim); |
| 64 | bool setParameter(const utils::Params& param); |
| 65 | bool setSource(const utils::PipeArgs& args); |
| 66 | const utils::PipeArgs& getArgs() const; |
| 67 | utils::eOverlayPipeType getOvPipeType() const; |
| 68 | void dump() const; |
| 69 | private: |
| 70 | overlay::GenericPipe<utils::EXTERNAL> mM3d; |
| 71 | // Cache the M3D format |
| 72 | uint32_t mM3Dfmt; |
| 73 | }; |
| 74 | |
| 75 | ///////////// M3DPrimary Pipe //////////////////////////// |
| 76 | /** |
| 77 | * A specific impl of GenericPipe for 3D. |
| 78 | * Whenever needed to have a pass through - we do it. |
| 79 | * If there is a special need for special/diff behavior |
| 80 | * do it here |
| 81 | * PANEL is always PRIMARY for this pipe. |
| 82 | * CHAN = 0,1 it's either Channel 1 or channel 2 needed for |
| 83 | * 3D crop and position */ |
| 84 | template <int CHAN> |
| 85 | class M3DPrimaryPipe : utils::NoCopy { |
| 86 | public: |
| 87 | /* Please look at overlayGenPipe.h for info */ |
| 88 | explicit M3DPrimaryPipe(); |
| 89 | ~M3DPrimaryPipe(); |
| 90 | bool open(RotatorBase* rot); |
| 91 | bool close(); |
| 92 | bool commit(); |
| 93 | void setId(int id); |
| 94 | void setMemoryId(int id); |
| 95 | bool queueBuffer(uint32_t offset); |
| 96 | bool dequeueBuffer(void*& buf); |
| 97 | bool waitForVsync(); |
| 98 | bool setCrop(const utils::Dim& d); |
| 99 | bool start(const utils::PipeArgs& args); |
| 100 | bool setPosition(const utils::Dim& dim); |
| 101 | bool setParameter(const utils::Params& param); |
| 102 | bool setSource(const utils::PipeArgs& args); |
| 103 | const utils::PipeArgs& getArgs() const; |
| 104 | utils::eOverlayPipeType getOvPipeType() const; |
| 105 | void dump() const; |
| 106 | private: |
| 107 | overlay::GenericPipe<utils::PRIMARY> mM3d; |
| 108 | // Cache the M3D format |
| 109 | uint32_t mM3Dfmt; |
| 110 | }; |
| 111 | |
| 112 | ///////////// S3DExt Pipe //////////////////////////////// |
| 113 | /** |
| 114 | * A specific impl of GenericPipe for 3D. |
| 115 | * Whenever needed to have a pass through - we do it. |
| 116 | * If there is a special need for special/diff behavior |
| 117 | * do it here. |
| 118 | * PANEL is always EXTERNAL for this pipe. |
| 119 | * CHAN = 0,1 it's either Channel 1 or channel 2 needed for |
| 120 | * 3D crop and position */ |
| 121 | template <int CHAN> |
| 122 | class S3DExtPipe : utils::NoCopy { |
| 123 | public: |
| 124 | /* Please look at overlayGenPipe.h for info */ |
| 125 | explicit S3DExtPipe(); |
| 126 | ~S3DExtPipe(); |
| 127 | bool open(RotatorBase* rot); |
| 128 | bool close(); |
| 129 | bool commit(); |
| 130 | void setId(int id); |
| 131 | void setMemoryId(int id); |
| 132 | bool queueBuffer(uint32_t offset); |
| 133 | bool dequeueBuffer(void*& buf); |
| 134 | bool waitForVsync(); |
| 135 | bool setCrop(const utils::Dim& d); |
| 136 | bool start(const utils::PipeArgs& args); |
| 137 | bool setPosition(const utils::Dim& dim); |
| 138 | bool setParameter(const utils::Params& param); |
| 139 | bool setSource(const utils::PipeArgs& args); |
| 140 | const utils::PipeArgs& getArgs() const; |
| 141 | utils::eOverlayPipeType getOvPipeType() const; |
| 142 | void dump() const; |
| 143 | private: |
| 144 | overlay::GenericPipe<utils::EXTERNAL> mS3d; |
| 145 | // Cache the 3D format |
| 146 | uint32_t mS3Dfmt; |
| 147 | }; |
| 148 | |
| 149 | ///////////// S3DPrimary Pipe //////////////////////////// |
| 150 | /** |
| 151 | * A specific impl of GenericPipe for 3D. |
| 152 | * Whenever needed to have a pass through - we do it. |
| 153 | * If there is a special need for special/diff behavior |
| 154 | * do it here |
| 155 | * PANEL is always PRIMARY for this pipe. |
| 156 | * CHAN = 0,1 it's either Channel 1 or channel 2 needed for |
| 157 | * 3D crop and position */ |
| 158 | template <int CHAN> |
| 159 | class S3DPrimaryPipe : utils::NoCopy { |
| 160 | public: |
| 161 | /* Please look at overlayGenPipe.h for info */ |
| 162 | explicit S3DPrimaryPipe(); |
| 163 | ~S3DPrimaryPipe(); |
| 164 | bool open(RotatorBase* rot); |
| 165 | bool close(); |
| 166 | bool commit(); |
| 167 | void setId(int id); |
| 168 | void setMemoryId(int id); |
| 169 | bool queueBuffer(uint32_t offset); |
| 170 | bool dequeueBuffer(void*& buf); |
| 171 | bool waitForVsync(); |
| 172 | bool setCrop(const utils::Dim& d); |
| 173 | bool start(const utils::PipeArgs& args); |
| 174 | bool setPosition(const utils::Dim& dim); |
| 175 | bool setParameter(const utils::Params& param); |
| 176 | bool setSource(const utils::PipeArgs& args); |
| 177 | const utils::PipeArgs& getArgs() const; |
| 178 | utils::eOverlayPipeType getOvPipeType() const; |
| 179 | void dump() const; |
| 180 | private: |
| 181 | /* needed for 3D related IOCTL */ |
| 182 | MdpCtrl3D mCtrl3D; |
| 183 | overlay::GenericPipe<utils::PRIMARY> mS3d; |
| 184 | // Cache the 3D format |
| 185 | uint32_t mS3Dfmt; |
| 186 | }; |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | //------------------------Inlines and Templates-------------------------- |
| 192 | |
| 193 | |
| 194 | ///////////// M3DExt Pipe //////////////////////////// |
| 195 | template <int CHAN> |
| 196 | inline M3DExtPipe<CHAN>::M3DExtPipe() : mM3Dfmt(0) {} |
| 197 | template <int CHAN> |
| 198 | inline M3DExtPipe<CHAN>::~M3DExtPipe() { close(); } |
| 199 | template <int CHAN> |
| 200 | inline bool M3DExtPipe<CHAN>::open(RotatorBase* rot) { |
| 201 | ALOGE_IF(DEBUG_OVERLAY, "M3DExtPipe open"); |
| 202 | if(!mM3d.open(rot)) { |
| 203 | ALOGE("3Dpipe failed to open"); |
| 204 | return false; |
| 205 | } |
| 206 | return true; |
| 207 | } |
| 208 | template <int CHAN> |
| 209 | inline bool M3DExtPipe<CHAN>::close() { |
| 210 | return mM3d.close(); |
| 211 | } |
| 212 | template <int CHAN> |
| 213 | inline bool M3DExtPipe<CHAN>::commit() { return mM3d.commit(); } |
| 214 | template <int CHAN> |
| 215 | inline void M3DExtPipe<CHAN>::setId(int id) { mM3d.setId(id); } |
| 216 | template <int CHAN> |
| 217 | inline void M3DExtPipe<CHAN>::setMemoryId(int id) { mM3d.setMemoryId(id); } |
| 218 | template <int CHAN> |
| 219 | inline bool M3DExtPipe<CHAN>::queueBuffer(uint32_t offset) { |
| 220 | return mM3d.queueBuffer(offset); } |
| 221 | template <int CHAN> |
| 222 | inline bool M3DExtPipe<CHAN>::dequeueBuffer(void*& buf) { |
| 223 | return mM3d.dequeueBuffer(buf); } |
| 224 | template <int CHAN> |
| 225 | inline bool M3DExtPipe<CHAN>::waitForVsync() { |
| 226 | return mM3d.waitForVsync(); } |
| 227 | template <int CHAN> |
| 228 | inline bool M3DExtPipe<CHAN>::setCrop(const utils::Dim& d) { |
| 229 | utils::Dim _dim; |
| 230 | if(!utils::getCropS3D<CHAN>(d, _dim, mM3Dfmt)){ |
| 231 | ALOGE("M3DExtPipe setCrop failed to getCropS3D"); |
| 232 | _dim = d; |
| 233 | } |
| 234 | return mM3d.setCrop(_dim); |
| 235 | } |
| 236 | template <int CHAN> |
| 237 | inline bool M3DExtPipe<CHAN>::start(const utils::PipeArgs& args) { |
| 238 | if(!mM3d.start(args)) { |
| 239 | ALOGE("M3DExtPipe start failed"); |
| 240 | return false; |
| 241 | } |
| 242 | return true; |
| 243 | } |
| 244 | template <int CHAN> |
| 245 | inline bool M3DExtPipe<CHAN>::setPosition(const utils::Dim& d) { |
| 246 | utils::Dim _dim; |
| 247 | // original setPositionHandleState has getPositionS3D(...,true) |
| 248 | // which means format is HAL_3D_OUT_SBS_MASK |
| 249 | // HAL_3D_OUT_SBS_MASK is 0x1000 >> 12 == 0x1 as the orig |
| 250 | // code suggets |
| 251 | utils::Whf _whf(mM3d.getScreenInfo().mFBWidth, |
| 252 | mM3d.getScreenInfo().mFBHeight, |
| 253 | mM3Dfmt); |
| 254 | if(!utils::getPositionS3D<CHAN>(_whf, _dim)) { |
| 255 | ALOGE("S3DPrimaryPipe setPosition err in getPositionS3D"); |
| 256 | _dim = d; |
| 257 | } |
| 258 | return mM3d.setPosition(_dim); |
| 259 | } |
| 260 | template <int CHAN> |
| 261 | inline bool M3DExtPipe<CHAN>::setParameter(const utils::Params& param) { |
| 262 | return mM3d.setParameter(param); |
| 263 | } |
| 264 | template <int CHAN> |
| 265 | inline bool M3DExtPipe<CHAN>::setSource(const utils::PipeArgs& args) |
| 266 | { |
| 267 | // extract 3D fmt |
| 268 | mM3Dfmt = utils::format3DInput(utils::getS3DFormat(args.whf.format)) | |
| 269 | utils::HAL_3D_OUT_MONOS_MASK; |
| 270 | if(mM3d.isClosed()){ |
| 271 | if(!this->start(args)) { |
| 272 | ALOGE("M3DExtPipe setSource failed to start"); |
| 273 | return false; |
| 274 | } |
| 275 | } |
| 276 | return mM3d.setSource(args); |
| 277 | } |
| 278 | template <int CHAN> |
| 279 | inline const utils::PipeArgs& M3DExtPipe<CHAN>::getArgs() const { |
| 280 | return mM3d.getArgs(); |
| 281 | } |
| 282 | template <int CHAN> |
| 283 | inline utils::eOverlayPipeType M3DExtPipe<CHAN>::getOvPipeType() const { |
| 284 | return utils::OV_PIPE_TYPE_M3D_EXTERNAL; |
| 285 | } |
| 286 | template <int CHAN> |
| 287 | inline void M3DExtPipe<CHAN>::dump() const { |
| 288 | ALOGE("M3DExtPipe Pipe fmt=%d", mM3Dfmt); |
| 289 | mM3d.dump(); |
| 290 | } |
| 291 | |
| 292 | |
| 293 | ///////////// M3DPrimary Pipe //////////////////////////// |
| 294 | template <int CHAN> |
| 295 | inline M3DPrimaryPipe<CHAN>::M3DPrimaryPipe() : mM3Dfmt(0) {} |
| 296 | template <int CHAN> |
| 297 | inline M3DPrimaryPipe<CHAN>::~M3DPrimaryPipe() { close(); } |
| 298 | template <int CHAN> |
| 299 | inline bool M3DPrimaryPipe<CHAN>::open(RotatorBase* rot) { |
| 300 | ALOGE_IF(DEBUG_OVERLAY, "M3DPrimaryPipe open"); |
| 301 | if(!mM3d.open(rot)) { |
| 302 | ALOGE("3Dpipe failed to open"); |
| 303 | return false; |
| 304 | } |
| 305 | return true; |
| 306 | } |
| 307 | template <int CHAN> |
| 308 | inline bool M3DPrimaryPipe<CHAN>::close() { |
| 309 | return mM3d.close(); |
| 310 | } |
| 311 | template <int CHAN> |
| 312 | inline bool M3DPrimaryPipe<CHAN>::commit() { return mM3d.commit(); } |
| 313 | template <int CHAN> |
| 314 | inline void M3DPrimaryPipe<CHAN>::setId(int id) { mM3d.setId(id); } |
| 315 | template <int CHAN> |
| 316 | inline void M3DPrimaryPipe<CHAN>::setMemoryId(int id) { mM3d.setMemoryId(id); } |
| 317 | template <int CHAN> |
| 318 | inline bool M3DPrimaryPipe<CHAN>::queueBuffer(uint32_t offset) { |
| 319 | return mM3d.queueBuffer(offset); } |
| 320 | template <int CHAN> |
| 321 | inline bool M3DPrimaryPipe<CHAN>::dequeueBuffer(void*& buf) { |
| 322 | return mM3d.dequeueBuffer(buf); } |
| 323 | template <int CHAN> |
| 324 | inline bool M3DPrimaryPipe<CHAN>::waitForVsync() { |
| 325 | return mM3d.waitForVsync(); } |
| 326 | template <int CHAN> |
| 327 | inline bool M3DPrimaryPipe<CHAN>::setCrop(const utils::Dim& d) { |
| 328 | utils::Dim _dim; |
| 329 | if(!utils::getCropS3D<CHAN>(d, _dim, mM3Dfmt)){ |
| 330 | ALOGE("M3DPrimaryPipe setCrop failed to getCropS3D"); |
| 331 | _dim = d; |
| 332 | } |
| 333 | return mM3d.setCrop(_dim); |
| 334 | } |
| 335 | template <int CHAN> |
| 336 | inline bool M3DPrimaryPipe<CHAN>::start(const utils::PipeArgs& args) { |
| 337 | if(!mM3d.start(args)) { |
| 338 | ALOGE("M3DPrimaryPipe start failed"); |
| 339 | return false; |
| 340 | } |
| 341 | return true; |
| 342 | } |
| 343 | template <int CHAN> |
| 344 | inline bool M3DPrimaryPipe<CHAN>::setPosition(const utils::Dim& d) { |
| 345 | return mM3d.setPosition(d); |
| 346 | } |
| 347 | template <int CHAN> |
| 348 | inline bool M3DPrimaryPipe<CHAN>::setParameter(const utils::Params& param) { |
| 349 | return mM3d.setParameter(param); |
| 350 | } |
| 351 | template <int CHAN> |
| 352 | inline bool M3DPrimaryPipe<CHAN>::setSource(const utils::PipeArgs& args) |
| 353 | { |
| 354 | // extract 3D fmt |
| 355 | mM3Dfmt = utils::format3DInput(utils::getS3DFormat(args.whf.format)) | |
| 356 | utils::HAL_3D_OUT_MONOS_MASK; |
| 357 | if (mM3d.isClosed()) { |
| 358 | if (!this->start(args)) { |
| 359 | ALOGE("M3DPrimaryPipe setSource failed to start"); |
| 360 | return false; |
| 361 | } |
| 362 | } |
| 363 | return mM3d.setSource(args); |
| 364 | } |
| 365 | template <int CHAN> |
| 366 | inline const utils::PipeArgs& M3DPrimaryPipe<CHAN>::getArgs() const { |
| 367 | return mM3d.getArgs(); |
| 368 | } |
| 369 | template <int CHAN> |
| 370 | inline utils::eOverlayPipeType M3DPrimaryPipe<CHAN>::getOvPipeType() const { |
| 371 | return utils::OV_PIPE_TYPE_M3D_PRIMARY; |
| 372 | } |
| 373 | template <int CHAN> |
| 374 | inline void M3DPrimaryPipe<CHAN>::dump() const { |
| 375 | ALOGE("M3DPrimaryPipe Pipe fmt=%d", mM3Dfmt); |
| 376 | mM3d.dump(); |
| 377 | } |
| 378 | |
| 379 | ///////////// S3DExt Pipe //////////////////////////////// |
| 380 | template <int CHAN> |
| 381 | inline S3DExtPipe<CHAN>::S3DExtPipe() : mS3Dfmt(0) {} |
| 382 | template <int CHAN> |
| 383 | inline S3DExtPipe<CHAN>::~S3DExtPipe() { close(); } |
| 384 | template <int CHAN> |
| 385 | inline bool S3DExtPipe<CHAN>::open(RotatorBase* rot) { |
| 386 | ALOGE_IF(DEBUG_OVERLAY, "S3DExtPipe open"); |
| 387 | if(!mS3d.open(rot)) { |
| 388 | ALOGE("3Dpipe failed to open"); |
| 389 | return false; |
| 390 | } |
| 391 | return true; |
| 392 | } |
| 393 | template <int CHAN> |
| 394 | inline bool S3DExtPipe<CHAN>::close() { |
| 395 | if(!utils::send3DInfoPacket(0)) { |
| 396 | ALOGE("S3DExtPipe close failed send3D info packet"); |
| 397 | } |
| 398 | return mS3d.close(); |
| 399 | } |
| 400 | template <int CHAN> |
| 401 | inline bool S3DExtPipe<CHAN>::commit() { return mS3d.commit(); } |
| 402 | template <int CHAN> |
| 403 | inline void S3DExtPipe<CHAN>::setId(int id) { mS3d.setId(id); } |
| 404 | template <int CHAN> |
| 405 | inline void S3DExtPipe<CHAN>::setMemoryId(int id) { mS3d.setMemoryId(id); } |
| 406 | template <int CHAN> |
| 407 | inline bool S3DExtPipe<CHAN>::queueBuffer(uint32_t offset) { |
| 408 | //this->dump(); |
| 409 | return mS3d.queueBuffer(offset); } |
| 410 | template <int CHAN> |
| 411 | inline bool S3DExtPipe<CHAN>::dequeueBuffer(void*& buf) { |
| 412 | return mS3d.dequeueBuffer(buf); } |
| 413 | template <int CHAN> |
| 414 | inline bool S3DExtPipe<CHAN>::waitForVsync() { |
| 415 | return mS3d.waitForVsync(); } |
| 416 | template <int CHAN> |
| 417 | inline bool S3DExtPipe<CHAN>::setCrop(const utils::Dim& d) { |
| 418 | utils::Dim _dim; |
| 419 | if(!utils::getCropS3D<CHAN>(d, _dim, mS3Dfmt)){ |
| 420 | ALOGE("S3DExtPipe setCrop failed to getCropS3D"); |
| 421 | _dim = d; |
| 422 | } |
| 423 | return mS3d.setCrop(_dim); |
| 424 | } |
| 425 | template <int CHAN> |
| 426 | inline bool S3DExtPipe<CHAN>::start(const utils::PipeArgs& args) { |
| 427 | OVASSERT(mS3Dfmt, "S3DExtPipe mS3Dfmt should not be 0 here"); |
| 428 | if(!mS3d.start(args)) { |
| 429 | ALOGE("S3DExtPipe start failed"); |
| 430 | return false; |
| 431 | } |
| 432 | uint32_t fmt = mS3Dfmt & utils::OUTPUT_3D_MASK; |
| 433 | if(!utils::send3DInfoPacket(fmt)){ |
| 434 | ALOGE("Error S3DExtPipe start error send3DInfoPacket %d", fmt); |
| 435 | return false; |
| 436 | } |
| 437 | return true; |
| 438 | } |
| 439 | template <int CHAN> |
| 440 | inline bool S3DExtPipe<CHAN>::setPosition(const utils::Dim& d) |
| 441 | { |
| 442 | utils::Dim _dim; |
| 443 | utils::Whf _whf(mS3d.getScreenInfo().mFBWidth, |
| 444 | mS3d.getScreenInfo().mFBHeight, |
| 445 | mS3Dfmt); |
| 446 | if(!utils::getPositionS3D<CHAN>(_whf, _dim)) { |
| 447 | ALOGE("S3DExtPipe setPosition err in getPositionS3D"); |
| 448 | _dim = d; |
| 449 | } |
| 450 | return mS3d.setPosition(_dim); |
| 451 | } |
| 452 | template <int CHAN> |
| 453 | inline bool S3DExtPipe<CHAN>::setParameter(const utils::Params& param) { |
| 454 | return mS3d.setParameter(param); |
| 455 | } |
| 456 | template <int CHAN> |
| 457 | inline bool S3DExtPipe<CHAN>::setSource(const utils::PipeArgs& args) { |
| 458 | mS3Dfmt = utils::getS3DFormat(args.whf.format); |
| 459 | if(mS3d.isClosed()){ |
| 460 | if(!this->start(args)) { |
| 461 | ALOGE("S3DExtPipe setSource failed to start"); |
| 462 | return false; |
| 463 | } |
| 464 | } |
| 465 | return mS3d.setSource(args); |
| 466 | } |
| 467 | template <int CHAN> |
| 468 | inline const utils::PipeArgs& S3DExtPipe<CHAN>::getArgs() const { |
| 469 | return mS3d.getArgs(); |
| 470 | } |
| 471 | template <int CHAN> |
| 472 | inline utils::eOverlayPipeType S3DExtPipe<CHAN>::getOvPipeType() const { |
| 473 | return utils::OV_PIPE_TYPE_S3D_EXTERNAL; |
| 474 | } |
| 475 | template <int CHAN> |
| 476 | inline void S3DExtPipe<CHAN>::dump() const { |
| 477 | ALOGE("S3DExtPipe Pipe fmt=%d", mS3Dfmt); |
| 478 | mS3d.dump(); |
| 479 | } |
| 480 | |
| 481 | ///////////// S3DPrimary Pipe //////////////////////////// |
| 482 | template <int CHAN> |
| 483 | inline S3DPrimaryPipe<CHAN>::S3DPrimaryPipe() : mS3Dfmt(0) {} |
| 484 | template <int CHAN> |
| 485 | inline S3DPrimaryPipe<CHAN>::~S3DPrimaryPipe() { close(); } |
| 486 | template <int CHAN> |
| 487 | inline bool S3DPrimaryPipe<CHAN>::open(RotatorBase* rot) { |
| 488 | ALOGE_IF(DEBUG_OVERLAY, "S3DPrimaryPipe open"); |
| 489 | if(!mS3d.open(rot)) { |
| 490 | ALOGE("3Dpipe failed to open"); |
| 491 | return false; |
| 492 | } |
| 493 | // set the ctrl fd |
| 494 | mCtrl3D.setFd(mS3d.getCtrlFd()); |
| 495 | return true; |
| 496 | } |
| 497 | template <int CHAN> |
| 498 | inline bool S3DPrimaryPipe<CHAN>::close() { |
| 499 | if(!utils::enableBarrier(0)) { |
| 500 | ALOGE("S3DExtPipe close failed enable barrier"); |
| 501 | } |
| 502 | mCtrl3D.close(); |
| 503 | return mS3d.close(); |
| 504 | } |
| 505 | template <int CHAN> |
| 506 | inline bool S3DPrimaryPipe<CHAN>::commit() { return mS3d.commit(); } |
| 507 | template <int CHAN> |
| 508 | inline void S3DPrimaryPipe<CHAN>::setId(int id) { mS3d.setId(id); } |
| 509 | template <int CHAN> |
| 510 | inline void S3DPrimaryPipe<CHAN>::setMemoryId(int id) { mS3d.setMemoryId(id); } |
| 511 | template <int CHAN> |
| 512 | inline bool S3DPrimaryPipe<CHAN>::queueBuffer(uint32_t offset) { |
| 513 | return mS3d.queueBuffer(offset); } |
| 514 | template <int CHAN> |
| 515 | inline bool S3DPrimaryPipe<CHAN>::dequeueBuffer(void*& buf) { |
| 516 | return mS3d.dequeueBuffer(buf); } |
| 517 | template <int CHAN> |
| 518 | inline bool S3DPrimaryPipe<CHAN>::waitForVsync() { |
| 519 | return mS3d.waitForVsync(); } |
| 520 | template <int CHAN> |
| 521 | inline bool S3DPrimaryPipe<CHAN>::setCrop(const utils::Dim& d) { |
| 522 | utils::Dim _dim; |
| 523 | if(!utils::getCropS3D<CHAN>(d, _dim, mS3Dfmt)){ |
| 524 | ALOGE("S3DPrimaryPipe setCrop failed to getCropS3D"); |
| 525 | _dim = d; |
| 526 | } |
| 527 | return mS3d.setCrop(_dim); |
| 528 | } |
| 529 | template <int CHAN> |
| 530 | inline bool S3DPrimaryPipe<CHAN>::start(const utils::PipeArgs& args) { |
| 531 | if(!mS3d.start(args)) { |
| 532 | ALOGE("S3DPrimaryPipe start failed"); |
| 533 | return false; |
| 534 | } |
| 535 | return true; |
| 536 | } |
| 537 | template <int CHAN> |
| 538 | inline bool S3DPrimaryPipe<CHAN>::setPosition(const utils::Dim& d) |
| 539 | { |
| 540 | utils::Whf fbwhf(mS3d.getScreenInfo().mFBWidth, |
| 541 | mS3d.getScreenInfo().mFBHeight, |
| 542 | 0 /* fmt dont care*/); |
| 543 | mCtrl3D.setWh(fbwhf); |
| 544 | if(!mCtrl3D.useVirtualFB()) { |
| 545 | ALOGE("Failed to use VFB on %d (non fatal)", utils::FB0); |
| 546 | return false; |
| 547 | } |
| 548 | utils::Dim _dim; |
| 549 | // original setPositionHandleState has getPositionS3D(...,true) |
| 550 | // which means format is HAL_3D_OUT_SBS_MASK |
| 551 | // HAL_3D_OUT_SBS_MASK is 0x1000 >> 12 == 0x1 as the orig |
| 552 | // code suggets |
| 553 | utils::Whf _whf(d.w, d.h, utils::HAL_3D_OUT_SBS_MASK); |
| 554 | if(!utils::getPositionS3D<CHAN>(_whf, _dim)) { |
| 555 | ALOGE("S3DPrimaryPipe setPosition err in getPositionS3D"); |
| 556 | _dim = d; |
| 557 | } |
| 558 | return mS3d.setPosition(_dim); |
| 559 | } |
| 560 | |
| 561 | /* for S3DPrimaryPipe, we need to have barriers once |
| 562 | * So the easiest way to achieve it, is to make sure FB0 is having it before |
| 563 | * setParam is running */ |
| 564 | template <> |
| 565 | inline bool S3DPrimaryPipe<utils::OV_PIPE0>::setParameter( |
| 566 | const utils::Params& param) { |
| 567 | if(utils::OVERLAY_TRANSFORM == param.param){ |
| 568 | uint32_t barrier=0; |
| 569 | switch(param.value) { |
| 570 | case HAL_TRANSFORM_ROT_90: |
| 571 | case HAL_TRANSFORM_ROT_270: |
| 572 | barrier = utils::BARRIER_LAND; |
| 573 | break; |
| 574 | default: |
| 575 | barrier = utils::BARRIER_PORT; |
| 576 | break; |
| 577 | } |
| 578 | if(!utils::enableBarrier(barrier)) { |
| 579 | ALOGE("S3DPrimaryPipe setParameter failed to enable barrier"); |
| 580 | } |
| 581 | } |
| 582 | return mS3d.setParameter(param); |
| 583 | } |
| 584 | |
| 585 | template <int CHAN> |
| 586 | inline bool S3DPrimaryPipe<CHAN>::setParameter(const utils::Params& param) { |
| 587 | return mS3d.setParameter(param); |
| 588 | } |
| 589 | template <int CHAN> |
| 590 | inline bool S3DPrimaryPipe<CHAN>::setSource(const utils::PipeArgs& args) |
| 591 | { |
| 592 | mS3Dfmt = utils::getS3DFormat(args.whf.format); |
| 593 | if(mS3d.isClosed()){ |
| 594 | if(!this->start(args)) { |
| 595 | ALOGE("S3DPrimaryPipe setSource failed to start"); |
| 596 | return false; |
| 597 | } |
| 598 | } |
| 599 | return mS3d.setSource(args); |
| 600 | } |
| 601 | template <int CHAN> |
| 602 | inline const utils::PipeArgs& S3DPrimaryPipe<CHAN>::getArgs() const { |
| 603 | return mS3d.getArgs(); |
| 604 | } |
| 605 | template <int CHAN> |
| 606 | inline utils::eOverlayPipeType S3DPrimaryPipe<CHAN>::getOvPipeType() const { |
| 607 | return utils::OV_PIPE_TYPE_S3D_PRIMARY; |
| 608 | } |
| 609 | template <int CHAN> |
| 610 | inline void S3DPrimaryPipe<CHAN>::dump() const { |
| 611 | ALOGE("S3DPrimaryPipe Pipe fmt=%d", mS3Dfmt); |
| 612 | mS3d.dump(); |
| 613 | } |
| 614 | |
| 615 | } // overlay |
| 616 | |
| 617 | #endif // OVERLAY_M3D_EXT_PIPE_H |