diff --git a/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/DisplayHotplugEvent.aidl b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/DisplayHotplugEvent.aidl new file mode 100644 index 0000000000..63dca0aab5 --- /dev/null +++ b/graphics/common/aidl/aidl_api/android.hardware.graphics.common/current/android/hardware/graphics/common/DisplayHotplugEvent.aidl @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2023, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/////////////////////////////////////////////////////////////////////////////// +// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. // +/////////////////////////////////////////////////////////////////////////////// + +// This file is a snapshot of an AIDL file. Do not edit it manually. There are +// two cases: +// 1). this is a frozen version file - do not edit this in any case. +// 2). this is a 'current' file. If you make a backwards compatible change to +// the interface (from the latest frozen version), the build system will +// prompt you to update this file with `m -update-api`. +// +// You must not make a backward incompatible change to any AIDL file built +// with the aidl_interface module type with versions property set. The module +// type is used to build AIDL files in a way that they can be used across +// independently updatable components of the system. If a device is shipped +// with such a backward incompatible change, it has a high risk of breaking +// later when a module using the interface is updated, e.g., Mainline modules. + +package android.hardware.graphics.common; +@Backing(type="int") @VintfStability +enum DisplayHotplugEvent { + CONNECTED = 0, + DISCONNECTED = 1, + ERROR_UNKNOWN = (-1) /* -1 */, + ERROR_INCOMPATIBLE_CABLE = (-2) /* -2 */, + ERROR_TOO_MANY_DISPLAYS = (-3) /* -3 */, +} diff --git a/graphics/common/aidl/android/hardware/graphics/common/DisplayHotplugEvent.aidl b/graphics/common/aidl/android/hardware/graphics/common/DisplayHotplugEvent.aidl new file mode 100644 index 0000000000..b35ada5bc9 --- /dev/null +++ b/graphics/common/aidl/android/hardware/graphics/common/DisplayHotplugEvent.aidl @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2023, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.graphics.common; + +/** + * Display hotplug events through onHotplugEvent callback. + */ +@VintfStability +@Backing(type="int") +enum DisplayHotplugEvent { + /** + * Display is successfully connected. + * Connected may be called more than once and the behavior of subsequent + * calls is that SurfaceFlinger queries the display properties again. + */ + CONNECTED = 0, + + /** Display is successfully disconnected */ + DISCONNECTED = 1, + + /** Display is plugged in, but an unknown error occurred */ + ERROR_UNKNOWN = -1, + + /** Display is plugged in, but incompatible cable error detected */ + ERROR_INCOMPATIBLE_CABLE = -2, + + /** + * Display is plugged in, but exceeds the max number of + * displays that can be simultaneously connected + */ + ERROR_TOO_MANY_DISPLAYS = -3, +} diff --git a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl index 2c08cbeffd..7e62f5eb87 100644 --- a/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl +++ b/graphics/composer/aidl/aidl_api/android.hardware.graphics.composer3/current/android/hardware/graphics/composer3/IComposerCallback.aidl @@ -34,6 +34,9 @@ package android.hardware.graphics.composer3; @VintfStability interface IComposerCallback { + /** + * @deprecated : Use instead onHotplugEvent + */ void onHotplug(long display, boolean connected); oneway void onRefresh(long display); oneway void onSeamlessPossible(long display); @@ -41,4 +44,5 @@ interface IComposerCallback { oneway void onVsyncPeriodTimingChanged(long display, in android.hardware.graphics.composer3.VsyncPeriodChangeTimeline updatedTimeline); oneway void onVsyncIdle(long display); oneway void onRefreshRateChangedDebug(in android.hardware.graphics.composer3.RefreshRateChangedDebugData data); + oneway void onHotplugEvent(long display, android.hardware.graphics.common.DisplayHotplugEvent event); } diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl index f4384b7a5a..5df140dfa9 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/IComposerCallback.aidl @@ -16,6 +16,7 @@ package android.hardware.graphics.composer3; +import android.hardware.graphics.common.DisplayHotplugEvent; import android.hardware.graphics.composer3.RefreshRateChangedDebugData; import android.hardware.graphics.composer3.VsyncPeriodChangeTimeline; @@ -38,6 +39,7 @@ interface IComposerCallback { * @param display is the display that triggers the hotplug event. * @param connected indicates whether the display is connected or * disconnected. + * @deprecated: Use instead onHotplugEvent */ void onHotplug(long display, boolean connected); @@ -118,4 +120,23 @@ interface IComposerCallback { * @param data is the data for the callback when refresh rate changed. */ oneway void onRefreshRateChangedDebug(in RefreshRateChangedDebugData data); + + /** + * Notifies the client that a DisplayHotplugEvent has occurred for the + * given display. Every active display (even a built-in physical display) + * must trigger at least one hotplug notification, even if it only occurs + * immediately after callback registration. + * + * Displays which have been connected are assumed to be in PowerMode.OFF, + * and the onVsync callback should not be called for a display until vsync + * has been enabled with setVsyncEnabled. + * + * The client may call back into the device while the callback is in + * progress. The device must serialize calls to this callback such that + * only one thread is calling it at a time. + * + * @param display is the display that triggers the hotplug event. + * @param event is the type of event that occurred. + */ + oneway void onHotplugEvent(long display, DisplayHotplugEvent event); } diff --git a/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp b/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp index 7b3a2b431f..544f69297a 100644 --- a/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp +++ b/graphics/composer/aidl/vts/GraphicsComposerCallback.cpp @@ -17,6 +17,7 @@ #include "GraphicsComposerCallback.h" #include #include +#include #pragma push_macro("LOG_TAG") #undef LOG_TAG @@ -193,4 +194,18 @@ int32_t GraphicsComposerCallback::getInvalidRefreshRateDebugEnabledCallbackCount return ::ndk::ScopedAStatus::ok(); } +::ndk::ScopedAStatus GraphicsComposerCallback::onHotplugEvent(int64_t in_display, + common::DisplayHotplugEvent event) { + switch (event) { + case common::DisplayHotplugEvent::CONNECTED: + return onHotplug(in_display, true); + case common::DisplayHotplugEvent::DISCONNECTED: + return onHotplug(in_display, false); + default: + ALOGE("%s(): display:%" PRIu64 ", event:%d", __func__, in_display, + static_cast(event)); + return ::ndk::ScopedAStatus::ok(); + } +} + } // namespace aidl::android::hardware::graphics::composer3::vts diff --git a/graphics/composer/aidl/vts/GraphicsComposerCallback.h b/graphics/composer/aidl/vts/GraphicsComposerCallback.h index 13e992a4e1..7a8d4a35b8 100644 --- a/graphics/composer/aidl/vts/GraphicsComposerCallback.h +++ b/graphics/composer/aidl/vts/GraphicsComposerCallback.h @@ -63,6 +63,8 @@ class GraphicsComposerCallback : public BnComposerCallback { virtual ::ndk::ScopedAStatus onVsyncIdle(int64_t in_display) override; virtual ::ndk::ScopedAStatus onRefreshRateChangedDebug( const RefreshRateChangedDebugData&) override; + virtual ::ndk::ScopedAStatus onHotplugEvent(int64_t in_display, + common::DisplayHotplugEvent) override; mutable std::mutex mMutex; // the set of all currently connected displays