blob: a0de9983599ef513797b2dce5abbf250846c1062 [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
Mark Salyzyn3ff52602017-01-10 10:16:48 -080019#include <log/log.h>
20
Craig Donner8fd4c612016-10-14 17:53:46 -070021#include <hardware/hardware.h>
22#include <hardware/vr.h>
Mark Salyzyn3ff52602017-01-10 10:16:48 -080023
Craig Donner8fd4c612016-10-14 17:53:46 -070024#include "Vr.h"
25
26namespace android {
27namespace hardware {
28namespace vr {
29namespace V1_0 {
30namespace implementation {
31
32Vr::Vr(vr_module_t *device) : mDevice(device) {}
33
34// Methods from ::android::hardware::vr::V1_0::IVr follow.
35Return<void> Vr::init() {
36 mDevice->init(mDevice);
37 return Void();
38}
39
40Return<void> Vr::setVrMode(bool enabled) {
41 mDevice->set_vr_mode(mDevice, enabled);
42 return Void();
43}
44
45IVr* 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