blob: aa74bfd3f81857a70b59d7919a4db4a32d2f9793 [file] [log] [blame]
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Mathias Agopiand0566bc2011-11-17 17:49:17 -080017#include <gui/IDisplayEventConnection.h>
Mathias Agopian801ea092017-03-06 15:05:04 -080018
19#include <private/gui/BitTube.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080020
21namespace android {
Mathias Agopiand0566bc2011-11-17 17:49:17 -080022
Dan Stoza2d191c32017-04-03 13:27:12 -070023namespace { // Anonymous
24
25enum class Tag : uint32_t {
Dan Stoza6b698e42017-04-03 13:09:08 -070026 STEAL_RECEIVE_CHANNEL = IBinder::FIRST_CALL_TRANSACTION,
27 SET_VSYNC_RATE,
Dan Stoza2d191c32017-04-03 13:27:12 -070028 REQUEST_NEXT_VSYNC,
Alec Mouri271de042020-04-27 22:38:19 -070029 REQUEST_LATEST_CONFIG,
30 LAST = REQUEST_LATEST_CONFIG,
Dan Stoza6b698e42017-04-03 13:09:08 -070031};
Mathias Agopiand0566bc2011-11-17 17:49:17 -080032
Dan Stoza2d191c32017-04-03 13:27:12 -070033} // Anonymous namespace
34
35class BpDisplayEventConnection : public SafeBpInterface<IDisplayEventConnection> {
Mathias Agopiand0566bc2011-11-17 17:49:17 -080036public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070037 explicit BpDisplayEventConnection(const sp<IBinder>& impl)
Dan Stoza2d191c32017-04-03 13:27:12 -070038 : SafeBpInterface<IDisplayEventConnection>(impl, "BpDisplayEventConnection") {}
Mathias Agopiand0566bc2011-11-17 17:49:17 -080039
Dan Stozae1c599b2017-03-30 16:37:19 -070040 ~BpDisplayEventConnection() override;
Dan Stozad723bd72014-11-18 10:24:03 -080041
Dan Stoza6b698e42017-04-03 13:09:08 -070042 status_t stealReceiveChannel(gui::BitTube* outChannel) override {
Dan Stoza2d191c32017-04-03 13:27:12 -070043 return callRemote<decltype(
44 &IDisplayEventConnection::stealReceiveChannel)>(Tag::STEAL_RECEIVE_CHANNEL,
45 outChannel);
Mathias Agopiand0566bc2011-11-17 17:49:17 -080046 }
Mathias Agopian478ae5e2011-12-06 17:22:19 -080047
Dan Stozae1c599b2017-03-30 16:37:19 -070048 status_t setVsyncRate(uint32_t count) override {
Dan Stoza2d191c32017-04-03 13:27:12 -070049 return callRemote<decltype(&IDisplayEventConnection::setVsyncRate)>(Tag::SET_VSYNC_RATE,
50 count);
Mathias Agopian478ae5e2011-12-06 17:22:19 -080051 }
52
Dan Stozae1c599b2017-03-30 16:37:19 -070053 void requestNextVsync() override {
Dan Stoza2d191c32017-04-03 13:27:12 -070054 callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>(
55 Tag::REQUEST_NEXT_VSYNC);
Mathias Agopian478ae5e2011-12-06 17:22:19 -080056 }
Alec Mouri60aee1c2019-10-28 16:18:59 -070057
Alec Mouri271de042020-04-27 22:38:19 -070058 void requestLatestConfig() override {
59 callRemoteAsync<decltype(&IDisplayEventConnection::requestLatestConfig)>(
60 Tag::REQUEST_LATEST_CONFIG);
Alec Mouri60aee1c2019-10-28 16:18:59 -070061 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -080062};
63
Dan Stozaa5f61dd2017-03-30 16:09:13 -070064// Out-of-line virtual method definition to trigger vtable emission in this translation unit (see
65// clang warning -Wweak-vtables)
Dan Stoza2d191c32017-04-03 13:27:12 -070066BpDisplayEventConnection::~BpDisplayEventConnection() = default;
Dan Stozad723bd72014-11-18 10:24:03 -080067
Mathias Agopiand0566bc2011-11-17 17:49:17 -080068IMPLEMENT_META_INTERFACE(DisplayEventConnection, "android.gui.DisplayEventConnection");
69
Dan Stozaa5f61dd2017-03-30 16:09:13 -070070status_t BnDisplayEventConnection::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
71 uint32_t flags) {
Dan Stoza2d191c32017-04-03 13:27:12 -070072 if (code < IBinder::FIRST_CALL_TRANSACTION || code > static_cast<uint32_t>(Tag::LAST)) {
73 return BBinder::onTransact(code, data, reply, flags);
Mathias Agopiand0566bc2011-11-17 17:49:17 -080074 }
Dan Stoza2d191c32017-04-03 13:27:12 -070075 auto tag = static_cast<Tag>(code);
76 switch (tag) {
77 case Tag::STEAL_RECEIVE_CHANNEL:
78 return callLocal(data, reply, &IDisplayEventConnection::stealReceiveChannel);
79 case Tag::SET_VSYNC_RATE:
80 return callLocal(data, reply, &IDisplayEventConnection::setVsyncRate);
81 case Tag::REQUEST_NEXT_VSYNC:
82 return callLocalAsync(data, reply, &IDisplayEventConnection::requestNextVsync);
Alec Mouri271de042020-04-27 22:38:19 -070083 case Tag::REQUEST_LATEST_CONFIG:
84 return callLocalAsync(data, reply, &IDisplayEventConnection::requestLatestConfig);
Dan Stoza2d191c32017-04-03 13:27:12 -070085 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -080086}
87
Dan Stozaa5f61dd2017-03-30 16:09:13 -070088} // namespace android