• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 // Copyright (c) 2014 Intel Corporation 
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
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 void checkPosition(int& x, int& y, int& w, int& h);
71     virtual void checkCrop(int& x, int& y, int& w, int& h, int coded_width, int coded_height);
72 
73 
74 protected:
75     // back buffer operations
76     virtual OverlayBackBuffer* createBackBuffer();
77     virtual void deleteBackBuffer(int buf);
78     virtual void resetBackBuffer(int buf);
79 
80     virtual BufferMapper* getTTMMapper(BufferMapper& grallocMapper, struct VideoPayloadBuffer *payload);
81     virtual void  putTTMMapper(BufferMapper* mapper);
82     virtual bool rotatedBufferReady(BufferMapper& mapper, BufferMapper* &rotatedMapper);
83     virtual bool useOverlayRotation(BufferMapper& mapper);
84 
85 private:
86     inline bool isActiveTTMBuffer(BufferMapper *mapper);
87     void updateActiveTTMBuffers(BufferMapper *mapper);
88     void invalidateActiveTTMBuffers();
89     void invalidateTTMBuffers();
90 
91 protected:
92     // flush flags
93     enum {
94         PLANE_ENABLE     = 0x00000001UL,
95         PLANE_DISABLE    = 0x00000002UL,
96         UPDATE_COEF      = 0x00000004UL,
97     };
98 
99     enum {
100         OVERLAY_BACK_BUFFER_COUNT = 3,
101         MAX_ACTIVE_TTM_BUFFERS = 3,
102         OVERLAY_DATA_BUFFER_COUNT = 20,
103     };
104 
105     // TTM data buffers
106     KeyedVector<uint64_t, BufferMapper*> mTTMBuffers;
107     // latest TTM buffers
108     Vector<BufferMapper*> mActiveTTMBuffers;
109 
110     // overlay back buffer
111     OverlayBackBuffer *mBackBuffer[OVERLAY_BACK_BUFFER_COUNT];
112     int mCurrent;
113     // wsbm
114     Wsbm *mWsbm;
115     // pipe config
116     uint32_t mPipeConfig;
117 
118     int mBobDeinterlace;
119 };
120 
121 } // namespace intel
122 } // namespace android
123 
124 #endif /* OVERLAY_PLANE_BASE_H */
125 
126