author | Tianhua Sun <tianhua.sun@amlogic.com> | 2020-03-20 10:04:03 (GMT) |
---|---|---|
committer | sky zhou <sky.zhou@amlogic.com> | 2020-05-21 12:13:07 (GMT) |
commit | 2ad946a29b4dad712adda4b691c685b4ed33c618 (patch) | |
tree | 025581fd8406917c830ed4565cfeb349234aab9c | |
parent | 7a43c0cc48490a32d0117a3d839c44daad21dc8e (diff) | |
download | hwcomposer-2ad946a29b4dad712adda4b691c685b4ed33c618.zip hwcomposer-2ad946a29b4dad712adda4b691c685b4ed33c618.tar.gz hwcomposer-2ad946a29b4dad712adda4b691c685b4ed33c618.tar.bz2 |
display: fix video stream switch play error [1/1]
PD#SWPL-22398
Problem:
DTVKit and YouTube switch to each other,
YouTube will occur black screen but have audio.
Solution:
if the plane blank type is UNBLANK and
video disable status is 1, set video disable
status to 2.
Verify:
verity on newton
Change-Id: Iabb70fb8c3a7903babe37c374b1def39d0d03aaf
Signed-off-by: Tianhua Sun <tianhua.sun@amlogic.com>
-rw-r--r-- | common/display/HwDisplayManager.cpp | 1 | ||||
-rw-r--r-- | common/display/HwcVideoPlane.cpp | 93 | ||||
-rw-r--r-- | common/display/HwcVideoPlane.h | 8 |
3 files changed, 102 insertions, 0 deletions
diff --git a/common/display/HwDisplayManager.cpp b/common/display/HwDisplayManager.cpp index dfea1fa..0b47c01 100644 --- a/common/display/HwDisplayManager.cpp +++ b/common/display/HwDisplayManager.cpp @@ -189,6 +189,7 @@ int32_t HwDisplayManager::loadPlanes() { plane_idx = video_idx_max + idx; std::shared_ptr<HwcVideoPlane> plane = std::make_shared<HwcVideoPlane>(fd, plane_idx); + plane->setAmVideoPath(idx); mPlanes.emplace(plane_idx, plane); count_video ++; } diff --git a/common/display/HwcVideoPlane.cpp b/common/display/HwcVideoPlane.cpp index a699839..ad6a761 100644 --- a/common/display/HwcVideoPlane.cpp +++ b/common/display/HwcVideoPlane.cpp @@ -20,6 +20,7 @@ HwcVideoPlane::HwcVideoPlane(int32_t drvFd, uint32_t id) snprintf(mName, 64, "HwcVideo-%d", id); mLastComposeFbs.clear(); mLastFence = std::make_shared<DrmFence>(-1); + memset(mAmVideosPath, 0, sizeof(mAmVideosPath)); } HwcVideoPlane::~HwcVideoPlane() { @@ -54,6 +55,66 @@ bool HwcVideoPlane::isFbSupport(std::shared_ptr<DrmFramebuffer> & fb) { return false; } +void HwcVideoPlane::setAmVideoPath(int id) { + if (id == 0) { + strncpy(mAmVideosPath, "/sys/class/video/disable_video", sizeof(mAmVideosPath)); + } else if (id == 1) { + strncpy(mAmVideosPath, "/sys/class/video/disable_videopip", sizeof(mAmVideosPath)); + } else { + // nothing + } +} + +int32_t HwcVideoPlane::getVideodisableStatus(int& status) { + /*fun is only called in updateVideodisableStatus(), mVideoDisableFd >= 0*/ + char buf[32] = {0}; + int ret; + int fd = -1; + + if (strlen(mAmVideosPath) == 0) + return -1; + + if ((fd = open(mAmVideosPath, O_RDWR, 0)) < 0) { + MESON_LOGE("open %s failed", mAmVideosPath); + return -1; + } + + if ((ret = read(fd, buf, sizeof(buf))) < 0) { + MESON_LOGE("get video disable failed, ret=%d error=%s", ret, strerror(errno)); + } else { + sscanf(buf, "%d", &status); + ret = 0; + } + + close(fd); + return ret; +} + +int32_t HwcVideoPlane::setVideodisableStatus(int status) { + /*fun is only called in updateVideodisableStatus(), mVideoDisableFd >= 0*/ + char buf[32] = {0}; + int ret; + int fd = -1; + + if (strlen(mAmVideosPath) == 0) + return -1; + + if ((fd = open(mAmVideosPath, O_RDWR, 0)) < 0) { + MESON_LOGE("open %s failed", mAmVideosPath); + return -1; + } + + snprintf(buf, 32, "%d", status); + if ((ret = write(fd, buf, strnlen(buf, sizeof(buf)))) < 0) { + MESON_LOGE("set video disable failed, ret=%d", ret); + } else { + ret = 0; + } + + close(fd); + return ret; +} + int32_t HwcVideoPlane::setComposePlane( DiComposerPair *difbs, int blankOp) { MESON_ASSERT(mDrvFd >= 0, "osd plane fd is not valiable!"); @@ -116,6 +177,22 @@ int32_t HwcVideoPlane::setComposePlane( mStatus = 1; } + /* update video plane disable status */ + if (fb) { + int blankStatus = 0; + getVideodisableStatus(blankStatus); + + /* the value of blankOp is UNBLANK */ + if (fb->mFbType == DRM_FB_VIDEO_OMX_V4L || + fb->mFbType == DRM_FB_VIDEO_OMX2_V4L2) { + if (blankStatus == 1) { + setVideodisableStatus(2); + } + } else { + MESON_LOGI("not support video fb type: %d", fb->mFbType); + } + } + if (ioctl(mDrvFd, VIDEO_COMPOSER_IOCTL_SET_FRAMES, &mVideoFramesInfo) != 0) { MESON_LOGE("video composer: ioctl error, %s(%d), mDrvFd = %d", strerror(errno), errno, mDrvFd); @@ -165,6 +242,22 @@ int32_t HwcVideoPlane::setPlane( mStatus = 0; } + /* update video plane disable status */ + if (fb) { + int blankStatus = 0; + getVideodisableStatus(blankStatus); + + /* the value of blankOp is UNBLANK */ + if (fb->mFbType == DRM_FB_VIDEO_OMX_V4L || + fb->mFbType == DRM_FB_VIDEO_OMX2_V4L2) { + if (blankStatus == 1) { + setVideodisableStatus(2); + } + } else { + MESON_LOGI("not support video fb type: %d", fb->mFbType); + } + } + /*update last frame release fence*/ if (mLastComposeFbs.size() > 0) { for (auto fbIt = mLastComposeFbs.begin(); fbIt != mLastComposeFbs.end(); ++fbIt) { diff --git a/common/display/HwcVideoPlane.h b/common/display/HwcVideoPlane.h index 5adfe87..e5dc19b 100644 --- a/common/display/HwcVideoPlane.h +++ b/common/display/HwcVideoPlane.h @@ -69,12 +69,17 @@ public: uint32_t getPossibleCrtcs(); bool isFbSupport(std::shared_ptr<DrmFramebuffer> & fb); + void setAmVideoPath(int32_t id); int32_t setPlane(std::shared_ptr<DrmFramebuffer> fb, uint32_t zorder, int blankOp); int32_t setComposePlane(DiComposerPair *difbs, int blankOp); void dump(String8 & dumpstr); protected: + int32_t getVideodisableStatus(int & status); + int32_t setVideodisableStatus(int status); + +protected: char mName[64]; u32 mFramesCount; video_frames_info_t mVideoFramesInfo; @@ -82,6 +87,9 @@ protected: std::vector<std::shared_ptr<DrmFramebuffer>> mLastComposeFbs; std::shared_ptr<DrmFence> mLastFence; + +private: + char mAmVideosPath[64]; }; #endif/*HWC_VIDEO_PLANE_H*/ |