From 6391df031abe4909fb886fb5ed844c7743277b92 Mon Sep 17 00:00:00 2001 From: Sky Zhou Date: Tue, 28 Nov 2017 10:20:06 +0000 Subject: Merge "hwc2: video layer keep last frame [3/4]" into o-amlogic --- diff --git a/hwc2/common/devices/PhysicalDevice.cpp b/hwc2/common/devices/PhysicalDevice.cpp index 85490e8..bc75be2 100644 --- a/hwc2/common/devices/PhysicalDevice.cpp +++ b/hwc2/common/devices/PhysicalDevice.cpp @@ -28,7 +28,7 @@ #include #include #include - +#include #define FBIOPUT_OSD_CURSOR 0x451a namespace android { @@ -60,7 +60,8 @@ PhysicalDevice::PhysicalDevice(hwc2_display_t id, Hwcomposer& hwc, IComposeDevic mGetInitState(false), mInitialized(false), mOmxVideoHandle(0), - mFirstPostFb(true){ + mFirstPostFb(true), + mVideoLayerOpenByOMX(false) { CTRACE(); switch (id) { @@ -85,6 +86,8 @@ PhysicalDevice::PhysicalDevice(hwc2_display_t id, Hwcomposer& hwc, IComposeDevic mGE2DRenderSortedLayerIds.clear(); mHwcCurReleaseFences = mHwcPriorReleaseFences = NULL; + mOmxKeepLastFrame = 0; + AmVideo::getInstance()->getOmxKeepLastFrame(&mOmxKeepLastFrame); } PhysicalDevice::~PhysicalDevice() { @@ -1250,6 +1253,8 @@ bool PhysicalDevice::calReverseScale() { int32_t PhysicalDevice::preValidate() { bool bScale = (mReverseScaleX >= 0.01f && mReverseScaleX >= 0.01f) ? true : false; HwcLayer* layer = NULL; + int videoPresentFlags = 0; //0: no video, 1: video presetn, 2: omx video present; + //find out video layer first. for (uint32_t i=0; iflags & private_handle_t::PRIV_FLAGS_VIDEO_OMX)) { + videoPresentFlags = 2; + } else if (hnd && (hnd->flags & private_handle_t::PRIV_FLAGS_VIDEO_OVERLAY)) { + videoPresentFlags = 1; + } } + if (videoPresentFlags == 2) { + mOmxVideoPresent = true; + } else { + mOmxVideoPresent = false; + } return HWC2_ERROR_NONE; } @@ -1402,6 +1418,32 @@ int32_t PhysicalDevice::validateDisplay(uint32_t* outNumTypes, break; } } + if (mOmxKeepLastFrame == 1) { + int is_disable_video = -1; + AmVideo::getInstance()->getvideodisable(&is_disable_video); + //ALOGD("is_disable_video %d, mOmxVideoPresent %d",is_disable_video,mOmxVideoPresent); + if (mOmxVideoPresent) { + //enable video layer + if (is_disable_video == 1) { + ALOGI("video layer present, enable video layer"); + AmVideo::getInstance()->setvideodisable(2); + } + mVideoLayerOpenByOMX = true; + } else { + //disable video layer. + if (mVideoLayerOpenByOMX) { + if (is_disable_video == 0) { + if (mVideoOverlayLayerId == 0) { + ALOGI("no omx video layer, no OVERLAY, set display_mode 2"); + AmVideo::getInstance()->setvideodisable(2); + } else { + ALOGI("no omx video layer, but has OVERLAY, not set display_mode"); + } + } + mVideoLayerOpenByOMX = false; + } + } + } bool noDevComp = Utils::checkBoolProp("sys.sf.debug.nohwc"); #ifndef USE_CONTINOUS_BUFFER_COMPOSER diff --git a/hwc2/common/utils/AmVideo.cpp b/hwc2/common/utils/AmVideo.cpp index 15db0c9..89e0fbc 100644 --- a/hwc2/common/utils/AmVideo.cpp +++ b/hwc2/common/utils/AmVideo.cpp @@ -33,6 +33,9 @@ using namespace android; #define AMSTREAM_IOC_MAGIC 'S' #define AMSTREAM_IOC_GLOBAL_GET_VIDEO_OUTPUT _IOR(AMSTREAM_IOC_MAGIC, 0x21, int) #define AMSTREAM_IOC_GLOBAL_SET_VIDEO_OUTPUT _IOW(AMSTREAM_IOC_MAGIC, 0x22, int) +#define AMSTREAM_IOC_GET_VIDEO_DISABLE _IOR((AMSTREAM_IOC_MAGIC), 0x48, int) +#define AMSTREAM_IOC_SET_VIDEO_DISABLE _IOW((AMSTREAM_IOC_MAGIC), 0x49, int) +#define AMSTREAM_IOC_GET_OMX_INFO _IOR((AMSTREAM_IOC_MAGIC), 0xb2, unsigned int) AmVideo* AmVideo::mInstance = NULL; Mutex AmVideo::mLock; @@ -107,3 +110,44 @@ int AmVideo::getVideoPresent(bool& output) { return 0; } +int AmVideo::getvideodisable(int* mode) { + if (mDevFd < 0) + return -EBADF; + + int ret = ioctl(mDevFd, AMSTREAM_IOC_GET_VIDEO_DISABLE, mode); + if (ret < 0) { + ALOGE("getvideodisable error, ret=%d", ret); + return ret; + } + return 0; +} + +int AmVideo::setvideodisable(int mode) { + if (mDevFd < 0) + return -EBADF; + int ret = ioctl(mDevFd, AMSTREAM_IOC_SET_VIDEO_DISABLE, &mode); + if (ret < 0) { + ALOGE("setvideodisable error, ret=%d", ret); + return ret; + } + return 0; +} + +int AmVideo::getOmxKeepLastFrame(unsigned int *keepLastFrame) { + if (mDevFd < 0) + return -EBADF; + + unsigned long omx_info = 0; + int ret = ioctl(mDevFd, AMSTREAM_IOC_GET_OMX_INFO, &omx_info); + if (ret < 0) { + ALOGE("get omx info error, ret =%d", ret); + *keepLastFrame = 0; + return ret; + } else { + *keepLastFrame = omx_info & 0x1; //omx_info bit0: keep last frmame + } + //ALOGV("video layer keepLastFrame %d", *keepLastFrame); + return 0; + +} + diff --git a/hwc2/include/AmVideo.h b/hwc2/include/AmVideo.h index 4d2c8e8..b1eb94c 100644 --- a/hwc2/include/AmVideo.h +++ b/hwc2/include/AmVideo.h @@ -25,6 +25,9 @@ public: static AmVideo* getInstance(); int presentVideo(bool bPresent); bool isVideoPresent() {return mVideoPresent;} + int getvideodisable(int* mode); + int setvideodisable(int mode); + int getOmxKeepLastFrame(unsigned int *keepLastFrame); protected: AmVideo(); diff --git a/hwc2/include/PhysicalDevice.h b/hwc2/include/PhysicalDevice.h index e47982f..6c5fa5c 100644 --- a/hwc2/include/PhysicalDevice.h +++ b/hwc2/include/PhysicalDevice.h @@ -290,6 +290,10 @@ private: //omx handle for set omx pts int32_t mOmxVideoHandle; + //for omx video layer status. + bool mOmxVideoPresent; + uint32_t mOmxKeepLastFrame; + bool mVideoLayerOpenByOMX; }; -- cgit