diff options
Diffstat (limited to 'vr')
| -rw-r--r-- | vr/1.0/Android.bp | 59 | ||||
| -rw-r--r-- | vr/1.0/Android.mk | 76 | ||||
| -rw-r--r-- | vr/1.0/IVr.hal | 41 | ||||
| -rw-r--r-- | vr/1.0/default/Android.bp | 36 | ||||
| -rw-r--r-- | vr/1.0/default/Vr.cpp | 62 | ||||
| -rw-r--r-- | vr/1.0/default/Vr.h | 51 | ||||
| -rw-r--r-- | vr/1.0/default/android.hardware.vr@1.0-service.rc | 4 | ||||
| -rw-r--r-- | vr/1.0/default/service.cpp | 27 | ||||
| -rw-r--r-- | vr/1.0/vts/functional/Android.bp | 32 | ||||
| -rw-r--r-- | vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp | 80 | ||||
| -rw-r--r-- | vr/Android.bp | 6 |
11 files changed, 474 insertions, 0 deletions
diff --git a/vr/1.0/Android.bp b/vr/1.0/Android.bp new file mode 100644 index 000000000..b48d01014 --- /dev/null +++ b/vr/1.0/Android.bp @@ -0,0 +1,59 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. + +filegroup { + name: "android.hardware.vr@1.0_hal", + srcs: [ + "IVr.hal", + ], +} + +genrule { + name: "android.hardware.vr@1.0_genc++", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.vr@1.0", + srcs: [ + ":android.hardware.vr@1.0_hal", + ], + out: [ + "android/hardware/vr/1.0/VrAll.cpp", + ], +} + +genrule { + name: "android.hardware.vr@1.0_genc++_headers", + tools: ["hidl-gen"], + cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.vr@1.0", + srcs: [ + ":android.hardware.vr@1.0_hal", + ], + out: [ + "android/hardware/vr/1.0/IVr.h", + "android/hardware/vr/1.0/IHwVr.h", + "android/hardware/vr/1.0/BnHwVr.h", + "android/hardware/vr/1.0/BpHwVr.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: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "liblog", + "libutils", + "libcutils", + "android.hidl.base@1.0", + ], + export_shared_lib_headers: [ + "libhidlbase", + "libhidltransport", + "libhwbinder", + "libutils", + "android.hidl.base@1.0", + ], +} diff --git a/vr/1.0/Android.mk b/vr/1.0/Android.mk new file mode 100644 index 000000000..0fbdaf77b --- /dev/null +++ b/vr/1.0/Android.mk @@ -0,0 +1,76 @@ +# This file is autogenerated by hidl-gen. Do not edit manually. + +LOCAL_PATH := $(call my-dir) + +################################################################################ + +include $(CLEAR_VARS) +LOCAL_MODULE := android.hardware.vr@1.0-java +LOCAL_MODULE_CLASS := JAVA_LIBRARIES + +intermediates := $(call local-generated-sources-dir, COMMON) + +HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) + +LOCAL_JAVA_LIBRARIES := \ + android.hidl.base@1.0-java \ + + +# +# Build IVr.hal +# +GEN := $(intermediates)/android/hardware/vr/V1_0/IVr.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IVr.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.vr@1.0::IVr + +$(GEN): $(LOCAL_PATH)/IVr.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) +include $(BUILD_JAVA_LIBRARY) + + +################################################################################ + +include $(CLEAR_VARS) +LOCAL_MODULE := android.hardware.vr@1.0-java-static +LOCAL_MODULE_CLASS := JAVA_LIBRARIES + +intermediates := $(call local-generated-sources-dir, COMMON) + +HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX) + +LOCAL_STATIC_JAVA_LIBRARIES := \ + android.hidl.base@1.0-java-static \ + + +# +# Build IVr.hal +# +GEN := $(intermediates)/android/hardware/vr/V1_0/IVr.java +$(GEN): $(HIDL) +$(GEN): PRIVATE_HIDL := $(HIDL) +$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IVr.hal +$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates) +$(GEN): PRIVATE_CUSTOM_TOOL = \ + $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \ + -Ljava \ + -randroid.hardware:hardware/interfaces \ + -randroid.hidl:system/libhidl/transport \ + android.hardware.vr@1.0::IVr + +$(GEN): $(LOCAL_PATH)/IVr.hal + $(transform-generated-source) +LOCAL_GENERATED_SOURCES += $(GEN) +include $(BUILD_STATIC_JAVA_LIBRARY) + + + +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/vr/1.0/IVr.hal b/vr/1.0/IVr.hal new file mode 100644 index 000000000..1f996e9e6 --- /dev/null +++ b/vr/1.0/IVr.hal @@ -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); +}; diff --git a/vr/1.0/default/Android.bp b/vr/1.0/default/Android.bp new file mode 100644 index 000000000..ddc1bfb76 --- /dev/null +++ b/vr/1.0/default/Android.bp @@ -0,0 +1,36 @@ +cc_library_shared { + name: "android.hardware.vr@1.0-impl", + defaults: ["hidl_defaults"], + proprietary: true, + relative_install_path: "hw", + srcs: ["Vr.cpp"], + shared_libs: [ + "liblog", + "libcutils", + "libhardware", + "libbase", + "libcutils", + "libutils", + "libhidlbase", + "libhidltransport", + "android.hardware.vr@1.0", + ], +} + +cc_binary { + relative_install_path: "hw", + defaults: ["hidl_defaults"], + proprietary: true, + name: "android.hardware.vr@1.0-service", + init_rc: ["android.hardware.vr@1.0-service.rc"], + srcs: ["service.cpp"], + shared_libs: [ + "liblog", + "libdl", + "libutils", + "libhardware", + "libhidlbase", + "libhidltransport", + "android.hardware.vr@1.0", + ], +} diff --git a/vr/1.0/default/Vr.cpp b/vr/1.0/default/Vr.cpp new file mode 100644 index 000000000..4bba9eb5a --- /dev/null +++ b/vr/1.0/default/Vr.cpp @@ -0,0 +1,62 @@ +/* + * 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 <log/log.h> + +#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*/) { + const hw_module_t *hw_module = NULL; + + int ret = hw_get_module(VR_HARDWARE_MODULE_ID, &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", VR_HARDWARE_MODULE_ID, ret); + return nullptr; + } +} + +} // namespace implementation +} // namespace V1_0 +} // namespace vr +} // namespace hardware +} // namespace android diff --git a/vr/1.0/default/Vr.h b/vr/1.0/default/Vr.h new file mode 100644 index 000000000..dd5e76454 --- /dev/null +++ b/vr/1.0/default/Vr.h @@ -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 ANDROID_HARDWARE_VR_V1_0_VR_H +#define 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 // ANDROID_HARDWARE_VR_V1_0_VR_H diff --git a/vr/1.0/default/android.hardware.vr@1.0-service.rc b/vr/1.0/default/android.hardware.vr@1.0-service.rc new file mode 100644 index 000000000..ba4330253 --- /dev/null +++ b/vr/1.0/default/android.hardware.vr@1.0-service.rc @@ -0,0 +1,4 @@ +service vr-1-0 /vendor/bin/hw/android.hardware.vr@1.0-service + class hal + user system + group system readproc diff --git a/vr/1.0/default/service.cpp b/vr/1.0/default/service.cpp new file mode 100644 index 000000000..22fb7d10e --- /dev/null +++ b/vr/1.0/default/service.cpp @@ -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>(); +} diff --git a/vr/1.0/vts/functional/Android.bp b/vr/1.0/vts/functional/Android.bp new file mode 100644 index 000000000..5c077eaa4 --- /dev/null +++ b/vr/1.0/vts/functional/Android.bp @@ -0,0 +1,32 @@ +// +// 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. +// + +cc_test { + name: "VtsHalVrV1_0TargetTest", + defaults: ["hidl_defaults"], + srcs: ["VtsHalVrV1_0TargetTest.cpp"], + shared_libs: [ + "liblog", + "libhidlbase", + "libutils", + "android.hardware.vr@1.0", + ], + static_libs: ["VtsHalHidlTargetBaseTest"], + cflags: [ + "-O0", + "-g", + ] +} diff --git a/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp b/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp new file mode 100644 index 000000000..6a7b07803 --- /dev/null +++ b/vr/1.0/vts/functional/VtsHalVrV1_0TargetTest.cpp @@ -0,0 +1,80 @@ +/* + * 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 "vr_hidl_hal_test" +#include <android-base/logging.h> +#include <android/hardware/vr/1.0/IVr.h> +#include <android/log.h> +#include <VtsHalHidlTargetBaseTest.h> +#include <hardware/vr.h> + +using ::android::hardware::vr::V1_0::IVr; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +// The main test class for VR HIDL HAL. +class VrHidlTest : public ::testing::VtsHalHidlTargetBaseTest { + public: + void SetUp() override { + vr = ::testing::VtsHalHidlTargetBaseTest::getService<IVr>(); + ASSERT_NE(vr, nullptr); + } + + void TearDown() override {} + + sp<IVr> vr; +}; + + +// A class for test environment setup (kept since this file is a template). +class VrHidlEnvironment : public ::testing::Environment { + public: + void SetUp() {} + void TearDown() {} + + private: +}; + +// Sanity check that Vr::init does not crash. +TEST_F(VrHidlTest, Init) { + EXPECT_TRUE(vr->init().isOk()); +} + +// Sanity check Vr::setVrMode is able to enable and disable VR mode. +TEST_F(VrHidlTest, SetVrMode) { + EXPECT_TRUE(vr->init().isOk()); + EXPECT_TRUE(vr->setVrMode(true).isOk()); + EXPECT_TRUE(vr->setVrMode(false).isOk()); +} + +// Sanity check that Vr::init and Vr::setVrMode can be used in any order. +TEST_F(VrHidlTest, ReInit) { + EXPECT_TRUE(vr->init().isOk()); + EXPECT_TRUE(vr->setVrMode(true).isOk()); + EXPECT_TRUE(vr->init().isOk()); + EXPECT_TRUE(vr->setVrMode(false).isOk()); + EXPECT_TRUE(vr->init().isOk()); + EXPECT_TRUE(vr->setVrMode(false).isOk()); +} + +int main(int argc, char **argv) { + ::testing::AddGlobalTestEnvironment(new VrHidlEnvironment); + ::testing::InitGoogleTest(&argc, argv); + int status = RUN_ALL_TESTS(); + ALOGI("Test result = %d", status); + return status; +} diff --git a/vr/Android.bp b/vr/Android.bp new file mode 100644 index 000000000..ed19a3703 --- /dev/null +++ b/vr/Android.bp @@ -0,0 +1,6 @@ +// This is an autogenerated file, do not edit. +subdirs = [ + "1.0", + "1.0/default", + "1.0/vts/functional", +] |
