/* * Copyright (c) 2018 Amlogic, Inc. All rights reserved. * * This source code is subject to the terms and conditions defined in the * file 'LICENSE' which is part of this source code package. * * Description: */ #ifndef COMPOSITION_STRATEGY_BASE_H #define COMPOSITION_STRATEGY_BASE_H #include #include #include #include "ICompositionStrategyBase.h" #include "MesonLog.h" #define OSD_OUTPUT_ONE_CHANNEL 1 #define OSD_FB_BEGIN_ZORDER 65 // osd zorder: 65 - 128 #define TOP_VIDEO_FB_BEGIN_ZORDER 129 // top video zorder: 129 - 192 #define BOTTOM_VIDEO_FB_BEGIN_ZORDER 1 // bottom video zorder: 1 - 64 #define OSD_SCALER_INPUT_MAX_WIDTH (1920) #define OSD_SCALER_INPUT_MAX_HEIGHT (1080) #define OSD_SCALER_INPUT_FACTOR (3.0) #define OSD_SCALER_INPUT_MARGIN (1.1) #define DEFAULT_REFRESH_RATE (60.0f) #define IS_FB_COMPOSED(fb) \ ((fb)->getZorder() >= mMinComposerZorder && (fb)->getZorder() <= mMaxComposerZorder) class CompositionStrategyBase : public ICompositionStrategyBase { public: CompositionStrategyBase(); ~CompositionStrategyBase() = default; virtual const char* getName() {return "CompositionStrategyBase";} virtual void setup(std::vector> & layers, std::vector> & composers, std::vector> & planes, std::shared_ptr & crtc, uint32_t flags, float scaleValue, drm_mode_info_t mode); virtual void updateComposition(); virtual int decideComposition(); virtual int commit() { return 0; } virtual int commitTunnelVideo() { return 0; } virtual int getDisplayPair(std::list & displayPairs); virtual void dump(std::string & dumpstr); protected: virtual void init(); virtual int applyCompositionFlags(); int processVideoFbs(); int processGfxFbs(); int pickoutOsdFbs(); int countComposerFbs(int &belowClientNum, int &upClientNum, int &insideClientNum); int confirmComposerRange(); int setOsdFbs2PlanePairs(); int selectComposer(); int fillComposerFbs(); void handleOverlayVideoZorder(); int checkCommitZorder(); void handleVPUOddScaleLimit(); void handleVPUScaleLimit(); void handleVPULimit(bool video); void handleDisplayLayerZorder(); int handleOsdComposition(); int handleOsdCompositionWithVideo(); int32_t compareFbScale(drm_rect_t & aSrc, drm_rect_t & aDst, drm_rect_t & bSrc, drm_rect_t & bDst); int deleteFbFromVectorFbs( std::vector> & inputFbs, std::shared_ptr & Fb); int chooseVideoFbsBaseNoOverlap( std::vector> & inputVideoFbs, std::vector> & outputVideoFbs); int chooseOneVideoFbBaseBiggestWindow( std::vector> & inputVideoFbs, std::shared_ptr & outputVideoFb); int chooseOneVideoFbBaseVideoType( std::vector> & inputVideoFbs, std::shared_ptr & outputVideoFb); int chooseOneVideoFb( std::shared_ptr & outputVideoFb, bool bVideoCompose); int chooseVideoFbFromLegacySideband( std::vector> & sidebandFbs, std::shared_ptr & outputVideoFb); bool chooseOneVideoFbBasePriority( std::vector> & inputVideoFbs, std::shared_ptr & outputVideoFb); bool checkAndHandle4Mosaic(uint32_t videoZorder); void checkLayerValidate(std::shared_ptr & fb); void fillDebugInfoStr(); bool hasPlaneSupport(std::shared_ptr fb); void decidePlaneAssignment(); bool tryAllocate(int idx, const std::vector>& layers, std::vector>& planes, std::vector& bUsed, std::unordered_map& results); protected: /* Input Flags from SF */ bool mHDRMode; bool mHideSecureLayer; bool mForceClientComposer; bool mForceVideoComposer; bool mMosaicEnabled; bool m4Mosaic; bool mHideVideoForHdcpDev; /* Input Fbs from SF, min zorder at begin, max zorder at end. */ std::map, std::less> mFramebuffers; /*reffb is the fb used to setup the osddisplayframe.*/ std::shared_ptr mDisplayRefFb; display_zoom_info_t mOsdDisplayFrame; /* Composer */ std::shared_ptr mDummyComposer; std::shared_ptr mClientComposer; std::vector> mVideoComposers; std::vector> mOtherComposers; /* Get display planes from DisplayManager */ std::vector> mOsdPlanes; std::vector> mHwcVideoPlanes; // Future VIDEO support : 2 HwcVideoPlane std::vector> mOtherPlanes; /* Use for composer */ std::shared_ptr mComposer; // Handle composer Fbs std::vector> mOverlayFbs; std::vector> mComposerFbs; // Save Fbs that should be composered std::vector> mVideoComposerFbs; /*crtc*/ std::shared_ptr mCrtc; drm_mode_info_t mDisplayMode; std::list mDisplayPairs; bool mHaveClient; bool mInsideVideoFbsFlag; // Has VIDEO between different OSD ui layers. uint32_t mMinComposerZorder; uint32_t mMaxComposerZorder; uint32_t mMinVideoZorder; uint32_t mMaxVideoZorder; int mOsdPlaneNum; int mVideoPlaneNum; int mVideoComposerNum; uint32_t mCompositionFlag; float mScaleValue; bool mIsSideBandDisable; bool mIsVideoComposerV2D; // Layer Zorder -> Plane ID std::unordered_map mLayerAssignment; }; #endif/*COMPOSITION_STRATEGY_BASE_H*/