author | Ao Xu <ao.xu@amlogic.com> | 2019-11-27 07:55:12 (GMT) |
---|---|---|
committer | sky zhou <sky.zhou@amlogic.com> | 2020-05-21 11:07:17 (GMT) |
commit | ce9e0c15993b9693c104550265803ba012bb80bf (patch) | |
tree | 0012710574d305428d57b3761eb7418bd559e18a | |
parent | 3a7fd22a50f035d47fb6ef980edcb539b70fd73b (diff) | |
download | hwcomposer-ce9e0c15993b9693c104550265803ba012bb80bf.zip hwcomposer-ce9e0c15993b9693c104550265803ba012bb80bf.tar.gz hwcomposer-ce9e0c15993b9693c104550265803ba012bb80bf.tar.bz2 |
hwc: clean up video dma buffer in gralloc&hwc [1/1]
PD#SWPL-17318
Problem:
gralloc should clean up video dma buffer usage
Solution:
use the format to identify the dma situation
Verify:
u212
Change-Id: Ic93fe58658ef9a1041c41fda42f2c63331d904e3
Signed-off-by: Ao Xu <ao.xu@amlogic.com>
-rw-r--r-- | common/base/DrmTypes.cpp | 3 | ||||
-rw-r--r-- | common/display/HwcVideoPlane.cpp | 11 | ||||
-rw-r--r-- | composition/include/ICompositionStrategy.h | 12 | ||||
-rwxr-xr-x[-rw-r--r--] | composition/simplestrategy/MultiplanesWithDiComposition/MultiplanesWithDiComposition.cpp | 20 | ||||
-rw-r--r-- | hwc2/Hwc2Display.cpp | 10 | ||||
-rw-r--r-- | hwc2/Hwc2Layer.cpp | 16 |
6 files changed, 39 insertions, 33 deletions
diff --git a/common/base/DrmTypes.cpp b/common/base/DrmTypes.cpp index 8b70eb8..581591d 100644 --- a/common/base/DrmTypes.cpp +++ b/common/base/DrmTypes.cpp @@ -45,6 +45,9 @@ const char * drmFbTypeToString(drm_fb_type_t fbtype) { case DRM_FB_VIDEO_OMX2_V4L2: typeStr = "omx2-v4l2"; break; + case DRM_FB_VIDEO_DMABUF: + typeStr = "video-dma"; + break; default: typeStr = "unknown"; break; diff --git a/common/display/HwcVideoPlane.cpp b/common/display/HwcVideoPlane.cpp index a6eaf85..1788c84 100644 --- a/common/display/HwcVideoPlane.cpp +++ b/common/display/HwcVideoPlane.cpp @@ -58,8 +58,6 @@ int32_t HwcVideoPlane::setComposePlane( video_frame_info_t *vFrameInfo; int video_composer_enable; std::shared_ptr<DrmFramebuffer> fb; - native_handle_t * buf; - char *base = NULL; if (mDrvFd < 0) { MESON_LOGE("hwcvideo plane fd is not valiable!"); @@ -84,7 +82,7 @@ int32_t HwcVideoPlane::setComposePlane( vFrameInfo->fd = am_gralloc_get_omx_v4l_file(buf); vFrameInfo->type = 0; } else if (fb->mFbType == DRM_FB_VIDEO_DMABUF) { - vFrameInfo->fd = am_gralloc_get_video_dma_buf_fd(buf); + vFrameInfo->fd = am_gralloc_get_buffer_fd(buf); vFrameInfo->type = 1; } else if (fb->mFbType == DRM_FB_VIDEO_SIDEBAND || fb->mFbType == DRM_FB_VIDEO_SIDEBAND_SECOND) { @@ -132,13 +130,6 @@ int32_t HwcVideoPlane::setComposePlane( fb = difbs->composefbs[i]; if (fb) { - buf = fb->mBufferHandle; - if (0 == gralloc_lock_dma_buf(buf, (void **)&base)) { - set_v4lvideo_sync_info(base); - gralloc_unlock_dma_buf(buf); - } else { - MESON_LOGE("set_v4lvideo_sync_info failed."); - } /* dup a out fence fd for layer's release fence, we can't close this fd * now, cause display retire fence will also use this fd. will be closed * on SF side*/ diff --git a/composition/include/ICompositionStrategy.h b/composition/include/ICompositionStrategy.h index 1ace8d4..2a4a6c0 100644 --- a/composition/include/ICompositionStrategy.h +++ b/composition/include/ICompositionStrategy.h @@ -31,7 +31,7 @@ typedef enum { /*Macros for composition info dump.*/ #define DUMP_ADD_LINE_DIVIDE() \ - mDumpStr.append("+------+-------------+----------+--------+--------------+\n"); + mDumpStr.append("+------+-------------+---------------+--------+--------------+\n"); #define DUMP_APPEND_FB_INFO(fbZ, compType) \ mDumpStr.appendFormat("|%6d|%13s|", fbZ, compositionTypeToString(compType)); @@ -40,12 +40,12 @@ typedef enum { mDumpStr.appendFormat("|%6s|%13s|", " ", " "); #define DUMP_APPEND_PLANE_INFO(planeName, planeZ, blankType) \ - mDumpStr.appendFormat("%10s|%8d|%14s|\n", \ + mDumpStr.appendFormat("%15s|%8d|%14s|\n", \ planeName, planeZ, \ drmPlaneBlankToString((drm_plane_blank_t)blankType)); #define DUMP_APPEND_EMPTY_PLANE_INFO() \ - mDumpStr.appendFormat("%10s|%8s|%14s|\n", " ", " ", " "); + mDumpStr.appendFormat("%15s|%8s|%14s|\n", " ", " ", " "); #define HWC_PLANE_FAKE_ZORDER (1) @@ -78,10 +78,10 @@ public: virtual void dump(String8 & dumpstr) { dumpstr.appendFormat("Composition (%s):(0x%x)\n", getName(), mCompositionFlag); - dumpstr.append("---------------------------------------------------------\n"); - dumpstr.append("| FbZ | Comp Type | Plane | PlaneZ | BlankStat |\n"); + dumpstr.append("--------------------------------------------------------------\n"); + dumpstr.append("| FbZ | Comp Type | Plane | PlaneZ | BlankStat |\n"); dumpstr.append(mDumpStr); - dumpstr.append("---------------------------------------------------------\n"); + dumpstr.append("--------------------------------------------------------------\n"); } protected: diff --git a/composition/simplestrategy/MultiplanesWithDiComposition/MultiplanesWithDiComposition.cpp b/composition/simplestrategy/MultiplanesWithDiComposition/MultiplanesWithDiComposition.cpp index 9965c42..8bca031 100644..100755 --- a/composition/simplestrategy/MultiplanesWithDiComposition/MultiplanesWithDiComposition.cpp +++ b/composition/simplestrategy/MultiplanesWithDiComposition/MultiplanesWithDiComposition.cpp @@ -844,6 +844,7 @@ void MultiplanesWithDiComposition::handleDiComposition() if (mDIComposerFbs.size() > 0) { //mDiComposer->start(); std::shared_ptr<HwcVideoPlane> hwcVideoPlane0, hwcVideoPlane1; + std::shared_ptr<HwDisplayPlane> hwcPlane; std::vector<std::shared_ptr<DrmFramebuffer>> composefbs0, composefbs1, commitfbs; DiComposerPair diComposerPair; drm_rect_t dispFrame, dispFrame1; @@ -941,6 +942,7 @@ void MultiplanesWithDiComposition::handleDiComposition() it = mDIComposerFbs.erase(it); } + bool bDumpPlane = true; if (commitfbs.size() > 0) { fb = *commitfbs.begin(); if (composefbs1.size() <= 1) @@ -951,6 +953,14 @@ void MultiplanesWithDiComposition::handleDiComposition() MESON_LOGE("commit %d layers to video.composer0.\n", diComposerPair.num_composefbs); hwcVideoPlane0->setComposePlane(&diComposerPair, UNBLANK); + hwcPlane = hwcVideoPlane0; + for (auto it = commitfbs.begin(); it != commitfbs.end(); it++) { + if (bDumpPlane) { + dumpFbAndPlane(*it, hwcPlane, diComposerPair.zorder, UNBLANK); + bDumpPlane = false; + } else + dumpComposedFb(*it); + } } if (composefbs1.size() > 0 ) { @@ -967,6 +977,16 @@ void MultiplanesWithDiComposition::handleDiComposition() MESON_LOGE("commit %d layers to video.composer1.\n", diComposerPair.num_composefbs); hwcVideoPlane1->setComposePlane(&diComposerPair, UNBLANK); + + hwcPlane = hwcVideoPlane1; + bDumpPlane = true; + for (auto it = composefbs1.begin(); it != composefbs1.end(); it++) { + if (bDumpPlane) { + dumpFbAndPlane(*it, hwcPlane, diComposerPair.zorder, UNBLANK); + bDumpPlane = false; + } else + dumpComposedFb(*it); + } } } } diff --git a/hwc2/Hwc2Display.cpp b/hwc2/Hwc2Display.cpp index 1738e14..295bfe5 100644 --- a/hwc2/Hwc2Display.cpp +++ b/hwc2/Hwc2Display.cpp @@ -1010,14 +1010,14 @@ bool Hwc2Display::isPlaneHideForDebug(int id) { void Hwc2Display::dumpPresentLayers(String8 & dumpstr) { dumpstr.append("----------------------------------------------------------" - "-------------------------------\n"); - dumpstr.append("| id | z | type |blend| alpha |t|" + "-----------------------------------\n"); + dumpstr.append("| id | z | type |blend| alpha |t|" " AFBC | Source Crop | Display Frame |\n"); for (auto it = mPresentLayers.begin(); it != mPresentLayers.end(); it++) { Hwc2Layer *layer = (Hwc2Layer*)(it->get()); - dumpstr.append("+------+-----+--------+-----+--------+-+--------+" + dumpstr.append("+------+-----+------------+-----+--------+-+--------+" "-------------------+-------------------+\n"); - dumpstr.appendFormat("|%6llu|%5d|%8s|%5d|%8f|%1d|%8x|%4d %4d %4d %4d" + dumpstr.appendFormat("|%6llu|%5d|%12s|%5d|%8f|%1d|%8x|%4d %4d %4d %4d" "|%4d %4d %4d %4d|\n", layer->getUniqueId(), layer->mZorder, @@ -1037,7 +1037,7 @@ void Hwc2Display::dumpPresentLayers(String8 & dumpstr) { ); } dumpstr.append("----------------------------------------------------------" - "-------------------------------\n"); + "-----------------------------------\n"); } void Hwc2Display::dumpHwDisplayPlane(String8 &dumpstr) { diff --git a/hwc2/Hwc2Layer.cpp b/hwc2/Hwc2Layer.cpp index 80ec4e8..99da841 100644 --- a/hwc2/Hwc2Layer.cpp +++ b/hwc2/Hwc2Layer.cpp @@ -114,8 +114,6 @@ hwc2_error_t Hwc2Layer::setBuffer(buffer_handle_t buffer, int32_t acquireFence) mFbType = DRM_FB_VIDEO_OMX_V4L; } else if (am_gralloc_is_omx2_v4l2_buffer(buffer)) { mFbType = DRM_FB_VIDEO_OMX2_V4L2; - } else if (am_gralloc_is_video_dma_buffer(buffer)) { - mFbType = DRM_FB_VIDEO_DMABUF; } else if (am_gralloc_is_omx_metadata_buffer(buffer)) { int tunnel = 0; int ret = am_gralloc_get_omx_metadata_tunnel(buffer, &tunnel); @@ -131,20 +129,14 @@ hwc2_error_t Hwc2Layer::setBuffer(buffer_handle_t buffer, int32_t acquireFence) //For the buffer which size is 1x1, we treat it as a dim layer. handleDimLayer(buffer); } else if (am_gralloc_is_coherent_buffer(buffer)) { - mFbType = DRM_FB_SCANOUT; + if (am_gralloc_get_format(buffer) == HAL_PIXEL_FORMAT_YCrCb_420_SP) + mFbType = DRM_FB_VIDEO_DMABUF; + else + mFbType = DRM_FB_SCANOUT; } else { mFbType = DRM_FB_RENDER; } - char fbtype_str[PROPERTY_VALUE_MAX]; - int fbtype = 0; - if (property_get("vendor.v4l2.fbtype", fbtype_str, "12") >0) { - fbtype = atoi(fbtype_str); - if (mFbType == DRM_FB_VIDEO_OMX2_V4L2) { - mFbType = (drm_fb_type_t)fbtype; - } - } - mSecure = am_gralloc_is_secure_buffer(mBufferHandle); return HWC2_ERROR_NONE; } |