blob: 4b2c60356fe10bea78f57ec8efe1dfef48461721 [file] [log] [blame]
Craig Donner8fd4c612016-10-14 17:53:46 -07001/*
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
19#include <hardware/hardware.h>
20#include <hardware/vr.h>
21#include "Vr.h"
22
23namespace android {
24namespace hardware {
25namespace vr {
26namespace V1_0 {
27namespace implementation {
28
29Vr::Vr(vr_module_t *device) : mDevice(device) {}
30
31// Methods from ::android::hardware::vr::V1_0::IVr follow.
32Return<void> Vr::init() {
33 mDevice->init(mDevice);
34 return Void();
35}
36
37Return<void> Vr::setVrMode(bool enabled) {
38 mDevice->set_vr_mode(mDevice, enabled);
39 return Void();
40}
41
42IVr* HIDL_FETCH_IVr(const char *name) {
43 vr_module_t *vr_module;
44 const hw_module_t *hw_module = NULL;
45
46 int ret = hw_get_module(name, &hw_module);
47 if (ret == 0) {
48 return new Vr(reinterpret_cast<vr_module_t*>(
49 const_cast<hw_module_t*>(hw_module)));
50 } else {
51 ALOGE("hw_get_module %s failed: %d", name, ret);
52 return nullptr;
53 }
54}
55
56} // namespace implementation
57} // namespace V1_0
58} // namespace vr
59} // namespace hardware
60} // namespace android