liboverlay: Refactor, bug-fixes, upgrade.
* Fix memory leak during copying pipe objects.
* Remove unused / unnecessary code.
* setMemoryId API is merged with queueBuffer.
* setParameter API is setTransform now.
* Rotator upgraded to:
--Allow different rotator hardware types.
--Remove dependency on MDP code.
--Allocate memory only during first playback,
close when the associated pipe is closed.
* Have single commit implementation.
* Include new format types.
* Remove WAIT and CHANNEL enums and usage. Replace BypassPipe with
GenericPipe. Client expected to set alignments and parameters.
Add transform combination enums.
* Allow APIs to be called in any order. Do transform calcs in commit.
Move ext type setter and getter functions.
* Add calculations for 180 transform.
* Add secure session support in rotator
* Implement all rotations in terms of H flip, V flip and 90 rotation.
Change-Id: I34a9a2a0f1255b3467a0abbaa254d0b584e901ce
diff --git a/liboverlay/overlayCtrlData.h b/liboverlay/overlayCtrlData.h
index fbd701a..1398ec4 100644
--- a/liboverlay/overlayCtrlData.h
+++ b/liboverlay/overlayCtrlData.h
@@ -38,65 +38,40 @@
namespace overlay {
-// FIXME make int to be uint32 whenever possible
-
-class RotatorBase;
-
/*
-* FIXME do we want rot to be template parameter?
-* It's already using inheritance...
-*
* Sequence to use:
-* open
+* init
* start
* setXXX
* close
-*
-* Can call setRot anytime to replace rotator on-the-fly
* */
class Ctrl : utils::NoCopy {
public:
/* ctor */
explicit Ctrl();
-
/* dtor close */
~Ctrl();
-
- /* should open devices? or start()? */
- bool open(uint32_t fbnum, RotatorBase* rot);
-
+ /* init fd etc*/
+ bool init(uint32_t fbnum);
/* close underlying mdp */
bool close();
- /* Invoke methods for opening underlying devices
- * flags - PIPE SHARED
- * wait - WAIT, NO_WAIT */
- bool start(const utils::PipeArgs& args);
-
- /* Dynamically set rotator*/
- void setRot(RotatorBase* rot);
-
- /* set mdp posision using dim */
- bool setPosition(const utils::Dim& dim);
-
- /* set param using Params (param,value pair) */
- bool setParameter(const utils::Params& p);
-
/* set source using whf, orient and wait flag */
bool setSource(const utils::PipeArgs& args);
-
/* set crop info and pass it down to mdp */
bool setCrop(const utils::Dim& d);
-
+ /* set orientation */
+ bool setTransform(const utils::eTransform& p, const bool&);
+ /* set mdp position using dim */
+ bool setPosition(const utils::Dim& dim);
/* mdp set overlay/commit changes */
bool commit();
/* ctrl id */
- int getId() const;
+ int getPipeId() const;
/* ctrl fd */
int getFd() const;
- bool getRotSessId(int& id) const;
utils::Dim getAspectRatio(const utils::Whf& whf) const;
utils::Dim getAspectRatio(const utils::Dim& dim) const;
@@ -113,40 +88,14 @@
/* Retrieve screen info from underlying mdp */
bool getScreenInfo(utils::ScreenInfo& info);
- /* calls underlying mdp set info */
- bool setInfo(const utils::PipeArgs& args);
-
- /* given whf, update src */
- void updateSource(RotatorBase* r,
- const utils::PipeArgs& args,
- utils::ScreenInfo& info);
-
// mdp ctrl struct(info e.g.)
MdpCtrl mMdp;
- // Rotator
- RotatorBase* mRot;
-
- /* Cache cropped value */
- utils::Dim mCrop;
-
/* Screen info */
utils::ScreenInfo mInfo;
-
- /* orientation cache FIXME */
- utils::eTransform mOrient;
-
- /* Cache last known whfz.
- * That would help us compare to a previous
- * source that was submitted */
- utils::Whf mOvBufInfo;
};
-/*
-* MDP = DataMdp, ROT = CtrlMdp usually since Rotator<>
-* is instansiated with Ctrl data structure.
-* */
class Data : utils::NoCopy {
public:
/* init, reset */
@@ -155,44 +104,30 @@
/* calls close */
~Data();
- /* should open devices? or start()? */
- bool open(uint32_t fbnum, RotatorBase* rot);
+ /* init fd etc */
+ bool init(uint32_t fbnum);
/* calls underlying mdp close */
bool close();
- /* set the rotator */
- void setRot(RotatorBase* rot);
-
- /* set memory id in the mdp struct */
- void setMemoryId(int id);
-
- /* set overlay id in the mdp struct */
- void setId(int id);
+ /* set overlay pipe id in the mdp struct */
+ void setPipeId(int id);
/* get overlay id in the mdp struct */
- int getId() const;
+ int getPipeId() const;
/* queue buffer to the overlay */
- bool queueBuffer(uint32_t offset);
+ bool queueBuffer(int fd, uint32_t offset);
/* wait for vsync to be done */
bool waitForVsync();
/* sump the state of the obj */
void dump() const;
+
private:
- /* play wrapper */
- bool play();
-
- /* playWait wrapper */
- bool playWait();
-
// mdp data struct
MdpData mMdp;
-
- // Rotator
- RotatorBase* mRot;
};
/* This class just creates a Ctrl Data pair to be used by a pipe.
@@ -207,7 +142,7 @@
//-------------Inlines-------------------------------
-inline Ctrl::Ctrl() : mRot(0), mOrient(utils::OVERLAY_TRANSFORM_0) {
+inline Ctrl::Ctrl() {
mMdp.reset();
}
@@ -216,7 +151,6 @@
}
inline bool Ctrl::close() {
- // do not close the rotator
if(!mMdp.close())
return false;
return true;
@@ -238,70 +172,37 @@
return true;
}
-inline bool Ctrl::setInfo(const utils::PipeArgs& args)
-{
- // FIXME set flags, zorder and wait separtly
- if(!mMdp.setInfo(mRot, args, mInfo)){
- ALOGE("Ctrl failed to setInfo wait=%d mdpflags=%d "
- "zorder=%d", args.wait, args.mdpFlags, args.zorder);
- return false;
- }
- return true;
-}
-
-inline int Ctrl::getId() const {
- // FIXME check channel up?
- return mMdp.getId();
+inline int Ctrl::getPipeId() const {
+ return mMdp.getPipeId();
}
inline int Ctrl::getFd() const {
- // FIXME check channel up?
return mMdp.getFd();
}
-inline bool Ctrl::getRotSessId(int& id) const {
- // FIXME check channel up?
- // should be -1 in case of no rot session active
- id = mRot->getSessId();
- return true;
-}
-
inline utils::ScreenInfo Ctrl::getScreenInfo() const {
return mInfo;
}
inline utils::Dim Ctrl::getCrop() const {
- return mCrop;
+ return mMdp.getSrcRectDim();
}
-
-
-inline Data::Data() : mRot(0) {
+inline Data::Data() {
mMdp.reset();
}
inline Data::~Data() { close(); }
-inline void Data::setRot(RotatorBase* rot) { mRot = rot; }
+inline void Data::setPipeId(int id) { mMdp.setPipeId(id); }
-inline void Data::setMemoryId(int id) { mMdp.setMemoryId(id); }
+inline int Data::getPipeId() const { return mMdp.getPipeId(); }
-// really a reqid
-inline void Data::setId(int id) { mMdp.setId(id); }
-
-inline int Data::getId() const { return mMdp.getId(); }
-
-inline bool Data::open(uint32_t fbnum,
- RotatorBase* rot) {
- if(!mMdp.open(fbnum)) {
- ALOGE("Data cannot open mdp");
+inline bool Data::init(uint32_t fbnum) {
+ if(!mMdp.init(fbnum)) {
+ ALOGE("Data cannot init mdp");
return false;
}
-
- OVASSERT(rot, "rot is null");
- mRot = rot;
-
- // rotator should be already opened here
return true;
}
@@ -313,49 +214,22 @@
return true;
}
-inline bool Data::queueBuffer(uint32_t offset) {
- // FIXME asserts on state validity
-
- mMdp.setOffset(offset);
- mRot->setRotDataSrcMemId(mMdp.getMemoryId());
- // will play if succeeded
- if(!mRot->prepareQueueBuf(offset)) {
- ALOGE("Data failed to prepareQueueBuf");
- return false;
- }
- // Play can go either from mdp or rot
- if(!this->play()){
- ALOGE("Data error in MDP/ROT play");
- return false;
- }
-
- return true;
+inline bool Data::queueBuffer(int fd, uint32_t offset) {
+ return mMdp.play(fd, offset);
}
inline bool Data::waitForVsync() {
-
- // Call mdp playWait
- if(!this->playWait()){
- ALOGE("Error in MDP playWait");
+ // Call mdp waitForVsync
+ if(!mMdp.waitForVsync()){
+ ALOGE("Error in MDP %s", __FUNCTION__);
return false;
}
-
return true;
}
-inline bool Data::play() {
- int fd = mMdp.getFd();
- return mRot->enabled() ? mRot->play(fd) : mMdp.play();
-}
-
-inline bool Data::playWait() {
- return mMdp.playWait();
-}
-
inline void Data::dump() const {
ALOGE("== Dump Data MDP start ==");
mMdp.dump();
- mRot->dump();
ALOGE("== Dump Data MDP end ==");
}