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 17 #ifndef __ROTATIONO_BUFFER_PROVIDER_H__ 18 #define __ROTATIONO_BUFFER_PROVIDER_H__ 19 20 #include <va/va.h> 21 #include <sys/time.h> 22 #include <va/va_tpi.h> 23 #include <va/va_vpp.h> 24 #include <ips/common/Wsbm.h> 25 #include <utils/Timers.h> 26 #include <va/va_android.h> 27 #include <ips/common/VideoPayloadBuffer.h> 28 29 namespace android { 30 namespace intel { 31 32 #define Display unsigned int 33 typedef void* VADisplay; 34 typedef int VAStatus; 35 36 class RotationBufferProvider { 37 38 public: 39 RotationBufferProvider(Wsbm* wsbm); 40 ~RotationBufferProvider(); 41 42 bool initialize(); 43 void deinitialize(); 44 void reset(); 45 bool setupRotationBuffer(VideoPayloadBuffer *payload, int transform); 46 bool prepareBufferInfo(int, int, int, VideoPayloadBuffer *, void *); 47 48 private: 49 void invalidateCaches(); 50 bool startVA(VideoPayloadBuffer *payload, int transform); 51 void stopVA(); 52 bool isContextChanged(int width, int height, int transform); 53 int transFromHalToVa(int transform); 54 uint32_t createWsbmBuffer(int width, int height, void **buf); 55 int getStride(bool isTarget, int width); 56 bool createVaSurface(VideoPayloadBuffer *payload, int transform, bool isTarget); 57 void freeVaSurfaces(); 58 inline uint32_t getMilliseconds(); 59 60 private: 61 enum { 62 MAX_SURFACE_NUM = 4 63 }; 64 65 Wsbm* mWsbm; 66 67 bool mVaInitialized; 68 VADisplay mVaDpy; 69 VAConfigID mVaCfg; 70 VAContextID mVaCtx; 71 VABufferID mVaBufFilter; 72 VASurfaceID mSourceSurface; 73 Display mDisplay; 74 75 // rotation config variables 76 int mWidth; 77 int mHeight; 78 int mTransform; 79 80 int mRotatedWidth; 81 int mRotatedHeight; 82 int mRotatedStride; 83 84 int mTargetIndex; 85 int mKhandles[MAX_SURFACE_NUM]; 86 VASurfaceID mRotatedSurfaces[MAX_SURFACE_NUM]; 87 void *mDrmBuf[MAX_SURFACE_NUM]; 88 89 enum { 90 TTM_WRAPPER_COUNT = 10, 91 }; 92 93 KeyedVector<uint64_t, void*> mTTMWrappers; /* userPt/wsbmBuffer */ 94 95 int mBobDeinterlace; 96 }; 97 98 } // name space intel 99 } // name space android 100 101 #endif 102