Craig Donner | 8fd4c61 | 2016-10-14 17:53:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
| 17 | #define LOG_TAG "VrService" |
| 18 | |
Mark Salyzyn | 3ff5260 | 2017-01-10 10:16:48 -0800 | [diff] [blame] | 19 | #include <log/log.h> |
| 20 | |
Craig Donner | 8fd4c61 | 2016-10-14 17:53:46 -0700 | [diff] [blame] | 21 | #include <hardware/hardware.h> |
| 22 | #include <hardware/vr.h> |
Mark Salyzyn | 3ff5260 | 2017-01-10 10:16:48 -0800 | [diff] [blame] | 23 | |
Craig Donner | 8fd4c61 | 2016-10-14 17:53:46 -0700 | [diff] [blame] | 24 | #include "Vr.h" |
| 25 | |
| 26 | namespace android { |
| 27 | namespace hardware { |
| 28 | namespace vr { |
| 29 | namespace V1_0 { |
| 30 | namespace implementation { |
| 31 | |
| 32 | Vr::Vr(vr_module_t *device) : mDevice(device) {} |
| 33 | |
| 34 | // Methods from ::android::hardware::vr::V1_0::IVr follow. |
| 35 | Return<void> Vr::init() { |
| 36 | mDevice->init(mDevice); |
| 37 | return Void(); |
| 38 | } |
| 39 | |
| 40 | Return<void> Vr::setVrMode(bool enabled) { |
| 41 | mDevice->set_vr_mode(mDevice, enabled); |
| 42 | return Void(); |
| 43 | } |
| 44 | |
| 45 | IVr* HIDL_FETCH_IVr(const char *name) { |
| 46 | vr_module_t *vr_module; |
| 47 | const hw_module_t *hw_module = NULL; |
| 48 | |
| 49 | int ret = hw_get_module(name, &hw_module); |
| 50 | if (ret == 0) { |
| 51 | return new Vr(reinterpret_cast<vr_module_t*>( |
| 52 | const_cast<hw_module_t*>(hw_module))); |
| 53 | } else { |
| 54 | ALOGE("hw_get_module %s failed: %d", name, ret); |
| 55 | return nullptr; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | } // namespace implementation |
| 60 | } // namespace V1_0 |
| 61 | } // namespace vr |
| 62 | } // namespace hardware |
| 63 | } // namespace android |