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