2012-06-14 07:56:20 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided
|
|
|
|
* with the distribution.
|
|
|
|
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
|
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
|
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
|
|
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "overlayUtils.h"
|
|
|
|
#include "overlayImpl.h"
|
|
|
|
#include "overlay.h"
|
|
|
|
|
|
|
|
#include "overlayMdp.h"
|
|
|
|
#include "overlayCtrlData.h"
|
|
|
|
|
|
|
|
namespace overlay {
|
|
|
|
|
2012-07-30 18:17:03 +00:00
|
|
|
//Helper
|
|
|
|
bool isStateValid(const utils::eOverlayState& st) {
|
2012-06-14 07:56:20 +00:00
|
|
|
switch (st) {
|
2012-07-30 18:17:03 +00:00
|
|
|
case utils::OV_CLOSED:
|
|
|
|
ALOGE("Overlay %s failed, state is OV_CLOSED; set state first",
|
|
|
|
__FUNCTION__);
|
|
|
|
return false;
|
|
|
|
break;
|
2012-06-14 07:56:20 +00:00
|
|
|
case utils::OV_2D_VIDEO_ON_PANEL:
|
|
|
|
case utils::OV_2D_VIDEO_ON_PANEL_TV:
|
2012-07-20 01:14:30 +00:00
|
|
|
case utils::OV_2D_VIDEO_ON_TV:
|
2012-06-14 07:56:20 +00:00
|
|
|
case utils::OV_3D_VIDEO_ON_2D_PANEL:
|
|
|
|
case utils::OV_3D_VIDEO_ON_3D_PANEL:
|
|
|
|
case utils::OV_3D_VIDEO_ON_3D_TV:
|
|
|
|
case utils::OV_3D_VIDEO_ON_2D_PANEL_2D_TV:
|
2012-08-13 06:19:01 +00:00
|
|
|
case utils::OV_2D_PIP_VIDEO_ON_PANEL:
|
2012-06-14 07:56:20 +00:00
|
|
|
case utils::OV_UI_MIRROR:
|
|
|
|
case utils::OV_2D_TRUE_UI_MIRROR:
|
|
|
|
case utils::OV_BYPASS_1_LAYER:
|
|
|
|
case utils::OV_BYPASS_2_LAYER:
|
|
|
|
case utils::OV_BYPASS_3_LAYER:
|
2012-07-20 01:14:30 +00:00
|
|
|
case utils::OV_DUAL_DISP:
|
2012-06-14 07:56:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
OVASSERT(false, "%s Unknown state %d", __FUNCTION__, st);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:17:03 +00:00
|
|
|
Overlay::Overlay(): mOv(0) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Overlay::~Overlay() {
|
|
|
|
mOv = mState.handleEvent(utils::OV_CLOSED, mOv);
|
|
|
|
delete mOv;
|
|
|
|
mOv = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Overlay::commit(utils::eDest dest)
|
2012-06-14 07:56:20 +00:00
|
|
|
{
|
|
|
|
OVASSERT(mOv,
|
|
|
|
"%s Overlay and Rotator should be init at this point",
|
|
|
|
__FUNCTION__);
|
|
|
|
utils::eOverlayState st = mState.state();
|
2012-07-30 18:17:03 +00:00
|
|
|
if(isStateValid(st)) {
|
|
|
|
if(!mOv->commit(dest)) {
|
|
|
|
ALOGE("Overlay %s failed", __FUNCTION__);
|
2012-06-14 07:56:20 +00:00
|
|
|
return false;
|
2012-07-30 18:17:03 +00:00
|
|
|
}
|
2012-06-14 07:56:20 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:17:03 +00:00
|
|
|
bool Overlay::queueBuffer(int fd, uint32_t offset,
|
|
|
|
utils::eDest dest)
|
2012-06-14 07:56:20 +00:00
|
|
|
{
|
|
|
|
OVASSERT(mOv,
|
|
|
|
"%s Overlay and Rotator should be init at this point",
|
|
|
|
__FUNCTION__);
|
|
|
|
utils::eOverlayState st = mState.state();
|
2012-07-30 18:17:03 +00:00
|
|
|
if(isStateValid(st)) {
|
|
|
|
if(!mOv->queueBuffer(fd, offset, dest)) {
|
|
|
|
ALOGE("Overlay %s failed", __FUNCTION__);
|
2012-06-14 07:56:20 +00:00
|
|
|
return false;
|
2012-07-30 18:17:03 +00:00
|
|
|
}
|
2012-06-14 07:56:20 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Overlay::setCrop(const utils::Dim& d,
|
|
|
|
utils::eDest dest)
|
|
|
|
{
|
|
|
|
OVASSERT(mOv,
|
|
|
|
"%s Overlay and Rotator should be init at this point",
|
|
|
|
__FUNCTION__);
|
|
|
|
utils::eOverlayState st = mState.state();
|
2012-07-30 18:17:03 +00:00
|
|
|
if(isStateValid(st)) {
|
|
|
|
if(!mOv->setCrop(d, dest)) {
|
|
|
|
ALOGE("Overlay %s failed", __FUNCTION__);
|
2012-06-14 07:56:20 +00:00
|
|
|
return false;
|
2012-07-30 18:17:03 +00:00
|
|
|
}
|
2012-06-14 07:56:20 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool Overlay::setPosition(const utils::Dim& d,
|
|
|
|
utils::eDest dest)
|
|
|
|
{
|
|
|
|
OVASSERT(mOv,
|
|
|
|
"%s Overlay and Rotator should be init at this point",
|
|
|
|
__FUNCTION__);
|
|
|
|
utils::eOverlayState st = mState.state();
|
2012-07-30 18:17:03 +00:00
|
|
|
if(isStateValid(st)) {
|
|
|
|
if(!mOv->setPosition(d, dest)) {
|
|
|
|
ALOGE("Overlay %s failed", __FUNCTION__);
|
2012-06-14 07:56:20 +00:00
|
|
|
return false;
|
2012-07-30 18:17:03 +00:00
|
|
|
}
|
2012-06-14 07:56:20 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-10 20:07:52 +00:00
|
|
|
|
|
|
|
bool Overlay::setTransform(const int orient,
|
2012-06-14 07:56:20 +00:00
|
|
|
utils::eDest dest)
|
|
|
|
{
|
2012-07-10 20:07:52 +00:00
|
|
|
utils::eTransform transform =
|
|
|
|
static_cast<utils::eTransform>(orient);
|
|
|
|
|
2012-06-14 07:56:20 +00:00
|
|
|
utils::eOverlayState st = mState.state();
|
2012-07-30 18:17:03 +00:00
|
|
|
if(isStateValid(st)) {
|
|
|
|
if(!mOv->setTransform(transform, dest)) {
|
|
|
|
ALOGE("Overlay %s failed", __FUNCTION__);
|
2012-06-14 07:56:20 +00:00
|
|
|
return false;
|
2012-07-30 18:17:03 +00:00
|
|
|
}
|
2012-06-14 07:56:20 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-10 20:07:52 +00:00
|
|
|
|
2012-06-14 07:56:20 +00:00
|
|
|
bool Overlay::setSource(const utils::PipeArgs args[utils::MAX_PIPES],
|
|
|
|
utils::eDest dest)
|
|
|
|
{
|
|
|
|
utils::PipeArgs margs[utils::MAX_PIPES] = {
|
|
|
|
args[0], args[1], args[2] };
|
|
|
|
utils::eOverlayState st = mState.state();
|
|
|
|
|
2012-07-30 18:17:03 +00:00
|
|
|
if(isStateValid(st)) {
|
|
|
|
if (!mOv->setSource(margs, dest)) {
|
|
|
|
ALOGE("Overlay %s failed", __FUNCTION__);
|
2012-07-10 20:07:52 +00:00
|
|
|
return false;
|
2012-07-30 18:17:03 +00:00
|
|
|
}
|
2012-06-14 07:56:20 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Overlay::dump() const
|
|
|
|
{
|
|
|
|
OVASSERT(mOv,
|
|
|
|
"%s Overlay and Rotator should be init at this point",
|
|
|
|
__FUNCTION__);
|
|
|
|
ALOGE("== Dump Overlay start ==");
|
|
|
|
mState.dump();
|
|
|
|
mOv->dump();
|
|
|
|
ALOGE("== Dump Overlay end ==");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Overlay::setState(utils::eOverlayState s) {
|
|
|
|
mOv = mState.handleEvent(s, mOv);
|
|
|
|
}
|
|
|
|
|
|
|
|
utils::eOverlayState Overlay::getState() const {
|
|
|
|
return mState.state();
|
|
|
|
}
|
|
|
|
|
|
|
|
Overlay *Overlay::sInstance = 0;
|
|
|
|
|
|
|
|
Overlay* Overlay::getInstance() {
|
|
|
|
if(sInstance == NULL)
|
|
|
|
sInstance = new Overlay();
|
|
|
|
return sInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // overlay
|