/*
 * Copyright (C) 2016 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.composer@2.1;

interface IComposerCallback {
    enum Connection : int32_t {
        INVALID = 0,

        /** The display has been connected */
        CONNECTED = 1,
        /** The display has been disconnected */
        DISCONNECTED = 2,
    };

    /**
     * Notifies the client that the given display has either been connected or
     * disconnected. 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 connected indicates whether the display is connected or
     *        disconnected.
     */
    @callflow(next="*")
    onHotplug(Display display, Connection connected);

    /**
     * Notifies the client to trigger a screen refresh. This forces all layer
     * state for this display to be resent, and the display to be validated
     * and presented, even if there have been no changes.

     * This refresh will occur some time after the callback is initiated, but
     * not necessarily before it returns.  It is safe to trigger this callback
     * from other functions which call into the device.
     *
     * @param display is the display to refresh.
     */
    @callflow(next="*")
    oneway onRefresh(Display display);

    /**
     * Notifies the client that a vsync event has occurred. This callback must
     * only be triggered when vsync is enabled for this display (through
     * setVsyncEnabled).
     *
     * @param display is the display which has received a vsync event
     * @param timestamp is the CLOCK_MONOTONIC time at which the vsync event
     *        occurred, in nanoseconds.
     */
    @callflow(next="*")
    oneway onVsync(Display display, int64_t timestamp);
};
