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

Commit ff96aa8d authored by Michael Wright's avatar Michael Wright Committed by Android (Google) Code Review
Browse files

Merge "Moved brightness from Lights to SF."

parents 705fe94a 3e83c455
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -480,7 +480,7 @@ b826892686850a9cf2b60ca5845db7185c2196ea4dd765cd80cd163169678a78 android.hardwar
01c6398c90fc6be0640810e2c5d8a4863b457280132bb3f97dd5682e19632b62 android.hardware.graphics.bufferqueue@2.0::types
7a2d64095252f85781b2d521f4f11d04ce774544feececcec2088c568656e93c android.hardware.graphics.common@1.2::types
3dff04a36b86660b5807414587e530bb0c294ed56fdff06f8915ba0a9b73f974 android.hardware.graphics.composer@2.3::IComposer
daa44e83d7709bf1c9e0bd9a6b552feff496fd14574a9461ee93c21980fc5b15 android.hardware.graphics.composer@2.3::IComposerClient
54bc1dc874f8bc0781767786075dafd33a0796c1eea7d2317231b8929280e946 android.hardware.graphics.composer@2.3::IComposerClient
5c8bf8e1af9efe225a4661db8c08ff1b7e13fdc8ed49f35291bd0b6c9436b8f2 android.hardware.graphics.mapper@3.0::IMapper
7183d9d9acfa41a61a64bdfed548e98299265a7bb1821a3ed204173b5c2cfd4a android.hardware.graphics.mapper@3.0::types
c3f831a66d5815baf74f5b82fe79cf099542ddae4dfab3f388e1d41828e794fc android.hardware.health.storage@1.0::IGarbageCollectCallback
+39 −0
Original line number Diff line number Diff line
@@ -61,6 +61,11 @@ interface IComposerClient extends @2.2::IComposerClient {
         * PowerMode::DOZE_SUSPEND.
         */
        DOZE = 2,

        /**
         * Indicates that the display supports brightness operations.
         */
        BRIGHTNESS = 3,
    };

    /**
@@ -495,4 +500,38 @@ interface IComposerClient extends @2.2::IComposerClient {
                       float maxLuminance,
                       float maxAverageLuminance,
                       float minLuminance);

    /**
     * Gets whether brightness operations are supported on a display.
     *
     * @param display
     *      The display.
     *
     * @return error is NONE upon success. Otherwise,
     *      BAD_DISPLAY   when the display is invalid, or
     *      BAD_PARAMETER when the output parameter is invalid.
     * @return support
     *      Whether brightness operations are supported on the display.
     */
    getDisplayBrightnessSupport(Display display) generates (Error error, bool support);

    /**
     * Sets the brightness of a display.
     *
     * Ideally, the brightness change should take effect in the next frame post (so that it can be
     * aligned with color transforms).
     *
     * @param display
     *      The display whose brightness is set.
     * @param brightness
     *      A number between 0.0f (minimum brightness) and 1.0f (maximum brightness), or -1.0 to
     *      turn the backlight off.
     *
     * @return error is NONE upon success. Otherwise,
     *         BAD_DISPLAY   when the display is invalid, or
     *         UNSUPPORTED   when brightness operations are not supported, or
     *         BAD_PARAMETER when the brightness is invalid, or
     *         NO_RESOURCES  when the brightness cannot be applied.
     */
    setDisplayBrightness(Display display, float brightness) generates (Error error);
};
+13 −1
Original line number Diff line number Diff line
@@ -172,6 +172,18 @@ class ComposerClientImpl : public V2_2::hal::detail::ComposerClientImpl<Interfac
        return Void();
    }

    Return<void> getDisplayBrightnessSupport(
            Display display, IComposerClient::getDisplayBrightnessSupport_cb hidl_cb) override {
        bool support = false;
        Error error = mHal->getDisplayBrightnessSupport(display, &support);
        hidl_cb(error, support);
        return Void();
    }

    Return<Error> setDisplayBrightness(Display display, float brightness) override {
        return mHal->setDisplayBrightness(display, brightness);
    }

  protected:
    std::unique_ptr<V2_1::hal::ComposerCommandEngine> createCommandEngine() override {
        return std::make_unique<ComposerCommandEngine>(
+2 −0
Original line number Diff line number Diff line
@@ -119,6 +119,8 @@ class ComposerHal : public V2_2::hal::ComposerHal {
    virtual Error setLayerPerFrameMetadataBlobs(
        Display display, Layer layer,
        std::vector<IComposerClient::PerFrameMetadataBlob>& blobs) = 0;
    virtual Error getDisplayBrightnessSupport(Display display, bool* outSupport) = 0;
    virtual Error setDisplayBrightness(Display display, float brightness) = 0;
};

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

    Error getDisplayBrightnessSupport(Display display, bool* outSupport) {
        if (!mDispatch.getDisplayBrightnessSupport) {
            return Error::UNSUPPORTED;
        }
        bool support = false;
        int32_t error = mDispatch.getDisplayBrightnessSupport(mDevice, display, &support);
        *outSupport = support;
        return static_cast<Error>(error);
    }

    Error setDisplayBrightness(Display display, float brightness) {
        if (std::isnan(brightness) || brightness > 1.0f ||
            (brightness < 0.0f && brightness != -1.0f)) {
            return Error::BAD_PARAMETER;
        }
        if (!mDispatch.setDisplayBrightness) {
            return Error::UNSUPPORTED;
        }
        int32_t error = mDispatch.setDisplayBrightness(mDevice, display, brightness);
        return static_cast<Error>(error);
    }

  protected:
    bool initDispatch() override {
        if (!BaseType2_2::initDispatch()) {
@@ -265,6 +287,10 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
                                   &mDispatch.getDisplayCapabilities);
        this->initOptionalDispatch(HWC2_FUNCTION_SET_LAYER_PER_FRAME_METADATA_BLOBS,
                                   &mDispatch.setLayerPerFrameMetadataBlobs);
        this->initOptionalDispatch(HWC2_FUNCTION_GET_DISPLAY_BRIGHTNESS_SUPPORT,
                                   &mDispatch.getDisplayBrightnessSupport);
        this->initOptionalDispatch(HWC2_FUNCTION_SET_DISPLAY_BRIGHTNESS,
                                   &mDispatch.setDisplayBrightness);
        return true;
    }

@@ -277,6 +303,8 @@ class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
        HWC2_PFN_GET_DISPLAYED_CONTENT_SAMPLE getDisplayedContentSample;
        HWC2_PFN_GET_DISPLAY_CAPABILITIES getDisplayCapabilities;
        HWC2_PFN_SET_LAYER_PER_FRAME_METADATA_BLOBS setLayerPerFrameMetadataBlobs;
        HWC2_PFN_GET_DISPLAY_BRIGHTNESS_SUPPORT getDisplayBrightnessSupport;
        HWC2_PFN_SET_DISPLAY_BRIGHTNESS setDisplayBrightness;
    } mDispatch = {};

    using BaseType2_2 = V2_2::passthrough::detail::HwcHalImpl<Hal>;
Loading