Home | History | Annotate | Download | only in common
      1 /*
      2 // Copyright(c)2014 IntelCorporation
      3 //
      4 // LicensedundertheApacheLicense,Version2.0(the"License");
      5 // youmaynotusethisfileexceptincompliancewiththeLicense.
      6 // YoumayobtainacopyoftheLicenseat
      7 //
      8 // http://www.apache.org/licenses/LICENSE-2.0
      9 //
     10 // Unlessrequiredbyapplicablelaworagreedtoinwriting,software
     11 // distributedundertheLicenseisdistributedonan"ASIS"BASIS,
     12 // WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
     13 // SeetheLicenseforthespecificlanguagegoverningpermissionsand
     14 // limitationsundertheLicense.
     15 */
     16 #ifndef OVERLAY_PLANE_BASE_H
     17 #define OVERLAY_PLANE_BASE_H
     18 
     19 #include <utils/KeyedVector.h>
     20 #include <DisplayPlane.h>
     21 #include <BufferMapper.h>
     22 #include <ips/common/Wsbm.h>
     23 #include <ips/common/OverlayHardware.h>
     24 #include <ips/common/VideoPayloadBuffer.h>
     25 
     26 namespace android {
     27 namespace intel {
     28 
     29 typedef struct {
     30     OverlayBackBufferBlk *buf;
     31     uint32_t gttOffsetInPage;
     32     uint32_t bufObject;
     33 } OverlayBackBuffer;
     34 
     35 class OverlayPlaneBase : public DisplayPlane {
     36 public:
     37     OverlayPlaneBase(int index, int disp);
     38     virtual ~OverlayPlaneBase();
     39 
     40     virtual void invalidateBufferCache();
     41 
     42     virtual bool assignToDevice(int disp);
     43 
     44     virtual void setZOrderConfig(ZOrderConfig& config, void *nativeConfig);
     45 
     46     // plane operations
     47     virtual bool flip(void *ctx) = 0;
     48     virtual bool reset();
     49     virtual bool enable();
     50     virtual bool disable();
     51     virtual bool isDisabled();
     52 
     53     virtual void* getContext() const = 0;
     54     virtual bool initialize(uint32_t bufferCount);
     55     virtual void deinitialize();
     56 
     57 protected:
     58     // generic overlay register flush
     59     virtual bool flush(uint32_t flags) = 0;
     60     virtual bool setDataBuffer(BufferMapper& mapper);
     61     virtual bool bufferOffsetSetup(BufferMapper& mapper);
     62     virtual uint32_t calculateSWidthSW(uint32_t offset, uint32_t width);
     63     virtual bool coordinateSetup(BufferMapper& mapper);
     64     virtual bool setCoeffRegs(double *coeff, int mantSize,
     65                                  coeffPtr pCoeff, int pos);
     66     virtual void updateCoeff(int taps, double fCutoff,
     67                                 bool isHoriz, bool isY,
     68                                 coeffPtr pCoeff);
     69     virtual bool scalingSetup(BufferMapper& mapper);
     70     virtual bool colorSetup(BufferMapper& mapper);
     71     virtual void checkPosition(int& x, int& y, int& w, int& h);
     72     virtual void checkCrop(int& x, int& y, int& w, int& h, int coded_width, int coded_height);
     73 
     74 
     75 protected:
     76     // back buffer operations
     77     virtual OverlayBackBuffer* createBackBuffer();
     78     virtual void deleteBackBuffer(int buf);
     79     virtual void resetBackBuffer(int buf);
     80 
     81     virtual BufferMapper* getTTMMapper(BufferMapper& grallocMapper, struct VideoPayloadBuffer *payload);
     82     virtual void  putTTMMapper(BufferMapper* mapper);
     83     virtual bool rotatedBufferReady(BufferMapper& mapper, BufferMapper* &rotatedMapper);
     84     virtual bool useOverlayRotation(BufferMapper& mapper);
     85 
     86 private:
     87     inline bool isActiveTTMBuffer(BufferMapper *mapper);
     88     void updateActiveTTMBuffers(BufferMapper *mapper);
     89     void invalidateActiveTTMBuffers();
     90     void invalidateTTMBuffers();
     91 
     92 protected:
     93     // flush flags
     94     enum {
     95         PLANE_ENABLE     = 0x00000001UL,
     96         PLANE_DISABLE    = 0x00000002UL,
     97         UPDATE_COEF      = 0x00000004UL,
     98     };
     99 
    100     enum {
    101         OVERLAY_BACK_BUFFER_COUNT = 3,
    102         MAX_ACTIVE_TTM_BUFFERS = 3,
    103         OVERLAY_DATA_BUFFER_COUNT = 20,
    104     };
    105 
    106     // TTM data buffers
    107     KeyedVector<uint64_t, BufferMapper*> mTTMBuffers;
    108     // latest TTM buffers
    109     Vector<BufferMapper*> mActiveTTMBuffers;
    110 
    111     // overlay back buffer
    112     OverlayBackBuffer *mBackBuffer[OVERLAY_BACK_BUFFER_COUNT];
    113     int mCurrent;
    114     // wsbm
    115     Wsbm *mWsbm;
    116     // pipe config
    117     uint32_t mPipeConfig;
    118 
    119     int mBobDeinterlace;
    120 };
    121 
    122 } // namespace intel
    123 } // namespace android
    124 
    125 #endif /* OVERLAY_PLANE_BASE_H */
    126 
    127