diff options
author | Xin Li <delphij@google.com> | 2023-12-08 13:13:09 -0800 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2023-12-08 13:13:09 -0800 |
commit | 2d6b7a1839dc81b78eff333b33e9f2555ad19852 (patch) | |
tree | 2c5063fdf41b088e94d0806dc99edf3b39fe2b7b | |
parent | 04a7b99e0480c75f508078b2a8b205f160454999 (diff) | |
parent | 215854057dc3e1db98c0b1a4e6ff770f990ef92f (diff) | |
download | goldfish-opengl-2d6b7a1839dc81b78eff333b33e9f2555ad19852.tar.gz |
Merge Android 14 QPR1
Merged-In: Iaa27a373d06dcf57441c75e9523151c78a2de03e
Bug: 315507370
Change-Id: Icdc26267018272f3fe73288321807d4e1a0e3db6
-rw-r--r-- | system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp | 14 | ||||
-rw-r--r-- | system/hals/mapper3.cpp | 1 | ||||
-rw-r--r-- | system/hwc3/DisplayFinder.cpp | 69 | ||||
-rw-r--r-- | system/hwc3/DisplayFinder.h | 2 | ||||
-rw-r--r-- | system/hwc3/GuestFrameComposer.cpp | 95 | ||||
-rw-r--r-- | system/hwc3/GuestFrameComposer.h | 7 | ||||
-rw-r--r-- | system/hwc3/HostFrameComposer.cpp | 4 |
7 files changed, 108 insertions, 84 deletions
diff --git a/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp b/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp index 4a89613a..81366dd6 100644 --- a/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp +++ b/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp @@ -133,8 +133,8 @@ class C2GoldfishAvcDec::IntfImpl : public SimpleInterface<void>::BaseParams { DefineParam(mSize, C2_PARAMKEY_PICTURE_SIZE) .withDefault(new C2StreamPictureSizeInfo::output(0u, 320, 240)) .withFields({ - C2F(mSize, width).inRange(2, 4080, 2), - C2F(mSize, height).inRange(2, 4080, 2), + C2F(mSize, width).inRange(2, 4096, 2), + C2F(mSize, height).inRange(2, 4096, 2), }) .withSetter(SizeSetter) .build()); @@ -143,8 +143,8 @@ class C2GoldfishAvcDec::IntfImpl : public SimpleInterface<void>::BaseParams { .withDefault(new C2StreamMaxPictureSizeTuning::output( 0u, 320, 240)) .withFields({ - C2F(mSize, width).inRange(2, 4080, 2), - C2F(mSize, height).inRange(2, 4080, 2), + C2F(mSize, width).inRange(2, 4096, 2), + C2F(mSize, height).inRange(2, 4096, 2), }) .withSetter(MaxPictureSizeSetter, mSize) .build()); @@ -280,10 +280,12 @@ class C2GoldfishAvcDec::IntfImpl : public SimpleInterface<void>::BaseParams { C2R res = C2R::Ok(); if (!me.F(me.v.width).supportsAtAll(me.v.width)) { + ALOGW("w %d is not supported, using old one %d", me.v.width, oldMe.v.width); res = res.plus(C2SettingResultBuilder::BadValue(me.F(me.v.width))); me.set().width = oldMe.v.width; } if (!me.F(me.v.height).supportsAtAll(me.v.height)) { + ALOGW("h %d is not supported, using old one %d", me.v.height, oldMe.v.height); res = res.plus(C2SettingResultBuilder::BadValue(me.F(me.v.height))); me.set().height = oldMe.v.height; } @@ -297,8 +299,8 @@ class C2GoldfishAvcDec::IntfImpl : public SimpleInterface<void>::BaseParams { (void)mayBlock; // TODO: get max width/height from the size's field helpers vs. // hardcoding - me.set().width = c2_min(c2_max(me.v.width, size.v.width), 4080u); - me.set().height = c2_min(c2_max(me.v.height, size.v.height), 4080u); + me.set().width = c2_min(c2_max(me.v.width, size.v.width), 4096u); + me.set().height = c2_min(c2_max(me.v.height, size.v.height), 4096u); return C2R::Ok(); } diff --git a/system/hals/mapper3.cpp b/system/hals/mapper3.cpp index 46956d63..8be0b492 100644 --- a/system/hals/mapper3.cpp +++ b/system/hals/mapper3.cpp @@ -612,6 +612,7 @@ private: // **** impl **** case PixelFormat::RGBA_1010102: case PixelFormat::YV12: case PixelFormat::YCBCR_420_888: + case PixelFormat::YCBCR_P010: RETURN(true); case PixelFormat::IMPLEMENTATION_DEFINED: diff --git a/system/hwc3/DisplayFinder.cpp b/system/hwc3/DisplayFinder.cpp index beb6ba32..c19502b5 100644 --- a/system/hwc3/DisplayFinder.cpp +++ b/system/hwc3/DisplayFinder.cpp @@ -123,39 +123,54 @@ HWC3::Error findGoldfishPrimaryDisplay( return HWC3::Error::None; } +void parseExternalDisplaysFromProperties(std::vector<int>& outPropIntParts) { + + static constexpr const char* kExternalDisplayProp[] = { + "hwservicemanager.external.displays", + "ro.boot.qemu.external.displays", + }; + + for (auto propName: kExternalDisplayProp) { + const std::string propVal = ::android::base::GetProperty(propName, ""); + if (propVal.empty()) { + DEBUG_LOG("%s: prop name is: %s, prop value is: empty", __FUNCTION__, + propName); + continue; + } + DEBUG_LOG("%s: prop name is: %s, prop value is: %s", __FUNCTION__, + propName, propVal.c_str()); + + const std::vector<std::string> propStringParts = + ::android::base::Split(propVal, ","); + if (propStringParts.size() % 5 != 0) { + ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__, + propName, propVal.c_str()); + continue; + } + std::vector<int> propIntParts; + for (const std::string& propStringPart : propStringParts) { + int propIntPart; + if (!::android::base::ParseInt(propStringPart, &propIntPart)) { + ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__, + propName, propVal.c_str()); + break; + } + propIntParts.push_back(propIntPart); + } + if (propIntParts.empty() || propIntParts.size() % 5 != 0) { + continue; + } + outPropIntParts.insert(outPropIntParts.end(), propIntParts.begin(), propIntParts.end()); + } +} + HWC3::Error findGoldfishSecondaryDisplays( std::vector<DisplayMultiConfigs>* outDisplays) { DEBUG_LOG("%s", __FUNCTION__); - static constexpr const char kExternalDisplayProp[] = - "hwservicemanager.external.displays"; - - const auto propString = - ::android::base::GetProperty(kExternalDisplayProp, ""); - DEBUG_LOG("%s: prop value is: %s", __FUNCTION__, propString.c_str()); - - if (propString.empty()) { - return HWC3::Error::None; - } - - const std::vector<std::string> propStringParts = - ::android::base::Split(propString, ","); - if (propStringParts.size() % 5 != 0) { - ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__, - kExternalDisplayProp, propString.c_str()); - return HWC3::Error::BadParameter; - } std::vector<int> propIntParts; - for (const std::string& propStringPart : propStringParts) { - int propIntPart; - if (!::android::base::ParseInt(propStringPart, &propIntPart)) { - ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__, - kExternalDisplayProp, propString.c_str()); - return HWC3::Error::BadParameter; - } - propIntParts.push_back(propIntPart); - } + parseExternalDisplaysFromProperties(propIntParts); int64_t secondaryDisplayId = 1; while (!propIntParts.empty()) { diff --git a/system/hwc3/DisplayFinder.h b/system/hwc3/DisplayFinder.h index 963e4c17..f66eedfb 100644 --- a/system/hwc3/DisplayFinder.h +++ b/system/hwc3/DisplayFinder.h @@ -33,6 +33,8 @@ struct DisplayMultiConfigs { std::vector<DisplayConfig> configs; }; +void parseExternalDisplaysFromProperties(std::vector<int>& outPropIntParts); + HWC3::Error findDisplays(const DrmClient* drm, std::vector<DisplayMultiConfigs>* outDisplays); diff --git a/system/hwc3/GuestFrameComposer.cpp b/system/hwc3/GuestFrameComposer.cpp index 3b01a8df..b4eef6a4 100644 --- a/system/hwc3/GuestFrameComposer.cpp +++ b/system/hwc3/GuestFrameComposer.cpp @@ -29,6 +29,7 @@ #include <ui/GraphicBufferMapper.h> #include "Display.h" +#include "DisplayFinder.h" #include "Drm.h" #include "Layer.h" @@ -488,24 +489,46 @@ HWC3::Error GuestFrameComposer::onDisplayCreate(Display* display) { } DisplayInfo& displayInfo = mDisplayInfos[displayId]; - displayInfo.swapchain = DrmSwapchain::create(displayWidth, displayHeight, - ::android::GraphicBuffer::USAGE_HW_COMPOSER | - ::android::GraphicBuffer::USAGE_SW_READ_OFTEN | - ::android::GraphicBuffer::USAGE_SW_WRITE_OFTEN, - &mDrmClient); + + uint32_t bufferStride; + buffer_handle_t bufferHandle; + + auto status = ::android::GraphicBufferAllocator::get().allocate( + displayWidth, // + displayHeight, // + ::android::PIXEL_FORMAT_RGBA_8888, // + /*layerCount=*/1, // + ::android::GraphicBuffer::USAGE_HW_COMPOSER | + ::android::GraphicBuffer::USAGE_SW_READ_OFTEN | + ::android::GraphicBuffer::USAGE_SW_WRITE_OFTEN, // + &bufferHandle, // + &bufferStride, // + "RanchuHwc"); + if (status != ::android::OK) { + ALOGE("%s: failed to allocate composition buffer for display:%" PRIu64, + __FUNCTION__, displayId); + return HWC3::Error::NoResources; + } + + displayInfo.compositionResultBuffer = bufferHandle; + + auto [drmBufferCreateError, drmBuffer] = mDrmClient.create(bufferHandle); + if (drmBufferCreateError != HWC3::Error::None) { + ALOGE("%s: failed to create drm buffer for display:%" PRIu64, __FUNCTION__, + displayId); + return drmBufferCreateError; + } + displayInfo.compositionResultDrmBuffer = std::move(drmBuffer); if (displayId == 0) { - auto compositionResult = displayInfo.swapchain->getNextImage(); - auto [flushError, flushSyncFd] = - mDrmClient.flushToDisplay(displayId, compositionResult->getDrmBuffer(), -1); + auto [flushError, flushSyncFd] = mDrmClient.flushToDisplay( + displayId, displayInfo.compositionResultDrmBuffer, -1); if (flushError != HWC3::Error::None) { ALOGW( "%s: Initial display flush failed. HWComposer assuming that we are " "running in QEMU without a display and disabling presenting.", __FUNCTION__); mPresentDisabled = true; - } else { - compositionResult->markAsInUse(std::move(flushSyncFd)); } } @@ -526,7 +549,14 @@ HWC3::Error GuestFrameComposer::onDisplayDestroy(Display* display) { displayId); return HWC3::Error::BadDisplay; } - mDisplayInfos.erase(displayId); + + DisplayInfo& displayInfo = mDisplayInfos[displayId]; + + ::android::GraphicBufferAllocator::get().free( + displayInfo.compositionResultBuffer); + + mDisplayInfos.erase(it); + return HWC3::Error::None; } @@ -562,35 +592,8 @@ HWC3::Error GuestFrameComposer::getDisplayConfigsFromSystemProp( std::vector<GuestFrameComposer::DisplayConfig>* configs) { DEBUG_LOG("%s", __FUNCTION__); - static constexpr const char kExternalDisplayProp[] = - "hwservicemanager.external.displays"; - - const auto propString = - ::android::base::GetProperty(kExternalDisplayProp, ""); - DEBUG_LOG("%s: prop value is: %s", __FUNCTION__, propString.c_str()); - - if (propString.empty()) { - return HWC3::Error::None; - } - - const std::vector<std::string> propStringParts = - ::android::base::Split(propString, ","); - if (propStringParts.size() % 5 != 0) { - ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__, - kExternalDisplayProp, propString.c_str()); - return HWC3::Error::BadParameter; - } - std::vector<int> propIntParts; - for (const std::string& propStringPart : propStringParts) { - int propIntPart; - if (!::android::base::ParseInt(propStringPart, &propIntPart)) { - ALOGE("%s: Invalid syntax for system prop %s which is %s", __FUNCTION__, - kExternalDisplayProp, propString.c_str()); - return HWC3::Error::BadParameter; - } - propIntParts.push_back(propIntPart); - } + parseExternalDisplaysFromProperties(propIntParts); while (!propIntParts.empty()) { DisplayConfig display_config = { @@ -724,23 +727,21 @@ HWC3::Error GuestFrameComposer::presentDisplay( } DisplayInfo& displayInfo = it->second; - auto compositionResult = displayInfo.swapchain->getNextImage(); - compositionResult->wait(); - if (compositionResult->getBuffer() == nullptr) { + if (displayInfo.compositionResultBuffer == nullptr) { ALOGE("%s: display:%" PRIu64 " missing composition result buffer", __FUNCTION__, displayId); return HWC3::Error::NoResources; } - if (compositionResult->getDrmBuffer() == nullptr) { + if (displayInfo.compositionResultDrmBuffer == nullptr) { ALOGE("%s: display:%" PRIu64 " missing composition result drm buffer", __FUNCTION__, displayId); return HWC3::Error::NoResources; } std::optional<GrallocBuffer> compositionResultBufferOpt = - mGralloc.Import(compositionResult->getBuffer()); + mGralloc.Import(displayInfo.compositionResultBuffer); if (!compositionResultBufferOpt) { ALOGE("%s: display:%" PRIu64 " failed to import buffer", __FUNCTION__, displayId); @@ -885,16 +886,14 @@ HWC3::Error GuestFrameComposer::presentDisplay( DEBUG_LOG("%s display:%" PRIu64 " flushing drm buffer", __FUNCTION__, displayId); - auto [error, fence] = mDrmClient.flushToDisplay(displayId, compositionResult->getDrmBuffer(), -1); + auto [error, fence] = mDrmClient.flushToDisplay( + displayId, displayInfo.compositionResultDrmBuffer, -1); if (error != HWC3::Error::None) { ALOGE("%s: display:%" PRIu64 " failed to flush drm buffer" PRIu64, __FUNCTION__, displayId); } *outDisplayFence = std::move(fence); - compositionResult->markAsInUse(outDisplayFence->ok() - ? ::android::base::unique_fd(dup(*outDisplayFence)) - : ::android::base::unique_fd()); return error; } diff --git a/system/hwc3/GuestFrameComposer.h b/system/hwc3/GuestFrameComposer.h index 21197355..2df2f32b 100644 --- a/system/hwc3/GuestFrameComposer.h +++ b/system/hwc3/GuestFrameComposer.h @@ -20,7 +20,6 @@ #include "Common.h" #include "Display.h" #include "DrmClient.h" -#include "DrmSwapchain.h" #include "FrameComposer.h" #include "Gralloc.h" #include "Layer.h" @@ -93,8 +92,10 @@ class GuestFrameComposer : public FrameComposer { std::uint32_t dstBufferBytesPerPixel); struct DisplayInfo { - // Additional per display buffers for the composition result. - std::unique_ptr<DrmSwapchain> swapchain = {}; + // Additional per display buffer for the composition result. + buffer_handle_t compositionResultBuffer = nullptr; + + std::shared_ptr<DrmBuffer> compositionResultDrmBuffer; }; std::unordered_map<int64_t, DisplayInfo> mDisplayInfos; diff --git a/system/hwc3/HostFrameComposer.cpp b/system/hwc3/HostFrameComposer.cpp index dd5b3084..6264052e 100644 --- a/system/hwc3/HostFrameComposer.cpp +++ b/system/hwc3/HostFrameComposer.cpp @@ -561,6 +561,8 @@ HWC3::Error HostFrameComposer::presentDisplay( *outDisplayFence = std::move(flushCompleteFence); } else { + rcEnc->rcSetDisplayColorBuffer(rcEnc, displayInfo.hostDisplayId, + hostCon->grallocHelper()->getHostHandle(displayClientTarget.getBuffer())); post(hostCon, rcEnc, displayClientTarget.getBuffer()); *outDisplayFence = std::move(fence); } @@ -733,6 +735,8 @@ HWC3::Error HostFrameComposer::presentDisplay( displayId, compositionResult->getDrmBuffer(), displayClientTargetFence); *outDisplayFence = std::move(flushFence); } else { + rcEnc->rcSetDisplayColorBuffer(rcEnc, displayInfo.hostDisplayId, + hostCon->grallocHelper()->getHostHandle(displayClientTarget.getBuffer())); post(hostCon, rcEnc, displayClientTarget.getBuffer()); *outDisplayFence = std::move(displayClientTargetFence); } |