1ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*
2ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* Copyright (c) 2011,2013 The Linux Foundation. All rights reserved.
3ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*
4ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* Redistribution and use in source and binary forms, with or without
5ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* modification, are permitted provided that the following conditions are
6ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* met:
7ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*    * Redistributions of source code must retain the above copyright
8ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*      notice, this list of conditions and the following disclaimer.
9ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*    * Redistributions in binary form must reproduce the above
10ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*      copyright notice, this list of conditions and the following
11ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*      disclaimer in the documentation and/or other materials provided
12ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*      with the distribution.
13ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*    * Neither the name of The Linux Foundation. nor the names of its
14ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*      contributors may be used to endorse or promote products derived
15ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*      from this software without specific prior written permission.
16ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*
17ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*/
29ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
30ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#ifndef OVERlAY_ROTATOR_H
31ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#define OVERlAY_ROTATOR_H
32ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
33ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include <stdlib.h>
34ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
35ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include "mdpWrapper.h"
36ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include "overlayUtils.h"
37ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#include "overlayMem.h"
383a21e54387a2b98a15611231e90600aa048a4dddSaurabh Shah#include "sync/sync.h"
39ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
40ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonnamespace overlay {
41ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
42ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*
43ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson   Manages the case where new rotator memory needs to be
44ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson   allocated, before previous is freed, due to resolution change etc. If we make
45ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson   rotator memory to be always max size, irrespctive of source resolution then
46ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson   we don't need this RotMem wrapper. The inner class is sufficient.
47ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*/
48ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonstruct RotMem {
49a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    // Max rotator buffers
50a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    enum { ROT_NUM_BUFS = 2 };
51a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    RotMem();
52a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    ~RotMem();
53ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool close();
54a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    bool valid() { return mem.valid(); }
55a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    uint32_t size() const { return mem.bufSz(); }
56a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    void setReleaseFd(const int& fence);
57a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson
58a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    // rotator data info dst offset
59a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    uint32_t mRotOffset[ROT_NUM_BUFS];
60a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    int mRelFence[ROT_NUM_BUFS];
61a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    // current slot being used
62a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    uint32_t mCurrIndex;
63a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    OvMem mem;
64ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson};
65ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
66ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonclass Rotator
67ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson{
68ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonpublic:
69ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    enum { TYPE_MDP, TYPE_MDSS };
70ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual ~Rotator();
71ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setSource(const utils::Whf& wfh) = 0;
72ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setCrop(const utils::Dim& crop) = 0;
73ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setFlags(const utils::eMdpFlags& flags) = 0;
74ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setTransform(const utils::eTransform& rot) = 0;
75ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual bool commit() = 0;
76ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setDownscale(int ds) = 0;
77c5628e5e5d07912ad30849801f18c07ab433a4f5Saurabh Shah    //Mem id and offset should be retrieved only after rotator kickoff
78ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual int getDstMemId() const = 0;
79ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual uint32_t getDstOffset() const = 0;
80c5628e5e5d07912ad30849801f18c07ab433a4f5Saurabh Shah    //Destination width, height, format, position should be retrieved only after
81c5628e5e5d07912ad30849801f18c07ab433a4f5Saurabh Shah    //rotator configuration is committed via commit API
82ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual uint32_t getDstFormat() const = 0;
83c5628e5e5d07912ad30849801f18c07ab433a4f5Saurabh Shah    virtual utils::Whf getDstWhf() const = 0;
84c5628e5e5d07912ad30849801f18c07ab433a4f5Saurabh Shah    virtual utils::Dim getDstDimensions() const = 0;
85ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual uint32_t getSessId() const = 0;
86ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual bool queueBuffer(int fd, uint32_t offset) = 0;
87ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void dump() const = 0;
88ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void getDump(char *buf, size_t len) const = 0;
89ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void setReleaseFd(const int& fence) { mMem.setReleaseFd(fence); }
90ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    static Rotator *getRotator();
91ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
92ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonprotected:
93ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* Rotator memory manager */
94ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    RotMem mMem;
95ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    explicit Rotator() {}
96ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    static uint32_t calcOutputBufSize(const utils::Whf& destWhf);
97ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
98ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonprivate:
99ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /*Returns rotator h/w type */
100ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    static int getRotatorHwType();
101ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    friend class RotMgr;
102ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson};
103ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
104ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*
105ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* MDP rot holds MDP's rotation related structures.
106ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson*
107ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson* */
108ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonclass MdpRot : public Rotator {
109ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonpublic:
110ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual ~MdpRot();
111ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setSource(const utils::Whf& wfh);
112ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setCrop(const utils::Dim& crop);
113ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setFlags(const utils::eMdpFlags& flags);
114ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setTransform(const utils::eTransform& rot);
115ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual bool commit();
116ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setDownscale(int ds);
117ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual int getDstMemId() const;
118ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual uint32_t getDstOffset() const;
119ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual uint32_t getDstFormat() const;
120c5628e5e5d07912ad30849801f18c07ab433a4f5Saurabh Shah    virtual utils::Whf getDstWhf() const;
121c5628e5e5d07912ad30849801f18c07ab433a4f5Saurabh Shah    virtual utils::Dim getDstDimensions() const;
122ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual uint32_t getSessId() const;
123ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual bool queueBuffer(int fd, uint32_t offset);
124ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void dump() const;
125ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void getDump(char *buf, size_t len) const;
126ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
127ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonprivate:
128ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    explicit MdpRot();
129ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool init();
130ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool close();
131ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void setRotations(uint32_t r);
132ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool enabled () const;
133ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* remap rot buffers */
134ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool remap(uint32_t numbufs);
135ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool open_i(uint32_t numbufs, uint32_t bufsz);
136ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* Deferred transform calculations */
137ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void doTransform();
138ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* reset underlying data, basically memset 0 */
139ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void reset();
140ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* return true if current rotator config is different
141ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson     * than last known config */
142ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool rotConfChanged() const;
143ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* save mRotImgInfo to be last known good config*/
144ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void save();
145ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* Calculates the rotator's o/p buffer size post the transform calcs and
146ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson     * knowing the o/p format depending on whether fastYuv is enabled or not */
147ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32_t calcOutputBufSize();
148ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
149ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* rot info*/
150ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    msm_rotator_img_info mRotImgInfo;
151ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* Last saved rot info*/
152ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    msm_rotator_img_info mLSRotImgInfo;
153ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* rot data */
154ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    msm_rotator_data_info mRotDataInfo;
155ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* Orientation */
156ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    utils::eTransform mOrientation;
157ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* rotator fd */
158ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    OvFD mFd;
159ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
160ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    friend Rotator* Rotator::getRotator();
161ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson};
162ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
163ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson/*
164ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson+* MDSS Rot holds MDSS's rotation related structures.
165ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson+*
166ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson+* */
167ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonclass MdssRot : public Rotator {
168ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonpublic:
169ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual ~MdssRot();
170ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setSource(const utils::Whf& wfh);
171ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setCrop(const utils::Dim& crop);
172ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setFlags(const utils::eMdpFlags& flags);
173ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setTransform(const utils::eTransform& rot);
174ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual bool commit();
175ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void setDownscale(int ds);
176ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual int getDstMemId() const;
177ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual uint32_t getDstOffset() const;
178ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual uint32_t getDstFormat() const;
179c5628e5e5d07912ad30849801f18c07ab433a4f5Saurabh Shah    virtual utils::Whf getDstWhf() const;
180c5628e5e5d07912ad30849801f18c07ab433a4f5Saurabh Shah    virtual utils::Dim getDstDimensions() const;
181ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual uint32_t getSessId() const;
182ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual bool queueBuffer(int fd, uint32_t offset);
183ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void dump() const;
184ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    virtual void getDump(char *buf, size_t len) const;
185ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
186ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonprivate:
187ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    explicit MdssRot();
188ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool init();
189ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool close();
190ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void setRotations(uint32_t r);
191ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool enabled () const;
192ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* remap rot buffers */
193ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool remap(uint32_t numbufs);
194ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool open_i(uint32_t numbufs, uint32_t bufsz);
195ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* Deferred transform calculations */
196ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void doTransform();
197ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* reset underlying data, basically memset 0 */
198ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void reset();
199ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* Calculates the rotator's o/p buffer size post the transform calcs and
200ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson     * knowing the o/p format depending on whether fastYuv is enabled or not */
201ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32_t calcOutputBufSize();
202ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    // Calculate the compressed o/p buffer size for BWC
203ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    uint32_t calcCompressedBufSize(const utils::Whf& destWhf);
204ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
205ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* MdssRot info structure */
206ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    mdp_overlay   mRotInfo;
207ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* MdssRot data structure */
208ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    msmfb_overlay_data mRotData;
209ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* Orientation */
210ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    utils::eTransform mOrientation;
211ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* rotator fd */
212ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    OvFD mFd;
213ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* Enable/Disable Mdss Rot*/
214ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    bool mEnabled;
215ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
216ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    friend Rotator* Rotator::getRotator();
217ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson};
218ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
219ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson// Holder of rotator objects. Manages lifetimes
220ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonclass RotMgr {
221ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonpublic:
2224a7fde21bc0dea152a633521d727dda7d540f262Ramkumar Radhakrishnan    //Virtually we can support as many rotator sessions as possible, However
2234a7fde21bc0dea152a633521d727dda7d540f262Ramkumar Radhakrishnan    // more number of rotator sessions leads to performance issues, so
2244a7fde21bc0dea152a633521d727dda7d540f262Ramkumar Radhakrishnan    // restricting the max rotator session to 4
225ba67e6aec2d54499784ad39340ec8832c753cc35Saurabh Shah    enum { MAX_ROT_SESS = 4 };
226a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson
227ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    ~RotMgr();
228ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void configBegin();
229ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void configDone();
230ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    overlay::Rotator *getNext();
231ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void clear(); //Removes all instances
232a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    //Resets the usage of top count objects, making them available for reuse
233a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    void markUnusedTop(const uint32_t& count) { mUseCount -= count; }
234ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    /* Returns rot dump.
235ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson     * Expects a NULL terminated buffer of big enough size.
236ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson     */
237ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    void getDump(char *buf, size_t len);
238ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int getRotDevFd();
239a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    int getNumActiveSessions() { return mUseCount; }
240a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson
241a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    static RotMgr *getInstance();
242a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson
243ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilsonprivate:
244a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    RotMgr();
245a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    static RotMgr *sRotMgr;
246a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson
247ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    overlay::Rotator *mRot[MAX_ROT_SESS];
248a653efede03423aa840da24634f1ec6f20796f1eSimon Wilson    uint32_t mUseCount;
249ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson    int mRotDevFd;
250ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson};
251ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
252ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
253ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson} // overlay
254ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson
255ef53c1c84ec55ed50f607d52b7abfbb86239408eSimon Wilson#endif // OVERlAY_ROTATOR_H
256