summaryrefslogtreecommitdiff
authorYao.Liu <yao.liu@amlogic.com>2017-11-23 02:54:15 (GMT)
committer Yao.Liu <yao.liu@amlogic.com>2017-11-23 12:58:24 (GMT)
commit6969a43cb31474bc0a5615e2fcc1d40eb02f6598 (patch)
treea168a09b6566b79557a0a1bce416ea3b4f792e9f
parentd5258260762009e1e8e6de8a1f184b1ba7b6b32b (diff)
downloadhwcomposer-6969a43cb31474bc0a5615e2fcc1d40eb02f6598.zip
hwcomposer-6969a43cb31474bc0a5615e2fcc1d40eb02f6598.tar.gz
hwcomposer-6969a43cb31474bc0a5615e2fcc1d40eb02f6598.tar.bz2
hwc2: video layer keep last frame [3/4]
Change-Id: I3979b60deab64f1b32326b5255f6dbbfabdd385c Signed-off-by: Yao.Liu <yao.liu@amlogic.com>
Diffstat
-rw-r--r--hwc2/common/devices/PhysicalDevice.cpp46
-rw-r--r--hwc2/common/utils/AmVideo.cpp44
-rw-r--r--hwc2/include/AmVideo.h3
-rw-r--r--hwc2/include/PhysicalDevice.h4
4 files changed, 95 insertions, 2 deletions
diff --git a/hwc2/common/devices/PhysicalDevice.cpp b/hwc2/common/devices/PhysicalDevice.cpp
index 69264f8..a103715 100644
--- a/hwc2/common/devices/PhysicalDevice.cpp
+++ b/hwc2/common/devices/PhysicalDevice.cpp
@@ -28,7 +28,7 @@
#include <cutils/properties.h>
#include <tvp/OmxUtil.h>
#include <framebuffer.h>
-
+#include <AmVideo.h>
#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() {
@@ -1165,6 +1168,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; i<mHwcLayers.size(); i++) {
hwc2_layer_t layerId = mHwcLayers.keyAt(i);
@@ -1192,8 +1197,19 @@ int32_t PhysicalDevice::preValidate() {
}
mVideoOverlayLayerId = layerId;
}
+
+ if (hnd && (hnd->flags & 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;
}
@@ -1317,6 +1333,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 aaa0292..b128042 100644
--- a/hwc2/include/PhysicalDevice.h
+++ b/hwc2/include/PhysicalDevice.h
@@ -270,6 +270,10 @@ private:
//omx handle for set omx pts
int32_t mOmxVideoHandle;
+ //for omx video layer status.
+ bool mOmxVideoPresent;
+ uint32_t mOmxKeepLastFrame;
+ bool mVideoLayerOpenByOMX;
};