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

Commit 43f8c36f authored by Huihong Luo's avatar Huihong Luo Committed by Android (Google) Code Review
Browse files

Merge "Add a new API to report display hotplug events" into main

parents 5e25fb2a 5569efbc
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
/**
 * 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 <name>-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 */,
}
+46 −0
Original line number Diff line number Diff line
/**
 * 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,
}
+4 −0
Original line number Diff line number Diff line
@@ -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);
}
+21 −0
Original line number Diff line number Diff line
@@ -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);
}
+15 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "GraphicsComposerCallback.h"
#include <log/log_main.h>
#include <utils/Timers.h>
#include <cinttypes>

#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<int32_t>(event));
            return ::ndk::ScopedAStatus::ok();
    }
}

}  // namespace aidl::android::hardware::graphics::composer3::vts
Loading