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/overlayRotator.h b/liboverlay/overlayRotator.h
index 39c4f0c..153fb2c 100644
--- a/liboverlay/overlayRotator.h
+++ b/liboverlay/overlayRotator.h
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
+* Copyright (c) 2011, 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
@@ -27,8 +27,8 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef OVERLAY_ROTATOR_H
-#define OVERLAY_ROTATOR_H
+#ifndef OVERlAY_ROTATOR_H
+#define OVERlAY_ROTATOR_H
#include <stdlib.h>
@@ -37,158 +37,111 @@
#include "overlayMem.h"
namespace overlay {
- class MdpCtrl;
+
+class IRotatorHw;
/*
-* MDP rot holds MDP's rotation related structures.
-*
-* */
-class MdpRot {
-public:
- /* ctor */
- explicit MdpRot();
-
- /* open fd for rotator. map bufs is defered */
- bool open();
-
- /* remap rot buffers */
- bool remap(uint32_t numbufs, const utils::PipeArgs& args);
-
- /* Unmap everything that is not current */
- bool unmapNonCurrent();
-
- /* close fd, mem */
- bool close();
-
- /* reset underlying data, basically memset 0 */
- void reset();
-
- /* calls underlying wrappers to start rotator */
- bool start();
-
- /* start underlying but use given whf and flags */
- bool start(const utils::PipeArgs& args);
-
- /* start underlying but use given whf and flags.
- * Has the ability to parameterize the dst fmt */
- template <int ROT_OUT_FMT>
- bool start(const utils::PipeArgs& args);
-
- /* assign memory id to mdp structure */
- void setDataMemId(int fd);
- void setRotDataSrcMemId(int fd);
-
- /* Mark src as FB (non-ION) */
- void setSrcFB(bool);
-
- /* get dst (for offset and memory id) non-virt */
- int getDstMemId() const;
- uint32_t getDstOffset() const;
-
- /* set enable/disable flag */
- void setEnable();
- void setDisable();
- bool enabled() const;
-
- /* set rotator flag*/
- void setRotations(uint32_t r);
-
- /* set the req data id in mData */
- void setDataReqId(int id);
-
- /* swap rot info dst w/h */
- void swapDstWH();
-
- /* returns a copy of src whf */
- utils::Whf getSrcWhf() const;
-
- /* setup rotator data before queue buf calls
- * call play if rotate call succeed. return false if failed */
- bool prepareQueueBuf(uint32_t offset);
-
- /* call play on mdp*/
- bool play(int fd);
-
- /* set src whf */
- void setSrcWhf(const utils::Whf& whf);
-
- /* returns rotator session id */
- int getSessId() const;
-
- /* dump the state of the object */
- void dump() const;
-
-private:
- bool open_i(uint32_t numbufs, uint32_t bufsz);
-
- /* max buf no for offset */
- enum { ROT_MAX_BUF_OFFSET = 2 };
- /* rot info*/
- msm_rotator_img_info mRotImgInfo;
- /* rot data */
- msm_rotator_data_info mRotDataInfo;
- /* data needed for rotator */
- msmfb_overlay_data mData;
- /* rotator fd */
- OvFD mFd;
- /* Array of memory map for rotator
- * The array enable us to change rot buffers/mapping
- * on the fly*/
- struct RotMem {
- enum {MAX_ROT_MEM = 2};
- struct Mem {
- Mem() : mCurrOffset(0) {utils::memset0(mRotOffset); }
- bool valid() { return m.valid(); }
- bool close() { return m.close(); }
- uint32_t size() const { return m.bufSz(); }
- /* rotator data info dst offset */
- uint32_t mRotOffset[ROT_MAX_BUF_OFFSET];
- /* current offset slot from mRotOffset */
- uint32_t mCurrOffset;
- OvMem m;
- };
- RotMem() : _curr(0) {}
- Mem& curr() { return m[_curr % MAX_ROT_MEM]; }
- const Mem& curr() const { return m[_curr % MAX_ROT_MEM]; }
- Mem& prev() { return m[(_curr+1) % MAX_ROT_MEM]; }
- RotMem& operator++() { ++_curr; return *this; }
- bool close();
- uint32_t _curr;
- Mem m[MAX_ROT_MEM];
- } mMem;
- bool isSrcFB;
-};
-
-/*
-* RotatorBase. No memebers, just interface.
-* ~ can also be =0 with empty impl in cpp.
+* RotatorBase. No members, just interface.
+* can also be =0 with empty impl in cpp.
* */
class RotatorBase {
public:
/* Most of the below are No op funcs for RotatorBase */
virtual ~RotatorBase() {}
- virtual bool open() = 0;
- virtual bool remap(uint32_t numbufs, const utils::PipeArgs& args) = 0;
+ virtual bool init() = 0;
virtual bool close() = 0;
- virtual bool start(const utils::PipeArgs& args) = 0;
- virtual bool start() = 0;
- virtual mdp_overlay setInfo(const utils::PipeArgs& args,
- const mdp_overlay& o) = 0;
- virtual bool overlayTransform(MdpCtrl& mdp,
- utils::eTransform& rot) = 0;
- virtual void setSrcWhf(const utils::Whf& wfh) = 0;
- virtual utils::Whf getSrcWhf() const = 0;
- virtual void setRotations(uint32_t r) = 0;
- virtual void setDataReqId(int id) = 0;
- virtual bool prepareQueueBuf(uint32_t offset) = 0;
- virtual bool play(int fd) = 0;
+ virtual void setSource(const utils::Whf& wfh) = 0;
+ virtual void setFlags(const utils::eMdpFlags& flags) = 0;
+ virtual void setTransform(const utils::eTransform& rot,
+ const bool& rotUsed) = 0;
+ virtual bool commit() = 0;
+ virtual bool queueBuffer(int fd, uint32_t offset) = 0;
+
virtual void setEnable() = 0;
virtual void setDisable() = 0;
+ virtual void setRotations(uint32_t r) = 0;
+ virtual void setSrcFB() = 0;
+
virtual bool enabled() const = 0;
- virtual void setDataMemId(int fd) = 0;
- virtual void setRotDataSrcMemId(int fd) = 0;
- virtual void setSrcFB(bool) = 0;
virtual int getSessId() const = 0;
+ virtual int getDstMemId() const = 0;
+ virtual uint32_t getDstOffset() const = 0;
virtual void dump() const = 0;
+
+protected:
+ //Hardware specific rotator impl.
+ IRotatorHw *mRot;
+};
+
+/*
+ * Rotator Hw Interface. Any hardware specific implementation should inherit
+ * from this.
+ */
+class IRotatorHw {
+public:
+ /* Most of the below are No op funcs for RotatorBase */
+ virtual ~IRotatorHw() {}
+ /* init fd for rotator. map bufs is defered */
+ virtual bool init() = 0;
+ /* close fd, mem */
+ virtual bool close() = 0;
+ /* set src */
+ virtual void setSource(const utils::Whf& wfh) = 0;
+ /* set mdp flags, will use only stuff necessary for rotator */
+ virtual void setFlags(const utils::eMdpFlags& flags) = 0;
+ /* Set rotation and calculate */
+ virtual void setTransform(const utils::eTransform& rot,
+ const bool& rotUsed) = 0;
+ /* calls underlying wrappers to start rotator */
+ virtual bool commit() = 0;
+ /* Lazy buffer allocation. queue buffer */
+ virtual bool queueBuffer(int fd, uint32_t offset) = 0;
+ /* set enable/disable flag */
+ virtual void setEnable() = 0;
+ virtual void setDisable() = 0;
+ /* set rotator flag*/
+ virtual void setRotations(uint32_t r) = 0;
+ /* Mark src as FB (non-ION) */
+ virtual void setSrcFB() = 0;
+ /* Retusn true if rotator enabled */
+ virtual bool enabled() const = 0;
+ /* returns rotator session id */
+ virtual int getSessId() const = 0;
+ /* get dst (for offset and memory id) non-virt */
+ virtual int getDstMemId() const = 0;
+ virtual uint32_t getDstOffset() const = 0;
+ /* dump the state of the object */
+ virtual void dump() const = 0;
+
+ enum { TYPE_MDP, TYPE_MDSS };
+ /*Returns rotator h/w type */
+ static int getRotatorHwType();
+};
+
+/*
+* Actual Rotator impl.
+* */
+class Rotator : public RotatorBase
+{
+public:
+ explicit Rotator();
+ virtual ~Rotator();
+ virtual bool init();
+ virtual bool close();
+ virtual void setSource(const utils::Whf& wfh);
+ virtual void setFlags(const utils::eMdpFlags& flags);
+ virtual void setTransform(const utils::eTransform& rot,
+ const bool& rotUsed);
+ virtual bool commit();
+ virtual void setRotations(uint32_t r);
+ virtual void setSrcFB();
+ virtual int getDstMemId() const;
+ virtual uint32_t getDstOffset() const;
+ virtual void setEnable();
+ virtual void setDisable();
+ virtual bool enabled () const;
+ virtual int getSessId() const;
+ virtual bool queueBuffer(int fd, uint32_t offset);
+ virtual void dump() const;
};
/*
@@ -198,357 +151,217 @@
public:
/* Most of the below are No op funcs for RotatorBase */
virtual ~NullRotator();
- virtual bool open();
- virtual bool remap(uint32_t numbufs, const utils::PipeArgs& args);
+ virtual bool init();
virtual bool close();
- virtual bool start(const utils::PipeArgs& args);
- virtual bool start();
- /* null rotator behavior should set info in a specific way */
- virtual mdp_overlay setInfo(const utils::PipeArgs& args,
- const mdp_overlay& o);
- virtual bool overlayTransform(MdpCtrl& o,
- utils::eTransform& rot);
- virtual void setSrcWhf(const utils::Whf& wfh);
- virtual utils::Whf getSrcWhf() const;
+ virtual void setSource(const utils::Whf& wfh);
+ virtual void setFlags(const utils::eMdpFlags& flags);
+ virtual void setTransform(const utils::eTransform& rot,
+ const bool& rotUsed);
+ virtual bool commit();
virtual void setRotations(uint32_t r);
- virtual void setDataReqId(int id);
- virtual bool prepareQueueBuf(uint32_t offset);
- virtual bool play(int fd);
+ virtual bool queueBuffer(int fd, uint32_t offset);
virtual void setEnable();
virtual void setDisable();
virtual bool enabled () const;
- virtual void setDataMemId(int fd);
- virtual void setRotDataSrcMemId(int fd);
- virtual void setSrcFB(bool);
+ virtual void setSrcFB();
virtual int getSessId() const;
+ virtual int getDstMemId() const;
+ virtual uint32_t getDstOffset() const;
virtual void dump() const;
};
+/*
+ Manages the case where new rotator memory needs to be
+ allocated, before previous is freed, due to resolution change etc. If we make
+ rotator memory to be always max size, irrespctive of source resolution then
+ we don't need this RotMem wrapper. The inner class is sufficient.
+*/
+struct RotMem {
+ // Max rotator memory allocations
+ enum { MAX_ROT_MEM = 2};
+
+ //Manages the rotator buffer offsets.
+ struct Mem {
+ Mem() : mCurrOffset(0) {utils::memset0(mRotOffset); }
+ bool valid() { return m.valid(); }
+ bool close() { return m.close(); }
+ uint32_t size() const { return m.bufSz(); }
+ // Max rotator buffers
+ enum { ROT_NUM_BUFS = 2 };
+ // rotator data info dst offset
+ uint32_t mRotOffset[ROT_NUM_BUFS];
+ // current offset slot from mRotOffset
+ uint32_t mCurrOffset;
+ OvMem m;
+ };
+
+ RotMem() : _curr(0) {}
+ Mem& curr() { return m[_curr % MAX_ROT_MEM]; }
+ const Mem& curr() const { return m[_curr % MAX_ROT_MEM]; }
+ Mem& prev() { return m[(_curr+1) % MAX_ROT_MEM]; }
+ RotMem& operator++() { ++_curr; return *this; }
+ bool close();
+ uint32_t _curr;
+ Mem m[MAX_ROT_MEM];
+};
/*
-* Rotator impl.
+* MDP rot holds MDP's rotation related structures.
+*
* */
-class Rotator : public RotatorBase
-{
+class MdpRot : public IRotatorHw {
public:
- /* construct underlying object */
- explicit Rotator();
-
- /* close underlying rot */
- virtual ~Rotator();
-
- /* calls underlying open */
- virtual bool open();
-
- /* remap rot buffers */
- virtual bool remap(uint32_t numbufs, const utils::PipeArgs& args);
-
- /* calls underlying close */
- virtual bool close();
-
- /* calls underlying start */
- virtual bool start();
-
- /* calls underlying start with whf and flags */
- virtual bool start(const utils::PipeArgs& args);
-
- /* non virtual - calls underlying start with whf and flags.
- * Has the ability to parameterize the dst */
- template <int ROT_OUT_FMT>
- bool start(const utils::PipeArgs& args);
-
- /* Unmap everything that is not current */
- bool unmapNonCurrent();
-
- /* set info using whf and given mdp */
- virtual mdp_overlay setInfo(const utils::PipeArgs& args,
- const mdp_overlay& o);
-
- /* transform function for the MDP */
- virtual bool overlayTransform(MdpCtrl& mdp,
- utils::eTransform& rot);
-
- /* set src whf */
- virtual void setSrcWhf(const utils::Whf& wfh);
-
- /* set Rotations */
- virtual void setRotations(uint32_t r);
-
- /* set the req data id in mData */
- virtual void setDataReqId(int id);
-
- /* set memory_id */
- virtual void setDataMemId(int fd);
- virtual void setRotDataSrcMemId(int fd);
-
- /* Mark the src for rotator as FB. usually set by UI mirroing cases */
- virtual void setSrcFB(bool);
-
- /* get dst (for offset and memory id) non-virt */
+ explicit MdpRot();
+ ~MdpRot();
+ bool init();
+ bool close();
+ void setSource(const utils::Whf& whf);
+ virtual void setFlags(const utils::eMdpFlags& flags);
+ void setTransform(const utils::eTransform& rot,
+ const bool& rotUsed);
+ bool commit();
+ bool queueBuffer(int fd, uint32_t offset);
+ void setEnable();
+ void setDisable();
+ void setRotations(uint32_t r);
+ void setSrcFB();
+ bool enabled() const;
+ int getSessId() const;
int getDstMemId() const;
uint32_t getDstOffset() const;
+ void dump() const;
- /* set enable/disable flag */
- virtual void setEnable();
- virtual void setDisable();
- virtual bool enabled () const;
-
- /* return rotator sess id */
- virtual int getSessId() const;
-
- /* return a copy of src whf*/
- virtual utils::Whf getSrcWhf() const;
-
- /* prepare rot for queue buf*/
- virtual bool prepareQueueBuf(uint32_t offset);
-
- /* call play on mdp*/
- virtual bool play(int fd);
-
- /* dump the state of the object */
- virtual void dump() const;
private:
- /* helper functions for overlayTransform */
- void overlayTransFlipHV(MdpCtrl& mdp,
- utils::eTransform& rot);
- void overlayTransFlipRot90(MdpCtrl& mdp,
- utils::eTransform& rot);
- void overlayTransFlipRot180(MdpCtrl& mdp);
- void overlayTransFlipRot270(MdpCtrl& mdp);
+ /* remap rot buffers */
+ bool remap(uint32_t numbufs);
+ bool open_i(uint32_t numbufs, uint32_t bufsz);
+ /* Deferred transform calculations */
+ void doTransform();
+ /* reset underlying data, basically memset 0 */
+ void reset();
- /* underlying rotator MDP object */
- MdpRot mRot;
+ /* rot info*/
+ msm_rotator_img_info mRotImgInfo;
+ /* rot data */
+ msm_rotator_data_info mRotDataInfo;
+ /* Orientation */
+ utils::eTransform mOrientation;
+ /* rotator fd */
+ OvFD mFd;
+ /* Rotator memory manager */
+ RotMem mMem;
+ /* Single Rotator buffer size */
+ uint32_t mBufSize;
};
//--------------inlines------------------------------------
-//// MdpRot ////
-inline MdpRot::MdpRot() { reset(); }
-inline bool MdpRot::start(const utils::PipeArgs& args) {
- return this->start<utils::ROT_OUT_FMT_DEFAULT>(args);
+
+///// Rotator /////
+inline Rotator::Rotator() {
+ int type = IRotatorHw::getRotatorHwType();
+ if(type == IRotatorHw::TYPE_MDP) {
+ mRot = new MdpRot(); //will do reset
+ } else if(type == IRotatorHw::TYPE_MDSS) {
+ //TODO create mdss specific rotator
+ } else {
+ ALOGE("%s Unknown h/w type %d", __FUNCTION__, type);
+ }
+}
+inline Rotator::~Rotator() {
+ delete mRot; //will do close
+}
+inline bool Rotator::init() {
+ if(!mRot->init()) {
+ ALOGE("Rotator::init failed");
+ return false;
+ }
+ return true;
+}
+inline bool Rotator::close() {
+ return mRot->close();
+}
+inline void Rotator::setSource(const utils::Whf& whf) {
+ mRot->setSource(whf);
+}
+inline void Rotator::setFlags(const utils::eMdpFlags& flags) {
+ mRot->setFlags(flags);
+}
+inline void Rotator::setTransform(const utils::eTransform& rot,
+ const bool& rotUsed)
+{
+ mRot->setTransform(rot, rotUsed);
+}
+inline bool Rotator::commit() {
+ return mRot->commit();
+}
+inline void Rotator::setEnable(){ mRot->setEnable(); }
+inline void Rotator::setDisable(){ mRot->setDisable(); }
+inline bool Rotator::enabled() const { return mRot->enabled(); }
+inline void Rotator::setSrcFB() { mRot->setSrcFB(); }
+inline int Rotator::getDstMemId() const {
+ return mRot->getDstMemId();
+}
+inline uint32_t Rotator::getDstOffset() const {
+ return mRot->getDstOffset();
+}
+inline void Rotator::setRotations(uint32_t rot) {
+ mRot->setRotations (rot);
+}
+inline int Rotator::getSessId() const {
+ return mRot->getSessId();
+}
+inline void Rotator::dump() const {
+ ALOGE("== Dump Rotator start ==");
+ mRot->dump();
+ ALOGE("== Dump Rotator end ==");
+}
+inline bool Rotator::queueBuffer(int fd, uint32_t offset) {
+ return mRot->queueBuffer(fd, offset);
}
-inline void MdpRot::setDataMemId(int fd) { mData.data.memory_id = fd; }
-inline void MdpRot::setRotDataSrcMemId(int fd) {
- mRotDataInfo.src.memory_id = fd; }
+///// Null Rotator /////
+inline NullRotator::~NullRotator() {}
+inline bool NullRotator::init() { return true; }
+inline bool NullRotator::close() { return true; }
+inline bool NullRotator::commit() { return true; }
+inline void NullRotator::setSource(const utils::Whf& wfh) {}
+inline void NullRotator::setFlags(const utils::eMdpFlags& flags) {}
+inline void NullRotator::setTransform(const utils::eTransform& rot, const bool&)
+{}
+inline void NullRotator::setRotations(uint32_t) {}
+inline void NullRotator::setEnable() {}
+inline void NullRotator::setDisable() {}
+inline bool NullRotator::enabled() const { return false; }
+inline int NullRotator::getSessId() const { return -1; }
+inline bool NullRotator::queueBuffer(int fd, uint32_t offset) { return true; }
+inline void NullRotator::setSrcFB() {}
+inline int NullRotator::getDstMemId() const { return -1; }
+inline uint32_t NullRotator::getDstOffset() const { return 0;}
+inline void NullRotator::dump() const {
+ ALOGE("== Dump NullRotator dump (null) start/end ==");
+}
+
+
+//// MdpRot ////
+inline MdpRot::MdpRot() { reset(); }
+inline MdpRot::~MdpRot() { close(); }
inline void MdpRot::setEnable() { mRotImgInfo.enable = 1; }
inline void MdpRot::setDisable() { mRotImgInfo.enable = 0; }
inline bool MdpRot::enabled() const { return mRotImgInfo.enable; }
-
inline void MdpRot::setRotations(uint32_t r) { mRotImgInfo.rotations = r; }
-inline void MdpRot::setDataReqId(int id) { mData.id = id; }
-inline void MdpRot::swapDstWH() {
- overlay::utils::swap(mRotImgInfo.dst.width,
- mRotImgInfo.dst.height); }
-
-inline overlay::utils::Whf MdpRot::getSrcWhf() const {
- return overlay::utils::Whf(mRotImgInfo.src.width,
- mRotImgInfo.src.height,
- mRotImgInfo.src.format);
-}
-
inline int MdpRot::getDstMemId() const {
return mRotDataInfo.dst.memory_id;
}
inline uint32_t MdpRot::getDstOffset() const {
return mRotDataInfo.dst.offset;
}
-
-inline void MdpRot::setSrcWhf(const overlay::utils::Whf& whf) {
- mRotImgInfo.src.width = whf.w;
- mRotImgInfo.src.height = whf.h;
- mRotImgInfo.src.format = whf.format;
-}
-
inline int MdpRot::getSessId() const { return mRotImgInfo.session_id; }
-
-inline void MdpRot::setSrcFB(bool mark) { isSrcFB = mark; }
-
-///// Null Rotator /////
-inline NullRotator::~NullRotator() {}
-inline bool NullRotator::open() {
- return true; }
-inline bool NullRotator::remap(uint32_t numbufs,
- const utils::PipeArgs& args){
- return true; }
-inline bool NullRotator::close() { return true; }
-inline bool NullRotator::start(const utils::PipeArgs& args)
-{ return true; }
-
-inline bool NullRotator::start() { return true; }
-inline bool NullRotator::overlayTransform(MdpCtrl& o,
- utils::eTransform& rot)
-{ return true; }
-inline void NullRotator::setSrcWhf(const overlay::utils::Whf& wfh) {}
-inline void NullRotator::setRotations(uint32_t) {}
-inline void NullRotator::setDataReqId(int id) {}
-inline void NullRotator::setEnable() {}
-inline void NullRotator::setDisable() {}
-inline bool NullRotator::enabled() const { return false; }
-inline int NullRotator::getSessId() const { return -1; }
-inline overlay::utils::Whf NullRotator::getSrcWhf() const {
- return overlay::utils::Whf(); }
-inline bool NullRotator::prepareQueueBuf(uint32_t offset)
-{ return true; }
-inline bool NullRotator::play(int fd)
-{ return true; }
-inline void NullRotator::setDataMemId(int fd) {}
-inline void NullRotator::setRotDataSrcMemId(int fd) {}
-inline void NullRotator::setSrcFB(bool) {}
-inline void NullRotator::dump() const {
- ALOGE("== Dump NullRotator dump (null) start/end ==");
-}
-
-///// Rotator /////
-inline Rotator::Rotator() { }
-
-inline Rotator::~Rotator() {
- mRot.close(); // also will do reset
-}
-
-inline bool Rotator::open() {
- if(!mRot.open()) {
- ALOGE("Rotator::open failed");
- return false;
- }
- return true;
-}
-
-template <int ROT_OUT_FMT>
-inline bool Rotator::start(const utils::PipeArgs& args) {
- return mRot.start<ROT_OUT_FMT>(args);
-}
-
-inline bool Rotator::remap(uint32_t numbufs,
- const utils::PipeArgs& args){
- if(!mRot.remap(numbufs, args)) {
- ALOGE("%s failed", __FUNCTION__);
- return false;
- }
- return true;
-}
-
-inline bool Rotator::close() {
- return mRot.close();
-}
-
-inline bool Rotator::start() {
- return mRot.start();
-}
-
-inline bool Rotator::start(const utils::PipeArgs& args) {
- return mRot.start(args);
-}
-
-inline bool Rotator::unmapNonCurrent() {
- return mRot.unmapNonCurrent();
-}
-
-inline void Rotator::setEnable(){ mRot.setEnable(); }
-inline void Rotator::setDisable(){ mRot.setDisable(); }
-inline bool Rotator::enabled() const { return mRot.enabled(); }
-inline void Rotator::setDataMemId(int fd) {
- mRot.setDataMemId(fd); }
-
-inline void Rotator::setRotDataSrcMemId(int fd) {
- mRot.setRotDataSrcMemId(fd);
-}
-
-inline void Rotator::setSrcFB(bool mark) { mRot.setSrcFB(mark); }
-
-inline int Rotator::getDstMemId() const {
- return mRot.getDstMemId();
-}
-inline uint32_t Rotator::getDstOffset() const {
- return mRot.getDstOffset();
-}
-
-inline void Rotator::setDataReqId(int id) {
- mRot.setDataReqId(id);
-}
-
-inline void Rotator::setSrcWhf(
- const overlay::utils::Whf& whf) {
- mRot.setSrcWhf(whf);
-}
-
-inline void Rotator::setRotations(uint32_t rot) {
- mRot.setRotations (rot);
-}
-
-inline int Rotator::getSessId() const {
- return mRot.getSessId(); }
-
-inline void Rotator::dump() const {
- ALOGE("== Dump Rotator start ==");
- mRot.dump();
- ALOGE("== Dump Rotator end ==");
-}
-
-inline overlay::utils::Whf Rotator::getSrcWhf() const {
- return mRot.getSrcWhf(); }
-
-inline bool Rotator::prepareQueueBuf(uint32_t offset)
-{
- return mRot.prepareQueueBuf(offset);
-}
-
-inline bool Rotator::play(int fd)
-{
- return mRot.play(fd);
-}
-
-template <int ROT_OUT_FMT>
-bool MdpRot::start(const utils::PipeArgs& args) {
- // Do nothing when no orientation
- if(utils::OVERLAY_TRANSFORM_0 == args.orientation &&
- utils::ROT_FLAG_ENABLED != args.rotFlags) {
- return true;
- }
- utils::Whf whf(args.whf);
- mRotImgInfo.src.format = whf.format;
- mRotImgInfo.src.width = whf.w;
- mRotImgInfo.src.height = whf.h;
- mRotImgInfo.src_rect.w = whf.w;
- mRotImgInfo.src_rect.h = whf.h;
- mRotImgInfo.dst.width = whf.w;
- mRotImgInfo.dst.height = whf.h;
- if(whf.format == MDP_Y_CRCB_H2V2_TILE ||
- whf.format == MDP_Y_CBCR_H2V2_TILE) {
- mRotImgInfo.src.width = utils::alignup(whf.w, 64);
- mRotImgInfo.src.height = utils::alignup(whf.h, 32);
- mRotImgInfo.src_rect.w = utils::alignup(whf.w, 64);
- mRotImgInfo.src_rect.h = utils::alignup(whf.h, 32);
- mRotImgInfo.dst.width = utils::alignup(whf.w, 64);
- mRotImgInfo.dst.height = utils::alignup(whf.h, 32);
- mRotImgInfo.dst.format = MDP_Y_CRCB_H2V2;
- }
- // either utils::getRotOutFmt(whf.format); or supplied fmt
- // utils::RotOutFmt<ROT_OUT_FMT_DEFAULT>::fmt;
- mRotImgInfo.dst.format = utils::RotOutFmt<ROT_OUT_FMT>::fmt(whf.format);
- mRotImgInfo.dst_x = 0;
- mRotImgInfo.dst_y = 0;
- mRotImgInfo.src_rect.x = 0;
- mRotImgInfo.src_rect.y = 0;
- mRotImgInfo.rotations = 0;
- // ROT_FLAG_DISABLED / ENABLED
- // Refer to overlayUtils.h eRotFlags
- // for more info
- mRotImgInfo.enable = args.rotFlags;
- mRotImgInfo.session_id = mRotImgInfo.session_id ?
- mRotImgInfo.session_id : 0;
-
- return start();
+inline void MdpRot::setSrcFB() {
+ mRotDataInfo.src.flags |= MDP_MEMORY_ID_TYPE_FB;
}
} // overlay
-namespace {
-// just a helper func for Rotator common operations x-(y+z)
-int compute(uint32_t x, uint32_t y, uint32_t z) {
- return x-(y+z);
-}
-}
-
-#endif // OVERLAY_ROTATOR_H
+#endif // OVERlAY_ROTATOR_H