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