Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 1 | /* |
| 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 Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 17 | #include <gui/IDisplayEventConnection.h> |
Mathias Agopian | 801ea09 | 2017-03-06 15:05:04 -0800 | [diff] [blame] | 18 | |
| 19 | #include <private/gui/BitTube.h> |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 20 | |
| 21 | namespace android { |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 22 | |
Dan Stoza | 2d191c3 | 2017-04-03 13:27:12 -0700 | [diff] [blame] | 23 | namespace { // Anonymous |
| 24 | |
| 25 | enum class Tag : uint32_t { |
Dan Stoza | 6b698e4 | 2017-04-03 13:09:08 -0700 | [diff] [blame] | 26 | STEAL_RECEIVE_CHANNEL = IBinder::FIRST_CALL_TRANSACTION, |
| 27 | SET_VSYNC_RATE, |
Dan Stoza | 2d191c3 | 2017-04-03 13:27:12 -0700 | [diff] [blame] | 28 | REQUEST_NEXT_VSYNC, |
Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame^] | 29 | TOGGLE_CONFIG_EVENTS, |
| 30 | LAST = TOGGLE_CONFIG_EVENTS, |
Dan Stoza | 6b698e4 | 2017-04-03 13:09:08 -0700 | [diff] [blame] | 31 | }; |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 32 | |
Dan Stoza | 2d191c3 | 2017-04-03 13:27:12 -0700 | [diff] [blame] | 33 | } // Anonymous namespace |
| 34 | |
| 35 | class BpDisplayEventConnection : public SafeBpInterface<IDisplayEventConnection> { |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 36 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 37 | explicit BpDisplayEventConnection(const sp<IBinder>& impl) |
Dan Stoza | 2d191c3 | 2017-04-03 13:27:12 -0700 | [diff] [blame] | 38 | : SafeBpInterface<IDisplayEventConnection>(impl, "BpDisplayEventConnection") {} |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 39 | |
Dan Stoza | e1c599b | 2017-03-30 16:37:19 -0700 | [diff] [blame] | 40 | ~BpDisplayEventConnection() override; |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 41 | |
Dan Stoza | 6b698e4 | 2017-04-03 13:09:08 -0700 | [diff] [blame] | 42 | status_t stealReceiveChannel(gui::BitTube* outChannel) override { |
Dan Stoza | 2d191c3 | 2017-04-03 13:27:12 -0700 | [diff] [blame] | 43 | return callRemote<decltype( |
| 44 | &IDisplayEventConnection::stealReceiveChannel)>(Tag::STEAL_RECEIVE_CHANNEL, |
| 45 | outChannel); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 46 | } |
Mathias Agopian | 478ae5e | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 47 | |
Dan Stoza | e1c599b | 2017-03-30 16:37:19 -0700 | [diff] [blame] | 48 | status_t setVsyncRate(uint32_t count) override { |
Dan Stoza | 2d191c3 | 2017-04-03 13:27:12 -0700 | [diff] [blame] | 49 | return callRemote<decltype(&IDisplayEventConnection::setVsyncRate)>(Tag::SET_VSYNC_RATE, |
| 50 | count); |
Mathias Agopian | 478ae5e | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 51 | } |
| 52 | |
Dan Stoza | e1c599b | 2017-03-30 16:37:19 -0700 | [diff] [blame] | 53 | void requestNextVsync() override { |
Dan Stoza | 2d191c3 | 2017-04-03 13:27:12 -0700 | [diff] [blame] | 54 | callRemoteAsync<decltype(&IDisplayEventConnection::requestNextVsync)>( |
| 55 | Tag::REQUEST_NEXT_VSYNC); |
Mathias Agopian | 478ae5e | 2011-12-06 17:22:19 -0800 | [diff] [blame] | 56 | } |
Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame^] | 57 | |
| 58 | void toggleConfigEvents(ISurfaceComposer::ConfigChanged configChangeFlag) override { |
| 59 | callRemoteAsync<decltype( |
| 60 | &IDisplayEventConnection::toggleConfigEvents)>(Tag::TOGGLE_CONFIG_EVENTS, |
| 61 | configChangeFlag); |
| 62 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 63 | }; |
| 64 | |
Dan Stoza | a5f61dd | 2017-03-30 16:09:13 -0700 | [diff] [blame] | 65 | // Out-of-line virtual method definition to trigger vtable emission in this translation unit (see |
| 66 | // clang warning -Wweak-vtables) |
Dan Stoza | 2d191c3 | 2017-04-03 13:27:12 -0700 | [diff] [blame] | 67 | BpDisplayEventConnection::~BpDisplayEventConnection() = default; |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 68 | |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 69 | IMPLEMENT_META_INTERFACE(DisplayEventConnection, "android.gui.DisplayEventConnection"); |
| 70 | |
Dan Stoza | a5f61dd | 2017-03-30 16:09:13 -0700 | [diff] [blame] | 71 | status_t BnDisplayEventConnection::onTransact(uint32_t code, const Parcel& data, Parcel* reply, |
| 72 | uint32_t flags) { |
Dan Stoza | 2d191c3 | 2017-04-03 13:27:12 -0700 | [diff] [blame] | 73 | if (code < IBinder::FIRST_CALL_TRANSACTION || code > static_cast<uint32_t>(Tag::LAST)) { |
| 74 | return BBinder::onTransact(code, data, reply, flags); |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 75 | } |
Dan Stoza | 2d191c3 | 2017-04-03 13:27:12 -0700 | [diff] [blame] | 76 | auto tag = static_cast<Tag>(code); |
| 77 | switch (tag) { |
| 78 | case Tag::STEAL_RECEIVE_CHANNEL: |
| 79 | return callLocal(data, reply, &IDisplayEventConnection::stealReceiveChannel); |
| 80 | case Tag::SET_VSYNC_RATE: |
| 81 | return callLocal(data, reply, &IDisplayEventConnection::setVsyncRate); |
| 82 | case Tag::REQUEST_NEXT_VSYNC: |
| 83 | return callLocalAsync(data, reply, &IDisplayEventConnection::requestNextVsync); |
Alec Mouri | 60aee1c | 2019-10-28 16:18:59 -0700 | [diff] [blame^] | 84 | case Tag::TOGGLE_CONFIG_EVENTS: |
| 85 | return callLocalAsync(data, reply, &IDisplayEventConnection::toggleConfigEvents); |
Dan Stoza | 2d191c3 | 2017-04-03 13:27:12 -0700 | [diff] [blame] | 86 | } |
Mathias Agopian | d0566bc | 2011-11-17 17:49:17 -0800 | [diff] [blame] | 87 | } |
| 88 | |
Dan Stoza | a5f61dd | 2017-03-30 16:09:13 -0700 | [diff] [blame] | 89 | } // namespace android |