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