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

Commit a1df7c3d authored by Ady Abraham's avatar Ady Abraham
Browse files

composer: few changes for refresh rate switching

 - getDisplayConfigs is required to remain backward compatible with
   composer@2.3 and older versions. To keep it that way a new config
   attribute was added to group similar configs.
 - getSupportedDisplayVsyncPeriods was removed as the vsync period
   can be obtained by getDisplayAttribute for each individual config.
 - renamed setActiveConfigAndVsyncPeriod -> setActiveConfigWithConstraints
   to better describe what this function does.
 - added VsyncPeriodChangeTimeline and onVsyncPeriodTimingChanged

With these changes composer is expected to return all possible
configurations when getDisplayConfigs (similar to older composer versions).
The client knows whether a seamless vsync period is possible or not by
the config groups.

Test: rev up composer to 2.4 and test refresh rate switching
Bug: 141329414
Change-Id: I1b4525f7e00b62cdaf260274abe4a6a5962ed1ab
parent f2b00218
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -32,4 +32,14 @@ interface IComposerCallback extends @2.1::IComposerCallback {
     *        is expected to be called vsyncPeriodNanos nanoseconds after this call.
     */
    oneway onVsync_2_4(Display display, int64_t timestamp, VsyncPeriodNanos vsyncPeriodNanos);

    /**
     * Notifies the client that the previously reported timing for vsync period change has been
     * updated. This may occur if the composer missed the deadline for changing the vsync period
     * or the client submitted a refresh frame too late.
     *
     * @param display is the display which vsync period change is in progress
     * @param updatedTimeline is the new timeline for the vsync period change.
     */
    oneway onVsyncPeriodTimingChanged(Display display, VsyncPeriodChangeTimeline updatedTimeline);
};
+35 −19
Original line number Diff line number Diff line
@@ -20,9 +20,22 @@ import IComposerCallback;
import @2.1::Config;
import @2.1::Display;
import @2.1::Error;
import @2.1::IComposerClient;
import @2.3::IComposerClient;

interface IComposerClient extends @2.3::IComposerClient {
    /**
     * Display attributes queryable through getDisplayAttribute_2_4.
     */
    enum Attribute : @2.1::IComposerClient.Attribute {
        /**
         * The configuration group ID (as int32_t) this config is associated to.
         * Switching between configurations within the same group may be done seamlessly
         * in some conditions via setActiveConfigWithConstraints.
         */
        CONFIG_GROUP = 7,
    };

    /**
     * Required capabilities which are supported by the display. The
     * particular set of supported capabilities for a given display may be
@@ -60,6 +73,7 @@ interface IComposerClient extends @2.3::IComposerClient {
         * (i.e., the vsync period must not change before this time).
         */
        int64_t desiredTimeNanos;

        /**
         * If true, requires that the vsync period change must happen seamlessly without
         * a noticeable visual artifact.
@@ -74,7 +88,6 @@ interface IComposerClient extends @2.3::IComposerClient {
     *
     * @param callback is the IComposerCallback object.
     */
    @entry
    registerCallback_2_4(IComposerCallback callback);

    /**
@@ -99,25 +112,29 @@ interface IComposerClient extends @2.3::IComposerClient {
    getDisplayConnectionType(Display display) generates (Error error, DisplayConnectionType type);

    /**
     * Provides a list of the vsync periods supported by the display in the given configuration
     *
     * @param display is the display for which the vsync periods are queried.
     * @param config is the display configuration for which the vsync periods are queried.
     * Returns a display attribute value for a particular display
     * configuration.
     *
     * @param display is the display to query.
     * @param config is the display configuration for which to return
     *        attribute values.
     * @return error is NONE upon success. Otherwise,
     *         BAD_DISPLAY when an invalid display handle was passed in.
     *     BAD_CONFIG when an invalid config handle was passed in.
     * @return supportedVsyncPeriods is a list of supported vsync periods.
     *         BAD_CONFIG when config does not name a valid configuration for
     *                    this display.
     *         BAD_PARAMETER when attribute is unrecognized.
     *         UNSUPPORTED when attribute cannot be queried for the config.
     * @return value is the value of the attribute.
     */
    getSupportedDisplayVsyncPeriods(Display display, Config config)
        generates (Error error, vec<VsyncPeriodNanos> supportedVsyncPeriods);
    getDisplayAttribute_2_4(Display display, Config config, Attribute attribute)
        generates (Error error, int32_t value);

    /**
     * Retrieves which vsync period the display is currently using.
     *
     * If no display configuration is currently active, this function must
     * return BAD_CONFIG. If the vsync period is about to change due to a
     * setActiveConfigAndVsyncPeriod call, this function must return the current vsync period
     * setActiveConfigWithConstraints call, this function must return the current vsync period
     * until the change takes place.
     *
     * @param display is the display for which the vsync period is queried.
@@ -131,7 +148,8 @@ interface IComposerClient extends @2.3::IComposerClient {

    /**
     * Sets the active configuration and the refresh rate for this display.
     * If the config is the same as the current config, only the vsync period shall change.
     * If the new config shares the same config group as the current config,
     * only the vsync period shall change.
     * Upon returning, the given display configuration, except vsync period, must be active and
     * remain so until either this function is called again or the display is disconnected.
     * When the display starts to refresh at the new vsync period, onVsync_2_4 callback must be
@@ -139,21 +157,19 @@ interface IComposerClient extends @2.3::IComposerClient {
     *
     * @param display is the display for which the active config is set.
     * @param config is the new display configuration.
     * @param vsyncPeriodNanos is the new display vsync period.
     * @param vsyncPeriodChangeConstraints are the constraints required for changing vsync period.
     *
     * @return error is NONE upon success. Otherwise,
     *         BAD_DISPLAY when an invalid display handle was passed in.
     *         BAD_CONFIG when the configuration handle passed in is not valid
     *                    for this display.
     *         BAD_VSYNC_PERIOD when an invalid vsync period is passed in.
     *         SEAMLESS_NOT_ALLOWED when seamlessRequired was true but config provided doesn't
     *                              share the same config group as the current config.
     *         SEAMLESS_NOT_POSSIBLE when seamlessRequired was true but the display cannot achieve
     *                               the vsync period change without a noticeable visual artifact.
     * @return newVsyncAppliedTime is the time in CLOCK_MONOTONIC when the new display will start to
     *                             refresh at the new vsync period.
     * @return timeline is the timeline for the vsync period change.
     */
    setActiveConfigAndVsyncPeriod(Display display, Config config,
        VsyncPeriodNanos vsyncPeriodNanos,
    setActiveConfigWithConstraints(Display display, Config config,
        VsyncPeriodChangeConstraints vsyncPeriodChangeConstraints)
        generates (Error error, int64_t newVsyncAppliedTime);
        generates (Error error, VsyncPeriodChangeTimeline timeline);
};
+25 −2
Original line number Diff line number Diff line
@@ -20,13 +20,36 @@ import @2.1::Error;

enum Error : @2.1::Error {
    /**
     * Invalid vsync period
     * Seamless cannot be required for configurations that don't share a config group
     */
    BAD_VSYNC_PERIOD = 9,
    SEAMLESS_NOT_ALLOWED = 9,
    /**
     * Seamless requirements cannot be met
     */
    SEAMLESS_NOT_POSSIBLE = 10,
};

/**
 * Timing for a vsync period change.
 */
struct VsyncPeriodChangeTimeline {
    /**
     * The time in CLOCK_MONOTONIC when the new display will start to refresh at
     * the new vsync period.
     */
    int64_t newVsyncAppliedTimeNanos;

    /**
     * Set to true if the client is required to send a frame to be displayed before
     * the change can take place.
     */
    bool refreshRequired;

    /**
     * The time in CLOCK_MONOTONIC when the client is expected to send the new frame.
     * Should be ignored if refreshRequired is false.
     */
    int64_t refreshTimeNanos;
};

typedef uint32_t VsyncPeriodNanos;
+20 −15
Original line number Diff line number Diff line
@@ -76,6 +76,13 @@ class ComposerClientImpl : public V2_3::hal::detail::ComposerClientImpl<Interfac
            ALOGE_IF(!ret.isOk(), "failed to send onVsync_2_4: %s", ret.description().c_str());
        }

        void onVsyncPeriodTimingChanged(Display display,
                                        const VsyncPeriodChangeTimeline& updatedTimeline) override {
            auto ret = mCallback->onVsyncPeriodTimingChanged(display, updatedTimeline);
            ALOGE_IF(!ret.isOk(), "failed to send onVsyncPeriodTimingChanged: %s",
                     ret.description().c_str());
        }

      protected:
        const sp<IComposerCallback> mCallback;
        V2_1::hal::ComposerResources* const mResources;
@@ -104,13 +111,12 @@ class ComposerClientImpl : public V2_3::hal::detail::ComposerClientImpl<Interfac
        return Void();
    }

    Return<void> getSupportedDisplayVsyncPeriods(
            Display display, Config config,
            IComposerClient::getSupportedDisplayVsyncPeriods_cb hidl_cb) override {
        std::vector<VsyncPeriodNanos> supportedVsyncPeriods;
        Error error =
                mHal->getSupportedDisplayVsyncPeriods(display, config, &supportedVsyncPeriods);
        hidl_cb(error, supportedVsyncPeriods);
    Return<void> getDisplayAttribute_2_4(
            Display display, Config config, IComposerClient::Attribute attribute,
            IComposerClient::getDisplayAttribute_2_4_cb hidl_cb) override {
        int32_t value = 0;
        Error error = mHal->getDisplayAttribute_2_4(display, config, attribute, &value);
        hidl_cb(error, value);
        return Void();
    }

@@ -122,15 +128,14 @@ class ComposerClientImpl : public V2_3::hal::detail::ComposerClientImpl<Interfac
        return Void();
    }

    Return<void> setActiveConfigAndVsyncPeriod(
            Display display, Config config, VsyncPeriodNanos vsyncPeriodNanos,
    Return<void> setActiveConfigWithConstraints(
            Display display, Config config,
            const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints,
            IComposerClient::setActiveConfigAndVsyncPeriod_cb hidl_cb) override {
        int64_t newVsyncAppliedTime = 0;
        Error error = mHal->setActiveConfigAndVsyncPeriod(display, config, vsyncPeriodNanos,
                                                          vsyncPeriodChangeConstraints,
                                                          &newVsyncAppliedTime);
        hidl_cb(error, newVsyncAppliedTime);
            IComposerClient::setActiveConfigWithConstraints_cb hidl_cb) override {
        VsyncPeriodChangeTimeline timeline = {};
        Error error = mHal->setActiveConfigWithConstraints(display, config,
                                                           vsyncPeriodChangeConstraints, &timeline);
        hidl_cb(error, timeline);
        return Void();
    }

+8 −5
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ class ComposerHal : public V2_3::hal::ComposerHal {
        virtual void onVsync(Display display, int64_t timestamp) = 0;
        virtual void onVsync_2_4(Display display, int64_t timestamp,
                                 VsyncPeriodNanos vsyncPeriodNanos) = 0;
        virtual void onVsyncPeriodTimingChanged(Display display,
                                                const VsyncPeriodChangeTimeline& timeline) = 0;
    };

    virtual void registerEventCallback_2_4(EventCallback_2_4* callback) = 0;
@@ -57,13 +59,14 @@ class ComposerHal : public V2_3::hal::ComposerHal {
            Display display, std::vector<IComposerClient::DisplayCapability>* outCapabilities) = 0;
    virtual Error getDisplayConnectionType(Display display,
                                           IComposerClient::DisplayConnectionType* outType) = 0;
    virtual Error getSupportedDisplayVsyncPeriods(
            Display display, Config config, std::vector<VsyncPeriodNanos>* outVsyncPeriod) = 0;
    virtual Error getDisplayAttribute_2_4(Display display, Config config,
                                          IComposerClient::Attribute attribute,
                                          int32_t* outValue) = 0;
    virtual Error getDisplayVsyncPeriod(Display display, VsyncPeriodNanos* outVsyncPeriod) = 0;
    virtual Error setActiveConfigAndVsyncPeriod(
            Display display, Config config, VsyncPeriodNanos vsyncPeriodNanos,
    virtual Error setActiveConfigWithConstraints(
            Display display, Config config,
            const IComposerClient::VsyncPeriodChangeConstraints& vsyncPeriodChangeConstraints,
            int64_t* outNewVsyncAppliedTime) = 0;
            VsyncPeriodChangeTimeline* timeline) = 0;
};

}  // namespace hal
Loading