Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 1 | /* |
Raj kamal | 23f69b2 | 2012-11-17 00:20:55 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011,2013 The Linux Foundation. All rights reserved. |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 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. |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 13 | * * Neither the name of The Linux Foundation. nor the names of its |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 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 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 30 | #ifndef OVERlAY_ROTATOR_H |
| 31 | #define OVERlAY_ROTATOR_H |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 32 | |
| 33 | #include <stdlib.h> |
| 34 | |
| 35 | #include "mdpWrapper.h" |
| 36 | #include "overlayUtils.h" |
| 37 | #include "overlayMem.h" |
| 38 | |
| 39 | namespace overlay { |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 40 | |
Saurabh Shah | 23a813c | 2013-03-20 16:58:12 -0700 | [diff] [blame] | 41 | /* |
| 42 | Manages the case where new rotator memory needs to be |
| 43 | allocated, before previous is freed, due to resolution change etc. If we make |
| 44 | rotator memory to be always max size, irrespctive of source resolution then |
| 45 | we don't need this RotMem wrapper. The inner class is sufficient. |
| 46 | */ |
| 47 | struct RotMem { |
Saurabh Shah | 912c948 | 2014-02-07 14:01:04 -0800 | [diff] [blame] | 48 | // Max rotator buffers |
| 49 | enum { ROT_NUM_BUFS = 2 }; |
| 50 | RotMem(); |
| 51 | ~RotMem(); |
Saurabh Shah | 23a813c | 2013-03-20 16:58:12 -0700 | [diff] [blame] | 52 | bool close(); |
Saurabh Shah | 912c948 | 2014-02-07 14:01:04 -0800 | [diff] [blame] | 53 | bool valid() { return mem.valid(); } |
| 54 | uint32_t size() const { return mem.bufSz(); } |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 55 | void setCurrBufReleaseFd(const int& fence); |
| 56 | void setPrevBufReleaseFd(const int& fence); |
Saurabh Shah | 912c948 | 2014-02-07 14:01:04 -0800 | [diff] [blame] | 57 | |
| 58 | // rotator data info dst offset |
| 59 | uint32_t mRotOffset[ROT_NUM_BUFS]; |
| 60 | int mRelFence[ROT_NUM_BUFS]; |
| 61 | // current slot being used |
| 62 | uint32_t mCurrIndex; |
| 63 | OvMem mem; |
Saurabh Shah | 23a813c | 2013-03-20 16:58:12 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 66 | class Rotator |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 67 | { |
| 68 | public: |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 69 | enum { TYPE_MDP, TYPE_MDSS }; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 70 | virtual ~Rotator(); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 71 | virtual void setSource(const utils::Whf& wfh) = 0; |
Sushil Chauhan | 80fc1f9 | 2013-04-23 17:30:05 -0700 | [diff] [blame] | 72 | virtual void setCrop(const utils::Dim& crop) = 0; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 73 | virtual void setFlags(const utils::eMdpFlags& flags) = 0; |
Ramkumar Radhakrishnan | 288f8c7 | 2013-01-15 11:37:54 -0800 | [diff] [blame] | 74 | virtual void setTransform(const utils::eTransform& rot) = 0; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 75 | virtual bool commit() = 0; |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 76 | /* return true if the current rotator state is cached */ |
| 77 | virtual bool isRotCached(int fd, uint32_t offset) const; |
| 78 | /* return true if current rotator config is same as the last round*/ |
| 79 | virtual bool rotConfChanged() const = 0; |
| 80 | /* return true if the current rotator input buffer fd and offset |
| 81 | * are same as the last round */ |
| 82 | virtual bool rotDataChanged(int fd, uint32_t offset) const; |
Ramkumar Radhakrishnan | 288f8c7 | 2013-01-15 11:37:54 -0800 | [diff] [blame] | 83 | virtual void setDownscale(int ds) = 0; |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 84 | /* returns the src buffer of the rotator for the previous/current round, |
| 85 | * depending on when it is called(before/after the queuebuffer)*/ |
| 86 | virtual int getSrcMemId() const = 0; |
Saurabh Shah | 8ec9b5e | 2014-06-30 14:37:17 -0700 | [diff] [blame] | 87 | //Mem id and offset should be retrieved only after rotator kickoff |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 88 | virtual int getDstMemId() const = 0; |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 89 | virtual uint32_t getSrcOffset() const = 0; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 90 | virtual uint32_t getDstOffset() const = 0; |
Saurabh Shah | 8ec9b5e | 2014-06-30 14:37:17 -0700 | [diff] [blame] | 91 | //Destination width, height, format, position should be retrieved only after |
| 92 | //rotator configuration is committed via commit API |
Raj kamal | 23f69b2 | 2012-11-17 00:20:55 +0530 | [diff] [blame] | 93 | virtual uint32_t getDstFormat() const = 0; |
Saurabh Shah | 8ec9b5e | 2014-06-30 14:37:17 -0700 | [diff] [blame] | 94 | virtual utils::Whf getDstWhf() const = 0; |
| 95 | virtual utils::Dim getDstDimensions() const = 0; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 96 | virtual uint32_t getSessId() const = 0; |
| 97 | virtual bool queueBuffer(int fd, uint32_t offset) = 0; |
| 98 | virtual void dump() const = 0; |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 99 | virtual void getDump(char *buf, size_t len) const = 0; |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 100 | inline void setCurrBufReleaseFd(const int& fence) { |
| 101 | mMem.setCurrBufReleaseFd(fence); |
| 102 | } |
| 103 | inline void setPrevBufReleaseFd(const int& fence) { |
| 104 | mMem.setPrevBufReleaseFd(fence); |
| 105 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 106 | static Rotator *getRotator(); |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 107 | /* Returns downscale by successfully applying constraints |
| 108 | * Returns 0 if target doesnt support rotator downscaling |
| 109 | * or if any of the constraints are not met |
| 110 | */ |
| 111 | static int getDownscaleFactor(const int& srcW, const int& srcH, |
| 112 | const int& dstW, const int& dstH, const uint32_t& mdpFormat, |
| 113 | const bool& isInterlaced); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 114 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 115 | protected: |
Saurabh Shah | 23a813c | 2013-03-20 16:58:12 -0700 | [diff] [blame] | 116 | /* Rotator memory manager */ |
| 117 | RotMem mMem; |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 118 | Rotator(); |
Saurabh Shah | fc3652f | 2013-02-15 13:15:45 -0800 | [diff] [blame] | 119 | static uint32_t calcOutputBufSize(const utils::Whf& destWhf); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 120 | |
| 121 | private: |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 122 | bool mRotCacheDisabled; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 123 | /*Returns rotator h/w type */ |
| 124 | static int getRotatorHwType(); |
Saurabh Shah | 23a813c | 2013-03-20 16:58:12 -0700 | [diff] [blame] | 125 | friend class RotMgr; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 126 | }; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 127 | |
| 128 | /* |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 129 | * MDP rot holds MDP's rotation related structures. |
| 130 | * |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 131 | * */ |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 132 | class MdpRot : public Rotator { |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 133 | public: |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 134 | virtual ~MdpRot(); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 135 | virtual void setSource(const utils::Whf& wfh); |
Sushil Chauhan | 80fc1f9 | 2013-04-23 17:30:05 -0700 | [diff] [blame] | 136 | virtual void setCrop(const utils::Dim& crop); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 137 | virtual void setFlags(const utils::eMdpFlags& flags); |
Ramkumar Radhakrishnan | 288f8c7 | 2013-01-15 11:37:54 -0800 | [diff] [blame] | 138 | virtual void setTransform(const utils::eTransform& rot); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 139 | virtual bool commit(); |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 140 | virtual bool rotConfChanged() const; |
Ramkumar Radhakrishnan | 288f8c7 | 2013-01-15 11:37:54 -0800 | [diff] [blame] | 141 | virtual void setDownscale(int ds); |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 142 | virtual int getSrcMemId() const; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 143 | virtual int getDstMemId() const; |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 144 | virtual uint32_t getSrcOffset() const; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 145 | virtual uint32_t getDstOffset() const; |
Raj kamal | 23f69b2 | 2012-11-17 00:20:55 +0530 | [diff] [blame] | 146 | virtual uint32_t getDstFormat() const; |
Saurabh Shah | 8ec9b5e | 2014-06-30 14:37:17 -0700 | [diff] [blame] | 147 | virtual utils::Whf getDstWhf() const; |
| 148 | virtual utils::Dim getDstDimensions() const; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 149 | virtual uint32_t getSessId() const; |
| 150 | virtual bool queueBuffer(int fd, uint32_t offset); |
| 151 | virtual void dump() const; |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 152 | virtual void getDump(char *buf, size_t len) const; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 153 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 154 | private: |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 155 | explicit MdpRot(); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 156 | bool init(); |
| 157 | bool close(); |
| 158 | void setRotations(uint32_t r); |
| 159 | bool enabled () const; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 160 | /* remap rot buffers */ |
| 161 | bool remap(uint32_t numbufs); |
| 162 | bool open_i(uint32_t numbufs, uint32_t bufsz); |
| 163 | /* Deferred transform calculations */ |
| 164 | void doTransform(); |
| 165 | /* reset underlying data, basically memset 0 */ |
| 166 | void reset(); |
Saurabh Shah | c23b380 | 2012-08-31 11:11:30 -0700 | [diff] [blame] | 167 | /* save mRotImgInfo to be last known good config*/ |
| 168 | void save(); |
Saurabh Shah | fc3652f | 2013-02-15 13:15:45 -0800 | [diff] [blame] | 169 | /* Calculates the rotator's o/p buffer size post the transform calcs and |
| 170 | * knowing the o/p format depending on whether fastYuv is enabled or not */ |
| 171 | uint32_t calcOutputBufSize(); |
Saurabh Shah | c23b380 | 2012-08-31 11:11:30 -0700 | [diff] [blame] | 172 | |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 173 | /* Applies downscale by taking areas |
| 174 | * Returns a log(downscale) |
| 175 | * Constraints applied: |
| 176 | * - downscale should be a power of 2 |
| 177 | * - Max downscale is 1/8 |
| 178 | */ |
| 179 | static int getDownscaleFactor(const int& srcW, const int& srcH, |
| 180 | const int& dstW, const int& dstH, const uint32_t& mdpFormat, |
| 181 | const bool& isInterlaced); |
| 182 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 183 | /* rot info*/ |
| 184 | msm_rotator_img_info mRotImgInfo; |
Saurabh Shah | c23b380 | 2012-08-31 11:11:30 -0700 | [diff] [blame] | 185 | /* Last saved rot info*/ |
| 186 | msm_rotator_img_info mLSRotImgInfo; |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 187 | /* rot data */ |
| 188 | msm_rotator_data_info mRotDataInfo; |
| 189 | /* Orientation */ |
| 190 | utils::eTransform mOrientation; |
| 191 | /* rotator fd */ |
| 192 | OvFD mFd; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 193 | |
| 194 | friend Rotator* Rotator::getRotator(); |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 195 | friend int Rotator::getDownscaleFactor(const int& srcW, const int& srcH, |
| 196 | const int& dstW, const int& dstH, const uint32_t& mdpFormat, |
| 197 | const bool& isInterlaced); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 198 | }; |
| 199 | |
Saurabh Shah | e012f7a | 2012-08-18 15:11:57 -0700 | [diff] [blame] | 200 | /* |
| 201 | +* MDSS Rot holds MDSS's rotation related structures. |
| 202 | +* |
| 203 | +* */ |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 204 | class MdssRot : public Rotator { |
Saurabh Shah | e012f7a | 2012-08-18 15:11:57 -0700 | [diff] [blame] | 205 | public: |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 206 | virtual ~MdssRot(); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 207 | virtual void setSource(const utils::Whf& wfh); |
Sushil Chauhan | 80fc1f9 | 2013-04-23 17:30:05 -0700 | [diff] [blame] | 208 | virtual void setCrop(const utils::Dim& crop); |
Saurabh Shah | e012f7a | 2012-08-18 15:11:57 -0700 | [diff] [blame] | 209 | virtual void setFlags(const utils::eMdpFlags& flags); |
Ramkumar Radhakrishnan | 288f8c7 | 2013-01-15 11:37:54 -0800 | [diff] [blame] | 210 | virtual void setTransform(const utils::eTransform& rot); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 211 | virtual bool commit(); |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 212 | virtual bool rotConfChanged() const; |
Ramkumar Radhakrishnan | 288f8c7 | 2013-01-15 11:37:54 -0800 | [diff] [blame] | 213 | virtual void setDownscale(int ds); |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 214 | virtual int getSrcMemId() const; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 215 | virtual int getDstMemId() const; |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 216 | virtual uint32_t getSrcOffset() const; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 217 | virtual uint32_t getDstOffset() const; |
Raj kamal | 23f69b2 | 2012-11-17 00:20:55 +0530 | [diff] [blame] | 218 | virtual uint32_t getDstFormat() const; |
Saurabh Shah | 8ec9b5e | 2014-06-30 14:37:17 -0700 | [diff] [blame] | 219 | virtual utils::Whf getDstWhf() const; |
| 220 | virtual utils::Dim getDstDimensions() const; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 221 | virtual uint32_t getSessId() const; |
| 222 | virtual bool queueBuffer(int fd, uint32_t offset); |
| 223 | virtual void dump() const; |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 224 | virtual void getDump(char *buf, size_t len) const; |
Saurabh Shah | e012f7a | 2012-08-18 15:11:57 -0700 | [diff] [blame] | 225 | |
| 226 | private: |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 227 | explicit MdssRot(); |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 228 | bool init(); |
| 229 | bool close(); |
| 230 | void setRotations(uint32_t r); |
| 231 | bool enabled () const; |
Saurabh Shah | e012f7a | 2012-08-18 15:11:57 -0700 | [diff] [blame] | 232 | /* remap rot buffers */ |
| 233 | bool remap(uint32_t numbufs); |
| 234 | bool open_i(uint32_t numbufs, uint32_t bufsz); |
| 235 | /* Deferred transform calculations */ |
| 236 | void doTransform(); |
| 237 | /* reset underlying data, basically memset 0 */ |
| 238 | void reset(); |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 239 | /* save mRotInfo to be last known good config*/ |
| 240 | void save(); |
Saurabh Shah | fc3652f | 2013-02-15 13:15:45 -0800 | [diff] [blame] | 241 | /* Calculates the rotator's o/p buffer size post the transform calcs and |
| 242 | * knowing the o/p format depending on whether fastYuv is enabled or not */ |
| 243 | uint32_t calcOutputBufSize(); |
Sushil Chauhan | bab187a | 2013-01-30 17:44:15 -0800 | [diff] [blame] | 244 | // Calculate the compressed o/p buffer size for BWC |
Sushil Chauhan | 466766f | 2013-07-31 11:21:07 -0700 | [diff] [blame] | 245 | uint32_t calcCompressedBufSize(const utils::Whf& destWhf); |
Saurabh Shah | e012f7a | 2012-08-18 15:11:57 -0700 | [diff] [blame] | 246 | |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 247 | /* Caller's responsibility to swap srcW, srcH if there is a 90 transform |
| 248 | * Returns actual downscale (not a log value) |
| 249 | * Constraints applied: |
| 250 | * - downscale should be a power of 2 |
| 251 | * - Max downscale is 1/32 |
| 252 | * - Equal downscale is applied in both directions |
| 253 | * - {srcW, srcH} mod downscale = 0 |
| 254 | * - Interlaced content is not supported |
| 255 | */ |
| 256 | static int getDownscaleFactor(const int& srcW, const int& srcH, |
| 257 | const int& dstW, const int& dstH, const uint32_t& mdpFormat, |
| 258 | const bool& isInterlaced); |
| 259 | |
| 260 | static utils::Dim getFormatAdjustedCrop(const utils::Dim& crop, |
| 261 | const uint32_t& mdpFormat, const bool& isInterlaced); |
| 262 | |
| 263 | static utils::Dim getDownscaleAdjustedCrop(const utils::Dim& crop, |
| 264 | const uint32_t& downscale); |
| 265 | |
Saurabh Shah | e012f7a | 2012-08-18 15:11:57 -0700 | [diff] [blame] | 266 | /* MdssRot info structure */ |
Raj Kamal | bd3bdc6 | 2014-08-05 18:52:49 +0530 | [diff] [blame] | 267 | mdp_overlay mRotInfo; |
| 268 | /* Last saved MdssRot info structure*/ |
| 269 | mdp_overlay mLSRotInfo; |
Saurabh Shah | e012f7a | 2012-08-18 15:11:57 -0700 | [diff] [blame] | 270 | /* MdssRot data structure */ |
| 271 | msmfb_overlay_data mRotData; |
| 272 | /* Orientation */ |
| 273 | utils::eTransform mOrientation; |
| 274 | /* rotator fd */ |
| 275 | OvFD mFd; |
Saurabh Shah | e012f7a | 2012-08-18 15:11:57 -0700 | [diff] [blame] | 276 | /* Enable/Disable Mdss Rot*/ |
| 277 | bool mEnabled; |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 278 | int mDownscale; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 279 | |
| 280 | friend Rotator* Rotator::getRotator(); |
Saurabh Shah | c46cf9d | 2014-07-02 15:22:34 -0700 | [diff] [blame] | 281 | friend int Rotator::getDownscaleFactor(const int& srcW, const int& srcH, |
| 282 | const int& dstW, const int& dstH, const uint32_t& mdpFormat, |
| 283 | const bool& isInterlaced); |
Saurabh Shah | e012f7a | 2012-08-18 15:11:57 -0700 | [diff] [blame] | 284 | }; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 285 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 286 | // Holder of rotator objects. Manages lifetimes |
| 287 | class RotMgr { |
| 288 | public: |
Ramkumar Radhakrishnan | 9d20b39 | 2013-11-15 19:32:47 -0800 | [diff] [blame] | 289 | //Virtually we can support as many rotator sessions as possible, However |
| 290 | // more number of rotator sessions leads to performance issues, so |
| 291 | // restricting the max rotator session to 4 |
Saurabh Shah | 5431857 | 2014-05-30 16:42:33 -0700 | [diff] [blame] | 292 | enum { MAX_ROT_SESS = 4 }; |
Saurabh Shah | 7a60684 | 2013-12-11 14:36:04 -0800 | [diff] [blame] | 293 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 294 | ~RotMgr(); |
| 295 | void configBegin(); |
| 296 | void configDone(); |
| 297 | overlay::Rotator *getNext(); |
| 298 | void clear(); //Removes all instances |
Saurabh Shah | 7a60684 | 2013-12-11 14:36:04 -0800 | [diff] [blame] | 299 | //Resets the usage of top count objects, making them available for reuse |
| 300 | void markUnusedTop(const uint32_t& count) { mUseCount -= count; } |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 301 | /* Returns rot dump. |
| 302 | * Expects a NULL terminated buffer of big enough size. |
| 303 | */ |
| 304 | void getDump(char *buf, size_t len); |
Saurabh Shah | e9b5a8f | 2013-06-28 11:33:25 -0700 | [diff] [blame] | 305 | int getRotDevFd(); |
Saurabh Shah | 2b6e519 | 2013-10-22 17:22:04 -0700 | [diff] [blame] | 306 | int getNumActiveSessions() { return mUseCount; } |
Saurabh Shah | 7a60684 | 2013-12-11 14:36:04 -0800 | [diff] [blame] | 307 | |
| 308 | static RotMgr *getInstance(); |
| 309 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 310 | private: |
Saurabh Shah | 7a60684 | 2013-12-11 14:36:04 -0800 | [diff] [blame] | 311 | RotMgr(); |
| 312 | static RotMgr *sRotMgr; |
| 313 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 314 | overlay::Rotator *mRot[MAX_ROT_SESS]; |
Saurabh Shah | 7a60684 | 2013-12-11 14:36:04 -0800 | [diff] [blame] | 315 | uint32_t mUseCount; |
Saurabh Shah | e9b5a8f | 2013-06-28 11:33:25 -0700 | [diff] [blame] | 316 | int mRotDevFd; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 317 | }; |
| 318 | |
| 319 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 320 | } // overlay |
| 321 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 322 | #endif // OVERlAY_ROTATOR_H |