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_IMPL_H |
| 31 | #define OVERLAY_IMPL_H |
| 32 | |
| 33 | #include "overlayUtils.h" |
| 34 | #include "overlayRotator.h" |
| 35 | |
| 36 | // FIXME make int to be uint32 whenever possible |
| 37 | |
| 38 | namespace overlay { |
| 39 | |
| 40 | // Interface only. No member, no definiton (except ~ which can |
| 41 | // also be =0 with impl in cpp) |
| 42 | class OverlayImplBase { |
| 43 | public: |
| 44 | /* empty dtor. can be =0 with cpp impl*/ |
| 45 | virtual ~OverlayImplBase() {} |
| 46 | |
| 47 | /* Open pipe/rot for one dest */ |
| 48 | virtual bool openPipe(RotatorBase* rot, utils::eDest dest) = 0; |
| 49 | |
| 50 | /* Close pipe/rot for all specified dest */ |
| 51 | virtual bool closePipe(utils::eDest dest) = 0; |
| 52 | |
| 53 | /* Copy specified pipe/rot from ov passed in (used by state machine only) */ |
| 54 | virtual bool copyOvPipe(OverlayImplBase* ov, utils::eDest dest) = 0; |
| 55 | |
| 56 | /* TODO open func customized for RGBx pipes */ |
| 57 | |
| 58 | /* Open all pipes |
| 59 | * To open just one pipe, use openPipe() |
| 60 | * */ |
| 61 | virtual bool open(RotatorBase* rot0, |
| 62 | RotatorBase* rot1, |
| 63 | RotatorBase* rot2) = 0; |
| 64 | |
| 65 | /* Close all pipes |
| 66 | * To close just one pipe, use closePipe() |
| 67 | * */ |
| 68 | virtual bool close() = 0; |
| 69 | |
| 70 | /* |
| 71 | * Commit changes to the overlay |
| 72 | * */ |
| 73 | virtual bool commit(utils::eDest dest = utils::OV_PIPE_ALL) = 0; |
| 74 | |
| 75 | /* Queue buffer with offset*/ |
| 76 | virtual bool queueBuffer(uint32_t offset, |
| 77 | utils::eDest dest = utils::OV_PIPE_ALL) = 0; |
| 78 | |
| 79 | /* For RGBx pipes, dequeue buffer (that is fb chunk)*/ |
| 80 | virtual bool dequeueBuffer(void*& buf, |
| 81 | utils::eDest dest = utils::OV_PIPE_ALL) = 0; |
| 82 | |
| 83 | /* Wait for vsync to be done on dest */ |
| 84 | virtual bool waitForVsync(utils::eDest dest = utils::OV_PIPE1) = 0; |
| 85 | |
| 86 | /* Crop existing destination using Dim coordinates */ |
| 87 | virtual bool setCrop(const utils::Dim& d, |
| 88 | utils::eDest dest = utils::OV_PIPE_ALL) = 0; |
| 89 | |
| 90 | /* Set new position using Dim */ |
| 91 | virtual bool setPosition(const utils::Dim& dim, |
| 92 | utils::eDest dest = utils::OV_PIPE_ALL) = 0; |
| 93 | |
| 94 | /* Set parameters - usually needed for Rotator, but would |
| 95 | * be passed down the stack as well */ |
| 96 | virtual bool setParameter(const utils::Params& param, |
| 97 | utils::eDest dest = utils::OV_PIPE_ALL) = 0; |
| 98 | |
| 99 | /* Set new source including orientation */ |
| 100 | virtual bool setSource(const utils::PipeArgs[utils::MAX_PIPES], |
| 101 | utils::eDest dest = utils::OV_PIPE_ALL) = 0; |
| 102 | |
| 103 | /* set memory id to the underlying pipes */ |
| 104 | virtual void setMemoryId(int id, utils::eDest dest = utils::OV_PIPE_ALL) = 0; |
| 105 | |
| 106 | /* Get the overlay pipe type */ |
| 107 | virtual utils::eOverlayPipeType getOvPipeType(utils::eDest dest) const = 0; |
| 108 | |
| 109 | /* Dump underlying state */ |
| 110 | virtual void dump() const = 0; |
| 111 | }; |
| 112 | |
| 113 | class NullPipe { |
| 114 | public: |
| 115 | /* TODO open func customized for RGBx pipes */ |
| 116 | bool open(RotatorBase* rot); |
| 117 | bool close(); |
| 118 | bool start(const utils::PipeArgs& args); |
| 119 | bool commit(); |
| 120 | bool setCrop(const utils::Dim& d); |
| 121 | bool setPosition(const utils::Dim& dim); |
| 122 | bool setParameter(const utils::Params& param); |
| 123 | bool setSource(const utils::PipeArgs& args); |
| 124 | bool queueBuffer(uint32_t offset); |
| 125 | bool dequeueBuffer(void*& buf); |
| 126 | bool waitForVsync(); |
| 127 | void setMemoryId(int id); |
| 128 | utils::PipeArgs getArgs() const; |
| 129 | utils::eOverlayPipeType getOvPipeType() const; |
| 130 | void dump() const; |
| 131 | }; |
| 132 | |
| 133 | /* |
| 134 | * Each pipe is not specific to a display (primary/external). The order in the |
| 135 | * template params, will setup the priorities of the pipes. |
| 136 | * */ |
| 137 | template <class P0, class P1=NullPipe, class P2=NullPipe> |
| 138 | class OverlayImpl : public OverlayImplBase { |
| 139 | public: |
| 140 | typedef P0 pipe0; |
| 141 | typedef P1 pipe1; |
| 142 | typedef P2 pipe2; |
| 143 | |
| 144 | /* ctor */ |
| 145 | OverlayImpl(); |
| 146 | OverlayImpl(P0* p0, P1* p1, P2* p2); |
| 147 | |
| 148 | /* |
| 149 | * Comments of the below functions are the same as the one |
| 150 | * in OverlayImplBase. |
| 151 | * */ |
| 152 | virtual ~OverlayImpl(); |
| 153 | |
| 154 | virtual bool openPipe(RotatorBase* rot, utils::eDest dest); |
| 155 | virtual bool closePipe(utils::eDest dest); |
| 156 | virtual bool copyOvPipe(OverlayImplBase* ov, utils::eDest dest); |
| 157 | |
| 158 | /* TODO open func customized for RGBx pipes */ |
| 159 | virtual bool open(RotatorBase* rot0, |
| 160 | RotatorBase* rot1, |
| 161 | RotatorBase* rot2); |
| 162 | virtual bool close(); |
| 163 | virtual bool commit(utils::eDest dest = utils::OV_PIPE_ALL); |
| 164 | virtual bool setCrop(const utils::Dim& d, |
| 165 | utils::eDest dest = utils::OV_PIPE_ALL); |
| 166 | virtual bool setPosition(const utils::Dim& dim, |
| 167 | utils::eDest dest = utils::OV_PIPE_ALL); |
| 168 | virtual bool setParameter(const utils::Params& param, |
| 169 | utils::eDest dest = utils::OV_PIPE_ALL); |
| 170 | virtual bool setSource(const utils::PipeArgs[utils::MAX_PIPES], |
| 171 | utils::eDest dest = utils::OV_PIPE_ALL); |
| 172 | virtual bool queueBuffer(uint32_t offset, |
| 173 | utils::eDest dest = utils::OV_PIPE_ALL); |
| 174 | virtual bool dequeueBuffer(void*& buf, |
| 175 | utils::eDest dest = utils::OV_PIPE_ALL); |
| 176 | virtual bool waitForVsync(utils::eDest dest = utils::OV_PIPE1); |
| 177 | virtual void setMemoryId(int id, utils::eDest dest = utils::OV_PIPE_ALL); |
| 178 | virtual utils::eOverlayPipeType getOvPipeType(utils::eDest dest) const; |
| 179 | virtual void dump() const; |
| 180 | |
| 181 | private: |
| 182 | P0* mPipe0; |
| 183 | P1* mPipe1; |
| 184 | P2* mPipe2; |
| 185 | // More Px here in the future as needed |
| 186 | |
| 187 | /* */ |
| 188 | |
| 189 | /* Each Px has it's own Rotator here. |
| 190 | * will pass rotator to the lower layer in stack |
| 191 | * but only overlay is allowed to control the lifetime |
| 192 | * of the rotator instace */ |
| 193 | RotatorBase* mRotP0; |
| 194 | RotatorBase* mRotP1; |
| 195 | RotatorBase* mRotP2; |
| 196 | }; |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | //-----------Inlines and Template defn--------------------------------- |
| 203 | |
| 204 | template <class P0, class P1, class P2> |
| 205 | OverlayImpl<P0, P1, P2>::OverlayImpl() : |
| 206 | mPipe0(new P0), mPipe1(new P1), mPipe2(new P2), |
| 207 | mRotP0(0), mRotP1(0), mRotP2(0) |
| 208 | {} |
| 209 | |
| 210 | template <class P0, class P1, class P2> |
| 211 | OverlayImpl<P0, P1, P2>::OverlayImpl(P0* p0, P1* p1, P2* p2) : |
| 212 | mPipe0(p0), mPipe1(p1), mPipe2(p2), |
| 213 | mRotP0(0), mRotP1(0), mRotP2(0) |
| 214 | {} |
| 215 | |
| 216 | template <class P0, class P1, class P2> |
| 217 | OverlayImpl<P0, P1, P2>::~OverlayImpl() |
| 218 | { |
| 219 | // no op in the meantime. needed to be clean |
| 220 | // since state machine will do delete. so we |
| 221 | // do not want to close/delete pipes here |
| 222 | } |
| 223 | |
| 224 | /* Open only one pipe/rot pair per call */ |
| 225 | template <class P0, class P1, class P2> |
| 226 | bool OverlayImpl<P0, P1, P2>::openPipe(RotatorBase* rot, utils::eDest dest) |
| 227 | { |
| 228 | OVASSERT(rot, "%s: OverlayImpl rot is null", __FUNCTION__); |
| 229 | OVASSERT(utils::isValidDest(dest), "%s: OverlayImpl invalid dest=%d", |
| 230 | __FUNCTION__, dest); |
| 231 | |
| 232 | // Need to down case rotator to mdp one. |
| 233 | // we assume p0/p1/p2/px all use the _same_ underlying mdp structure. |
| 234 | // FIXME STATIC_ASSERT here |
| 235 | |
| 236 | bool ret = true; |
| 237 | |
| 238 | if (utils::OV_PIPE0 & dest) { |
| 239 | OVASSERT(mPipe0, "%s: OverlayImpl pipe0 is null", __FUNCTION__); |
| 240 | ALOGE_IF(DEBUG_OVERLAY, "Open pipe0"); |
| 241 | ret = mPipe0->open(rot); |
| 242 | mRotP0 = rot; |
| 243 | if(!ret) { |
| 244 | ALOGE("%s: OverlayImpl pipe0 failed to open", __FUNCTION__); |
| 245 | } |
| 246 | return ret; |
| 247 | } |
| 248 | |
| 249 | if (utils::OV_PIPE1 & dest) { |
| 250 | OVASSERT(mPipe1, "%s: OverlayImpl pipe1 is null", __FUNCTION__); |
| 251 | ALOGE_IF(DEBUG_OVERLAY, "Open pipe1"); |
| 252 | ret = mPipe1->open(rot); |
| 253 | mRotP1 = rot; |
| 254 | if(!ret) { |
| 255 | ALOGE("%s: OverlayImpl pipe1 failed to open", __FUNCTION__); |
| 256 | } |
| 257 | return ret; |
| 258 | } |
| 259 | |
| 260 | if (utils::OV_PIPE2 & dest) { |
| 261 | OVASSERT(mPipe2, "%s: OverlayImpl pipe2 is null", __FUNCTION__); |
| 262 | ALOGE_IF(DEBUG_OVERLAY, "Open pipe2"); |
| 263 | ret = mPipe2->open(rot); |
| 264 | mRotP2 = rot; |
| 265 | if(!ret) { |
| 266 | ALOGE("%s: OverlayImpl pipe2 failed to open", __FUNCTION__); |
| 267 | } |
| 268 | return ret; |
| 269 | } |
| 270 | |
| 271 | // Should have returned by here |
| 272 | return false; |
| 273 | } |
| 274 | |
| 275 | /* Close pipe/rot for all specified dest */ |
| 276 | template <class P0, class P1, class P2> |
| 277 | bool OverlayImpl<P0, P1, P2>::closePipe(utils::eDest dest) |
| 278 | { |
| 279 | OVASSERT(utils::isValidDest(dest), "%s: OverlayImpl invalid dest=%d", |
| 280 | __FUNCTION__, dest); |
| 281 | |
| 282 | if (utils::OV_PIPE0 & dest) { |
| 283 | // Close pipe0 |
| 284 | OVASSERT(mPipe0, "%s: OverlayImpl pipe0 is null", __FUNCTION__); |
| 285 | ALOGE_IF(DEBUG_OVERLAY, "Close pipe0"); |
| 286 | if (!mPipe0->close()) { |
| 287 | ALOGE("%s: OverlayImpl failed to close pipe0", __FUNCTION__); |
| 288 | return false; |
| 289 | } |
| 290 | delete mPipe0; |
| 291 | mPipe0 = 0; |
| 292 | |
| 293 | // Close the rotator for pipe0 |
| 294 | OVASSERT(mRotP0, "%s: OverlayImpl rot0 is null", __FUNCTION__); |
| 295 | if (!mRotP0->close()) { |
| 296 | ALOGE("%s: OverlayImpl failed to close rot for pipe0", __FUNCTION__); |
| 297 | } |
| 298 | delete mRotP0; |
| 299 | mRotP0 = 0; |
| 300 | } |
| 301 | |
| 302 | if (utils::OV_PIPE1 & dest) { |
| 303 | // Close pipe1 |
| 304 | OVASSERT(mPipe1, "%s: OverlayImpl pipe1 is null", __FUNCTION__); |
| 305 | ALOGE_IF(DEBUG_OVERLAY, "Close pipe1"); |
| 306 | if (!mPipe1->close()) { |
| 307 | ALOGE("%s: OverlayImpl failed to close pipe1", __FUNCTION__); |
| 308 | return false; |
| 309 | } |
| 310 | delete mPipe1; |
| 311 | mPipe1 = 0; |
| 312 | |
| 313 | // Close the rotator for pipe1 |
| 314 | OVASSERT(mRotP1, "%s: OverlayImpl rot1 is null", __FUNCTION__); |
| 315 | if (!mRotP1->close()) { |
| 316 | ALOGE("%s: OverlayImpl failed to close rot for pipe1", __FUNCTION__); |
| 317 | } |
| 318 | delete mRotP1; |
| 319 | mRotP1 = 0; |
| 320 | } |
| 321 | |
| 322 | if (utils::OV_PIPE2 & dest) { |
| 323 | // Close pipe2 |
| 324 | OVASSERT(mPipe2, "%s: OverlayImpl pipe2 is null", __FUNCTION__); |
| 325 | ALOGE_IF(DEBUG_OVERLAY, "Close pipe2"); |
| 326 | if (!mPipe2->close()) { |
| 327 | ALOGE("%s: OverlayImpl failed to close pipe2", __FUNCTION__); |
| 328 | return false; |
| 329 | } |
| 330 | delete mPipe2; |
| 331 | mPipe2 = 0; |
| 332 | |
| 333 | // Close the rotator for pipe2 |
| 334 | OVASSERT(mRotP2, "%s: OverlayImpl rot2 is null", __FUNCTION__); |
| 335 | if (!mRotP2->close()) { |
| 336 | ALOGE("%s: OverlayImpl failed to close rot for pipe2", __FUNCTION__); |
| 337 | } |
| 338 | delete mRotP2; |
| 339 | mRotP2 = 0; |
| 340 | } |
| 341 | |
| 342 | return true; |
| 343 | } |
| 344 | |
| 345 | /* Copy pipe/rot from ov for all specified dest */ |
| 346 | template <class P0, class P1, class P2> |
| 347 | bool OverlayImpl<P0, P1, P2>::copyOvPipe(OverlayImplBase* ov, |
| 348 | utils::eDest dest) |
| 349 | { |
| 350 | OVASSERT(ov, "%s: OverlayImpl ov is null", __FUNCTION__); |
| 351 | OVASSERT(utils::isValidDest(dest), "%s: OverlayImpl invalid dest=%d", |
| 352 | __FUNCTION__, dest); |
| 353 | |
| 354 | OverlayImpl<P0, P1, P2>* ovimpl = static_cast<OverlayImpl<P0, P1, P2>*>(ov); |
| 355 | |
| 356 | if (utils::OV_PIPE0 & dest) { |
| 357 | mPipe0 = ovimpl->mPipe0; |
| 358 | mRotP0 = ovimpl->mRotP0; |
| 359 | } |
| 360 | |
| 361 | if (utils::OV_PIPE1 & dest) { |
| 362 | mPipe1 = ovimpl->mPipe1; |
| 363 | mRotP1 = ovimpl->mRotP1; |
| 364 | } |
| 365 | |
| 366 | if (utils::OV_PIPE2 & dest) { |
| 367 | mPipe2 = ovimpl->mPipe2; |
| 368 | mRotP2 = ovimpl->mRotP2; |
| 369 | } |
| 370 | |
| 371 | return true; |
| 372 | } |
| 373 | |
| 374 | /* TODO open func customized for RGBx pipes */ |
| 375 | |
| 376 | /* Open all pipes/rot */ |
| 377 | template <class P0, class P1, class P2> |
| 378 | bool OverlayImpl<P0, P1, P2>::open(RotatorBase* rot0, |
| 379 | RotatorBase* rot1, |
| 380 | RotatorBase* rot2) |
| 381 | { |
| 382 | if (!this->openPipe(rot0, utils::OV_PIPE0)) { |
| 383 | if (!this->close()) { |
| 384 | ALOGE("%s: failed to close at least one pipe", __FUNCTION__); |
| 385 | } |
| 386 | return false; |
| 387 | } |
| 388 | |
| 389 | if (!this->openPipe(rot1, utils::OV_PIPE1)) { |
| 390 | if (!this->close()) { |
| 391 | ALOGE("%s: failed to close at least one pipe", __FUNCTION__); |
| 392 | } |
| 393 | return false; |
| 394 | } |
| 395 | |
| 396 | if (!this->openPipe(rot2, utils::OV_PIPE2)) { |
| 397 | if (!this->close()) { |
| 398 | ALOGE("%s: failed to close at least one pipe", __FUNCTION__); |
| 399 | } |
| 400 | return false; |
| 401 | } |
| 402 | |
| 403 | return true; |
| 404 | } |
| 405 | |
| 406 | /* Close all pipes/rot */ |
| 407 | template <class P0, class P1, class P2> |
| 408 | bool OverlayImpl<P0, P1, P2>::close() |
| 409 | { |
| 410 | if (!this->closePipe(utils::OV_PIPE_ALL)) { |
| 411 | return false; |
| 412 | } |
| 413 | |
| 414 | return true; |
| 415 | } |
| 416 | |
| 417 | template <class P0, class P1, class P2> |
| 418 | bool OverlayImpl<P0, P1, P2>::commit(utils::eDest dest) |
| 419 | { |
| 420 | OVASSERT(mPipe0 && mPipe1 && mPipe2, |
| 421 | "%s: Pipes are null p0=%p p1=%p p2=%p", |
| 422 | __FUNCTION__, mPipe0, mPipe1, mPipe2); |
| 423 | |
| 424 | if (utils::OV_PIPE0 & dest) { |
| 425 | if(!mPipe0->commit()) { |
| 426 | ALOGE("OverlayImpl p0 failed to commit"); |
| 427 | return false; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | if (utils::OV_PIPE1 & dest) { |
| 432 | if(!mPipe1->commit()) { |
| 433 | ALOGE("OverlayImpl p1 failed to commit"); |
| 434 | return false; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | if (utils::OV_PIPE2 & dest) { |
| 439 | if(!mPipe2->commit()) { |
| 440 | ALOGE("OverlayImpl p2 failed to commit"); |
| 441 | return false; |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | return true; |
| 446 | } |
| 447 | |
| 448 | template <class P0, class P1, class P2> |
| 449 | bool OverlayImpl<P0, P1, P2>::setCrop(const utils::Dim& d, utils::eDest dest) |
| 450 | { |
| 451 | OVASSERT(mPipe0 && mPipe1 && mPipe2, |
| 452 | "%s: Pipes are null p0=%p p1=%p p2=%p", |
| 453 | __FUNCTION__, mPipe0, mPipe1, mPipe2); |
| 454 | |
| 455 | if (utils::OV_PIPE0 & dest) { |
| 456 | if(!mPipe0->setCrop(d)) { |
| 457 | ALOGE("OverlayImpl p0 failed to crop"); |
| 458 | return false; |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | if (utils::OV_PIPE1 & dest) { |
| 463 | if(!mPipe1->setCrop(d)) { |
| 464 | ALOGE("OverlayImpl p1 failed to crop"); |
| 465 | return false; |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | if (utils::OV_PIPE2 & dest) { |
| 470 | if(!mPipe2->setCrop(d)) { |
| 471 | ALOGE("OverlayImpl p2 failed to crop"); |
| 472 | return false; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | return true; |
| 477 | } |
| 478 | |
| 479 | template <class P0, class P1, class P2> |
| 480 | bool OverlayImpl<P0, P1, P2>::setPosition(const utils::Dim& d, |
| 481 | utils::eDest dest) |
| 482 | { |
| 483 | OVASSERT(mPipe0 && mPipe1 && mPipe2, |
| 484 | "%s: Pipes are null p0=%p p1=%p p2=%p", |
| 485 | __FUNCTION__, mPipe0, mPipe1, mPipe2); |
| 486 | |
| 487 | if (utils::OV_PIPE0 & dest) { |
| 488 | if(!mPipe0->setPosition(d)) { |
| 489 | ALOGE("OverlayImpl p0 failed to setpos"); |
| 490 | return false; |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | if (utils::OV_PIPE1 & dest) { |
| 495 | if(!mPipe1->setPosition(d)) { |
| 496 | ALOGE("OverlayImpl p1 failed to setpos"); |
| 497 | return false; |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | if (utils::OV_PIPE2 & dest) { |
| 502 | if(!mPipe2->setPosition(d)) { |
| 503 | ALOGE("OverlayImpl p2 failed to setpos"); |
| 504 | return false; |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | return true; |
| 509 | } |
| 510 | |
| 511 | template <class P0, class P1, class P2> |
| 512 | bool OverlayImpl<P0, P1, P2>::setParameter(const utils::Params& param, |
| 513 | utils::eDest dest) |
| 514 | { |
| 515 | OVASSERT(mPipe0 && mPipe1 && mPipe2, |
| 516 | "%s: Pipes are null p0=%p p1=%p p2=%p", |
| 517 | __FUNCTION__, mPipe0, mPipe1, mPipe2); |
| 518 | |
| 519 | if (utils::OV_PIPE0 & dest) { |
| 520 | if(!mPipe0->setParameter(param)) { |
| 521 | ALOGE("OverlayImpl p0 failed to setparam"); |
| 522 | return false; |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | if (utils::OV_PIPE1 & dest) { |
| 527 | if(!mPipe1->setParameter(param)) { |
| 528 | ALOGE("OverlayImpl p1 failed to setparam"); |
| 529 | return false; |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | if (utils::OV_PIPE2 & dest) { |
| 534 | if(!mPipe2->setParameter(param)) { |
| 535 | ALOGE("OverlayImpl p2 failed to setparam"); |
| 536 | return false; |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | return true; |
| 541 | } |
| 542 | |
| 543 | template <class P0, class P1, class P2> |
| 544 | bool OverlayImpl<P0, P1, P2>::setSource(const utils::PipeArgs args[utils::MAX_PIPES], |
| 545 | utils::eDest dest) |
| 546 | { |
| 547 | OVASSERT(mPipe0 && mPipe1 && mPipe2, |
| 548 | "%s: Pipes are null p0=%p p1=%p p2=%p", |
| 549 | __FUNCTION__, mPipe0, mPipe1, mPipe2); |
| 550 | |
| 551 | if (utils::OV_PIPE0 & dest) { |
| 552 | if(!mPipe0->setSource(args[0])) { |
| 553 | ALOGE("OverlayImpl p0 failed to setsrc"); |
| 554 | return false; |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | if (utils::OV_PIPE1 & dest) { |
| 559 | if(!mPipe1->setSource(args[1])) { |
| 560 | ALOGE("OverlayImpl p1 failed to setsrc"); |
| 561 | return false; |
| 562 | } |
| 563 | } |
| 564 | |
| 565 | if (utils::OV_PIPE2 & dest) { |
| 566 | if(!mPipe2->setSource(args[2])) { |
| 567 | ALOGE("OverlayImpl p2 failed to setsrc"); |
| 568 | return false; |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | return true; |
| 573 | } |
| 574 | |
| 575 | template <class P0, class P1, class P2> |
| 576 | bool OverlayImpl<P0, P1, P2>::queueBuffer(uint32_t offset, utils::eDest dest) |
| 577 | { |
| 578 | OVASSERT(mPipe0 && mPipe1 && mPipe2, |
| 579 | "%s: Pipes are null p0=%p p1=%p p2=%p", |
| 580 | __FUNCTION__, mPipe0, mPipe1, mPipe2); |
| 581 | |
| 582 | if (utils::OV_PIPE0 & dest) { |
| 583 | if(!mPipe0->queueBuffer(offset)) { |
| 584 | ALOGE("OverlayImpl p0 failed to queueBuffer"); |
| 585 | return false; |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | if (utils::OV_PIPE1 & dest) { |
| 590 | if(!mPipe1->queueBuffer(offset)) { |
| 591 | ALOGE("OverlayImpl p1 failed to queueBuffer"); |
| 592 | return false; |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | if (utils::OV_PIPE2 & dest) { |
| 597 | if(!mPipe2->queueBuffer(offset)) { |
| 598 | ALOGE("OverlayImpl p2 failed to queueBuffer"); |
| 599 | return false; |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | return true; |
| 604 | } |
| 605 | |
| 606 | template <class P0, class P1, class P2> |
| 607 | bool OverlayImpl<P0, P1, P2>::dequeueBuffer(void*& buf, utils::eDest dest) |
| 608 | { |
| 609 | OVASSERT(mPipe0 && mPipe1 && mPipe2, |
| 610 | "%s: Pipes are null p0=%p p1=%p p2=%p", |
| 611 | __FUNCTION__, mPipe0, mPipe1, mPipe2); |
| 612 | |
| 613 | if (utils::OV_PIPE0 & dest) { |
| 614 | if(!mPipe0->dequeueBuffer(buf)) { |
| 615 | ALOGE("OverlayImpl p0 failed to dequeueBuffer"); |
| 616 | return false; |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | if (utils::OV_PIPE1 & dest) { |
| 621 | if(!mPipe1->dequeueBuffer(buf)) { |
| 622 | ALOGE("OverlayImpl p1 failed to dequeueBuffer"); |
| 623 | return false; |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | if (utils::OV_PIPE2 & dest) { |
| 628 | if(!mPipe2->dequeueBuffer(buf)) { |
| 629 | ALOGE("OverlayImpl p2 failed to dequeueBuffer"); |
| 630 | return false; |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | return true; |
| 635 | } |
| 636 | |
| 637 | template <class P0, class P1, class P2> |
| 638 | bool OverlayImpl<P0, P1, P2>::waitForVsync(utils::eDest dest) |
| 639 | { |
| 640 | OVASSERT(mPipe0 && mPipe1 && mPipe2, |
| 641 | "%s: Pipes are null p0=%p p1=%p p2=%p", |
| 642 | __FUNCTION__, mPipe0, mPipe1, mPipe2); |
| 643 | |
| 644 | if (utils::OV_PIPE0 & dest) { |
| 645 | if(!mPipe0->waitForVsync()) { |
| 646 | ALOGE("OverlayImpl p0 failed to waitForVsync"); |
| 647 | return false; |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | if (utils::OV_PIPE1 & dest) { |
| 652 | if(!mPipe1->waitForVsync()) { |
| 653 | ALOGE("OverlayImpl p1 failed to waitForVsync"); |
| 654 | return false; |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | if (utils::OV_PIPE2 & dest) { |
| 659 | if(!mPipe2->waitForVsync()) { |
| 660 | ALOGE("OverlayImpl p2 failed to waitForVsync"); |
| 661 | return false; |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | return true; |
| 666 | } |
| 667 | |
| 668 | template <class P0, class P1, class P2> |
| 669 | void OverlayImpl<P0, P1, P2>::setMemoryId(int id, utils::eDest dest) |
| 670 | { |
| 671 | OVASSERT(mPipe0 && mPipe1 && mPipe2, |
| 672 | "%s: Pipes are null p0=%p p1=%p p2=%p", |
| 673 | __FUNCTION__, mPipe0, mPipe1, mPipe2); |
| 674 | |
| 675 | if (utils::OV_PIPE0 & dest) { |
| 676 | mPipe0->setMemoryId(id); |
| 677 | } |
| 678 | |
| 679 | if (utils::OV_PIPE1 & dest) { |
| 680 | mPipe1->setMemoryId(id); |
| 681 | } |
| 682 | |
| 683 | if (utils::OV_PIPE2 & dest) { |
| 684 | mPipe2->setMemoryId(id); |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | template <class P0, class P1, class P2> |
| 689 | utils::eOverlayPipeType OverlayImpl<P0, P1, P2>::getOvPipeType(utils::eDest dest) const |
| 690 | { |
| 691 | OVASSERT(utils::isValidDest(dest), "%s: OverlayImpl invalid dest=%d", |
| 692 | __FUNCTION__, dest); |
| 693 | |
| 694 | if (utils::OV_PIPE0 & dest) { |
| 695 | OVASSERT(mPipe0, "%s: OverlayImpl pipe0 is null", __FUNCTION__); |
| 696 | return mPipe0->getOvPipeType(); |
| 697 | } |
| 698 | |
| 699 | if (utils::OV_PIPE1 & dest) { |
| 700 | OVASSERT(mPipe1, "%s: OverlayImpl pipe1 is null", __FUNCTION__); |
| 701 | return mPipe1->getOvPipeType(); |
| 702 | } |
| 703 | |
| 704 | if (utils::OV_PIPE2 & dest) { |
| 705 | OVASSERT(mPipe2, "%s: OverlayImpl pipe2 is null", __FUNCTION__); |
| 706 | return mPipe2->getOvPipeType(); |
| 707 | } |
| 708 | |
| 709 | // Should never get here |
| 710 | return utils::OV_PIPE_TYPE_NULL; |
| 711 | } |
| 712 | |
| 713 | template <class P0, class P1, class P2> |
| 714 | void OverlayImpl<P0, P1, P2>::dump() const |
| 715 | { |
| 716 | OVASSERT(mPipe0 && mPipe1 && mPipe2, |
| 717 | "%s: Pipes are null p0=%p p1=%p p2=%p", |
| 718 | __FUNCTION__, mPipe0, mPipe1, mPipe2); |
| 719 | ALOGE("== Dump OverlayImpl dump start ROT p0 =="); |
| 720 | mRotP0->dump(); |
| 721 | ALOGE("== Dump OverlayImpl dump end ROT p0 =="); |
| 722 | ALOGE("== Dump OverlayImpl dump start ROT p1 =="); |
| 723 | mRotP1->dump(); |
| 724 | ALOGE("== Dump OverlayImpl dump end ROT p1 =="); |
| 725 | ALOGE("== Dump OverlayImpl dump start ROT p2 =="); |
| 726 | mRotP2->dump(); |
| 727 | ALOGE("== Dump OverlayImpl dump end ROT p2 =="); |
| 728 | ALOGE("== Dump OverlayImpl dump start p0 =="); |
| 729 | mPipe0->dump(); |
| 730 | ALOGE("== Dump OverlayImpl dump end p0 =="); |
| 731 | ALOGE("== Dump OverlayImpl dump start p1 =="); |
| 732 | mPipe1->dump(); |
| 733 | ALOGE("== Dump OverlayImpl dump end p1 =="); |
| 734 | ALOGE("== Dump OverlayImpl dump start p2 =="); |
| 735 | mPipe2->dump(); |
| 736 | ALOGE("== Dump OverlayImpl dump end p2 =="); |
| 737 | } |
| 738 | |
| 739 | |
| 740 | } // overlay |
| 741 | |
| 742 | #endif // OVERLAY_IMPL_H |