• 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 <hal_public.h>
21 #include <DisplayPlane.h>
22 #include <BufferMapper.h>
23 #include <common/Wsbm.h>
24 #include <common/OverlayHardware.h>
25 #include <common/VideoPayloadBuffer.h>
26 
27 namespace android {
28 namespace intel {
29 
30 typedef struct {
31     OverlayBackBufferBlk *buf;
32     uint32_t gttOffsetInPage;
33     void* bufObject;
34 } OverlayBackBuffer;
35 
36 class OverlayPlaneBase : public DisplayPlane {
37 public:
38     OverlayPlaneBase(int index, int disp);
39     virtual ~OverlayPlaneBase();
40 
41     virtual void invalidateBufferCache();
42 
43     virtual bool assignToDevice(int disp);
44 
45     virtual void setZOrderConfig(ZOrderConfig& config, void *nativeConfig);
46 
47     // plane operations
48     virtual bool flip(void *ctx) = 0;
49     virtual bool reset();
50     virtual bool enable();
51     virtual bool disable();
52     virtual bool isDisabled();
53 
54     virtual void* getContext() const = 0;
55     virtual bool initialize(uint32_t bufferCount);
56     virtual void deinitialize();
57 
58 protected:
59     // generic overlay register flush
60     virtual bool flush(uint32_t flags) = 0;
61     virtual bool setDataBuffer(BufferMapper& mapper);
62     virtual bool bufferOffsetSetup(BufferMapper& mapper);
63     virtual uint32_t calculateSWidthSW(uint32_t offset, uint32_t width);
64     virtual bool coordinateSetup(BufferMapper& mapper);
65     virtual bool setCoeffRegs(double *coeff, int mantSize,
66                                  coeffPtr pCoeff, int pos);
67     virtual void updateCoeff(int taps, double fCutoff,
68                                 bool isHoriz, bool isY,
69                                 coeffPtr pCoeff);
70     virtual bool scalingSetup(BufferMapper& mapper);
71     virtual bool colorSetup(BufferMapper& mapper);
72     virtual void checkPosition(int& x, int& y, int& w, int& h);
73     virtual void checkCrop(int& x, int& y, int& w, int& h, int coded_width, int coded_height);
74 
75 
76 protected:
77     // back buffer operations
78     virtual OverlayBackBuffer* createBackBuffer();
79     virtual void deleteBackBuffer(int buf);
80     virtual void resetBackBuffer(int buf);
81 
82     virtual BufferMapper* getTTMMapper(BufferMapper& grallocMapper, struct VideoPayloadBuffer *payload);
83     virtual void  putTTMMapper(BufferMapper* mapper);
84     virtual bool rotatedBufferReady(BufferMapper& mapper, BufferMapper* &rotatedMapper);
85     virtual bool useOverlayRotation(BufferMapper& mapper);
86     virtual bool scaledBufferReady(BufferMapper& mapper, BufferMapper* &scaledMapper, VideoPayloadBuffer *payload);
87 
88 private:
89     inline bool isActiveTTMBuffer(BufferMapper *mapper);
90     void updateActiveTTMBuffers(BufferMapper *mapper);
91     void invalidateActiveTTMBuffers();
92     void invalidateTTMBuffers();
93 
94 protected:
95     // flush flags
96     enum {
97         PLANE_ENABLE     = 0x00000001UL,
98         PLANE_DISABLE    = 0x00000002UL,
99         UPDATE_COEF      = 0x00000004UL,
100     };
101 
102     enum {
103         OVERLAY_BACK_BUFFER_COUNT = 3,
104         MAX_ACTIVE_TTM_BUFFERS = 3,
105         OVERLAY_DATA_BUFFER_COUNT = 20,
106     };
107 
108     // TTM data buffers
109     KeyedVector<buffer_handle_t, BufferMapper*> mTTMBuffers;
110     // latest TTM buffers
111     Vector<BufferMapper*> mActiveTTMBuffers;
112 
113     // overlay back buffer
114     OverlayBackBuffer *mBackBuffer[OVERLAY_BACK_BUFFER_COUNT];
115     int mCurrent;
116     // wsbm
117     Wsbm *mWsbm;
118     // pipe config
119     uint32_t mPipeConfig;
120 
121     int mBobDeinterlace;
122     int mUseScaledBuffer;
123 };
124 
125 } // namespace intel
126 } // namespace android
127 
128 #endif /* OVERLAY_PLANE_BASE_H */
129 
130