Add VR 1.0 hal.
Bug: 31442830 Test: make all and tested VR mode on a device. Change-Id: Icff8478c27184661d687d970d5b6759bff21beff
This commit is contained in:
parent
0fe3d8c2df
commit
8fd4c6141a
8 changed files with 243 additions and 0 deletions
|
@ -39,6 +39,8 @@ subdirs = [
|
|||
"vehicle/2.0",
|
||||
"vibrator/1.0",
|
||||
"vibrator/1.0/default",
|
||||
"vr/1.0",
|
||||
"vr/1.0/default",
|
||||
"wifi/1.0",
|
||||
"wifi/supplicant/1.0",
|
||||
]
|
||||
|
|
42
vr/1.0/Android.bp
Normal file
42
vr/1.0/Android.bp
Normal file
|
@ -0,0 +1,42 @@
|
|||
// This file is autogenerated by hidl-gen. Do not edit manually.
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.vr@1.0_genc++",
|
||||
tool: "hidl-gen",
|
||||
cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.vr@1.0",
|
||||
srcs: [
|
||||
"IVr.hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/vr/1.0/VrAll.cpp",
|
||||
],
|
||||
}
|
||||
|
||||
genrule {
|
||||
name: "android.hardware.vr@1.0_genc++_headers",
|
||||
tool: "hidl-gen",
|
||||
cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.vr@1.0",
|
||||
srcs: [
|
||||
"IVr.hal",
|
||||
],
|
||||
out: [
|
||||
"android/hardware/vr/1.0/IVr.h",
|
||||
"android/hardware/vr/1.0/IHwVr.h",
|
||||
"android/hardware/vr/1.0/BnVr.h",
|
||||
"android/hardware/vr/1.0/BpVr.h",
|
||||
"android/hardware/vr/1.0/BsVr.h",
|
||||
],
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
name: "android.hardware.vr@1.0",
|
||||
generated_sources: ["android.hardware.vr@1.0_genc++"],
|
||||
generated_headers: ["android.hardware.vr@1.0_genc++_headers"],
|
||||
export_generated_headers: ["android.hardware.vr@1.0_genc++_headers"],
|
||||
shared_libs: [
|
||||
"libhidl",
|
||||
"libhwbinder",
|
||||
"libutils",
|
||||
"libcutils",
|
||||
],
|
||||
}
|
41
vr/1.0/IVr.hal
Normal file
41
vr/1.0/IVr.hal
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.vr@1.0;
|
||||
|
||||
interface IVr {
|
||||
/**
|
||||
* Convenience method to set up any state needed at runtime startup. This is
|
||||
* called once from the VrManagerService during its boot phase.
|
||||
*/
|
||||
@callflow(next={"*"})
|
||||
@entry
|
||||
@exit
|
||||
init();
|
||||
|
||||
/**
|
||||
* Set the VR mode state. Possible states of the enabled parameter are:
|
||||
* false - VR mode is disabled, turn off all VR-specific settings.
|
||||
* true - VR mode is enabled, turn on all VR-specific settings.
|
||||
*
|
||||
* This must be called whenever the the Android system enters or leaves VR
|
||||
* mode. This will typically occur when the user switches to or from a VR
|
||||
* application that is doing stereoscopic rendering.
|
||||
*/
|
||||
@callflow(next={"*"})
|
||||
@exit
|
||||
setVrMode(bool enabled);
|
||||
};
|
16
vr/1.0/default/Android.bp
Normal file
16
vr/1.0/default/Android.bp
Normal file
|
@ -0,0 +1,16 @@
|
|||
cc_library_shared {
|
||||
name: "android.hardware.vr@1.0-impl",
|
||||
relative_install_path: "hw",
|
||||
srcs: ["Vr.cpp"],
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libcutils",
|
||||
"libhardware",
|
||||
"libhwbinder",
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libutils",
|
||||
"libhidl",
|
||||
"android.hardware.vr@1.0",
|
||||
],
|
||||
}
|
60
vr/1.0/default/Vr.cpp
Normal file
60
vr/1.0/default/Vr.cpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "VrService"
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <hardware/vr.h>
|
||||
#include "Vr.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vr {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
Vr::Vr(vr_module_t *device) : mDevice(device) {}
|
||||
|
||||
// Methods from ::android::hardware::vr::V1_0::IVr follow.
|
||||
Return<void> Vr::init() {
|
||||
mDevice->init(mDevice);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Vr::setVrMode(bool enabled) {
|
||||
mDevice->set_vr_mode(mDevice, enabled);
|
||||
return Void();
|
||||
}
|
||||
|
||||
IVr* HIDL_FETCH_IVr(const char *name) {
|
||||
vr_module_t *vr_module;
|
||||
const hw_module_t *hw_module = NULL;
|
||||
|
||||
int ret = hw_get_module(name, &hw_module);
|
||||
if (ret == 0) {
|
||||
return new Vr(reinterpret_cast<vr_module_t*>(
|
||||
const_cast<hw_module_t*>(hw_module)));
|
||||
} else {
|
||||
ALOGE("hw_get_module %s failed: %d", name, ret);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace vr
|
||||
} // namespace hardware
|
||||
} // namespace android
|
51
vr/1.0/default/Vr.h
Normal file
51
vr/1.0/default/Vr.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef HIDL_GENERATED_android_hardware_vr_V1_0_Vr_H_
|
||||
#define HIDL_GENERATED_android_hardware_vr_V1_0_Vr_H_
|
||||
|
||||
#include <android/hardware/vr/1.0/IVr.h>
|
||||
#include <hardware/vr.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace vr {
|
||||
namespace V1_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::hardware::vr::V1_0::IVr;
|
||||
using ::android::hardware::Return;
|
||||
|
||||
struct Vr : public IVr {
|
||||
Vr(vr_module_t *device);
|
||||
|
||||
// Methods from ::android::hardware::vr::V1_0::IVr follow.
|
||||
Return<void> init() override;
|
||||
Return<void> setVrMode(bool enabled) override;
|
||||
|
||||
private:
|
||||
vr_module_t *mDevice;
|
||||
};
|
||||
|
||||
extern "C" IVr* HIDL_FETCH_IVr(const char* name);
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_0
|
||||
} // namespace vr
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // HIDL_GENERATED_android_hardware_vr_V1_0_Vr_H_
|
4
vr/1.0/default/android.hardware.vr@1.0-service.rc
Normal file
4
vr/1.0/default/android.hardware.vr@1.0-service.rc
Normal file
|
@ -0,0 +1,4 @@
|
|||
service vr-1-0 /system/bin/hw/android.hardware.vr@1.0-service
|
||||
class hal
|
||||
user system
|
||||
group system readproc
|
27
vr/1.0/default/service.cpp
Normal file
27
vr/1.0/default/service.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define LOG_TAG "android.hardware.vr@1.0-service"
|
||||
|
||||
#include <android/hardware/vr/1.0/IVr.h>
|
||||
#include <hidl/LegacySupport.h>
|
||||
|
||||
// Generated HIDL files
|
||||
using android::hardware::vr::V1_0::IVr;
|
||||
using android::hardware::defaultPassthroughServiceImplementation;
|
||||
|
||||
int main() {
|
||||
return defaultPassthroughServiceImplementation<IVr>("vr");
|
||||
}
|
Loading…
Reference in a new issue