Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55d50d6b authored by Peiyong Lin's avatar Peiyong Lin
Browse files

[Graphics] Introduce per display capability.

Previously, the capability of skipping client color transform is global that
will apply on all displays. However, some hardwares are not capable of managing
it for all displays. This patch introduced a per display capability.

BUG: 69911676
Test: Build with mmma hardware/interfaces
Change-Id: I4a143ea89d06bd30ad2bf3f5307c8af9b17f0890
parent 868c0694
Loading
Loading
Loading
Loading
+49 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,42 @@ import @2.1::Error;


interface IComposerClient extends @2.2::IComposerClient {
interface IComposerClient extends @2.2::IComposerClient {


    // TODO: Move this enum to LLNDK after we decide where to put graphic types.
    /**
     * Required capabilities which are supported by the display. The
     * particular set of supported capabilities for a given display may be
     * retrieved using getDisplayCapabilities.
     */
    enum DisplayCapability : uint32_t {
        INVALID = 0,

        /**
         * Specifies that the display must a color transform even when
         * either the client or the device has chosen that all layers should
         * be composed by the client. This prevents the client from applying
         * the color transform during its composition step.
         * If getDisplayCapabilities is supported, the global capability
         * SKIP_CLIENT_COLOR_TRANSFORM is ignored.
         * If getDisplayCapabilities is not supported, and the global capability
         * SKIP_CLIENT_COLOR_TRANSFORM is returned by getCapabilities,
         * then all displays must be treated as having
         * SKIP_CLIENT_COLOR_TRANSFORM.
         */
        SKIP_CLIENT_COLOR_TRANSFORM = 1,

        /**
         * Specifies that the display supports PowerMode::DOZE and
         * PowerMode::DOZE_SUSPEND. DOZE_SUSPEND may not provide any benefit
         * over DOZE (see the definition of PowerMode for more information),
         * but if both DOZE and DOZE_SUSPEND are no different from
         * PowerMode::ON, the device must not claim support.
         * Must be returned by getDisplayCapabilities when getDozeSupport
         * indicates the display supports PowerMode::DOZE and
         * PowerMode::DOZE_SUSPEND.
         */
        DOZE = 2,
    };

    enum Command : @2.2::IComposerClient.Command {
    enum Command : @2.2::IComposerClient.Command {
        /**
        /**
         * SET_LAYER_COLOR_TRANSFORM has this pseudo prototype
         * SET_LAYER_COLOR_TRANSFORM has this pseudo prototype
@@ -350,4 +386,17 @@ interface IComposerClient extends @2.2::IComposerClient {
     */
     */
    setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent)
    setColorMode_2_3(Display display, ColorMode mode, RenderIntent intent)
          generates (Error error);
          generates (Error error);

    /**
     * Provides a list of supported capabilities (as described in the
     * definition of DisplayCapability above). This list must not change after
     * initialization.
     *
     * @return error is NONE upon success. Otherwise,
     *     BAD_DISPLAY when an invalid display handle was passed in.
     * @return capabilities is a list of supported capabilities.
     */
    getDisplayCapabilities(Display display)
              generates (Error error,
                         vec<DisplayCapability> capabilities);
};
};
+8 −0
Original line number Original line Diff line number Diff line
@@ -73,6 +73,14 @@ class ComposerClientImpl : public V2_2::hal::detail::ComposerClientImpl<Interfac
        return err;
        return err;
    }
    }


    Return<void> getDisplayCapabilities(
        Display display, IComposerClient::getDisplayCapabilities_cb hidl_cb) override {
        hidl_vec<IComposerClient::DisplayCapability> capabilities;
        Error error = mHal->getDisplayCapabilities(display, &capabilities);
        hidl_cb(error, capabilities);
        return Void();
    }

    static std::unique_ptr<ComposerClientImpl> create(Hal* hal) {
    static std::unique_ptr<ComposerClientImpl> create(Hal* hal) {
        auto client = std::make_unique<ComposerClientImpl>(hal);
        auto client = std::make_unique<ComposerClientImpl>(hal);
        return client->init() ? std::move(client) : nullptr;
        return client->init() ? std::move(client) : nullptr;
+2 −0
Original line number Original line Diff line number Diff line
@@ -84,6 +84,8 @@ class ComposerHal : public V2_2::hal::ComposerHal {
                                            hidl_vec<uint64_t>& sampleComponent1,
                                            hidl_vec<uint64_t>& sampleComponent1,
                                            hidl_vec<uint64_t>& sampleComponent2,
                                            hidl_vec<uint64_t>& sampleComponent2,
                                            hidl_vec<uint64_t>& sampleComponent3) = 0;
                                            hidl_vec<uint64_t>& sampleComponent3) = 0;
    virtual Error getDisplayCapabilities(
        Display display, hidl_vec<IComposerClient::DisplayCapability>* outCapabilities) = 0;
};
};


}  // namespace hal
}  // namespace hal
+26 −0
Original line number Original line Diff line number Diff line
@@ -163,6 +163,29 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
        return static_cast<Error>(errorRaw);
        return static_cast<Error>(errorRaw);
    }
    }


    Error getDisplayCapabilities(
        Display display, hidl_vec<IComposerClient::DisplayCapability>* outCapabilities) override {
        if (!mDispatch.getDisplayCapabilities) {
            return Error::UNSUPPORTED;
        }

        uint32_t count = 0;
        int32_t error = mDispatch.getDisplayCapabilities(mDevice, display, &count, nullptr);
        if (error != HWC2_ERROR_NONE) {
            return static_cast<Error>(error);
        }
        outCapabilities->resize(count);
        error = mDispatch.getDisplayCapabilities(
            mDevice, display, &count,
            reinterpret_cast<std::underlying_type<IComposerClient::DisplayCapability>::type*>(
                outCapabilities->data()));
        if (error != HWC2_ERROR_NONE) {
            *outCapabilities = hidl_vec<IComposerClient::DisplayCapability>();
            return static_cast<Error>(error);
        }
        return Error::NONE;
    }

   protected:
   protected:
    bool initDispatch() override {
    bool initDispatch() override {
        if (!BaseType2_2::initDispatch()) {
        if (!BaseType2_2::initDispatch()) {
@@ -179,6 +202,8 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
                                   &mDispatch.setDisplayedContentSamplingEnabled);
                                   &mDispatch.setDisplayedContentSamplingEnabled);
        this->initOptionalDispatch(HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE,
        this->initOptionalDispatch(HWC2_FUNCTION_GET_DISPLAYED_CONTENT_SAMPLE,
                                   &mDispatch.getDisplayedContentSample);
                                   &mDispatch.getDisplayedContentSample);
        this->initOptionalDispatch(HWC2_FUNCTION_GET_DISPLAY_CAPABILITIES,
                                   &mDispatch.getDisplayCapabilities);
        return true;
        return true;
    }
    }


@@ -189,6 +214,7 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
        HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES getDisplayedContentSamplingAttributes;
        HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES getDisplayedContentSamplingAttributes;
        HWC2_PFN_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED setDisplayedContentSamplingEnabled;
        HWC2_PFN_SET_DISPLAYED_CONTENT_SAMPLING_ENABLED setDisplayedContentSamplingEnabled;
        HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLE getDisplayedContentSample;
        HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLE getDisplayedContentSample;
        HWC2_PFN_GET_DISPLAY_CAPABILITIES getDisplayCapabilities;
    } mDispatch = {};
    } mDispatch = {};


    using BaseType2_2 = V2_2::passthrough::detail::HwcHalImpl<Hal>;
    using BaseType2_2 = V2_2::passthrough::detail::HwcHalImpl<Hal>;
+9 −0
Original line number Original line Diff line number Diff line
@@ -150,6 +150,15 @@ Error ComposerClient::getDisplayedContentSample(uint64_t display, uint64_t maxFr
    return error;
    return error;
}
}


std::vector<IComposerClient::DisplayCapability> ComposerClient::getDisplayCapabilities(
    Display display) {
    std::vector<IComposerClient::DisplayCapability> capabilities;
    mClient->getDisplayCapabilities(
        display, [&](const auto&, const auto& tmpCapabilities) { capabilities = tmpCapabilities; });

    return capabilities;
}

}  // namespace vts
}  // namespace vts
}  // namespace V2_3
}  // namespace V2_3
}  // namespace composer
}  // namespace composer
Loading