Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b580e654 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add VR 1.0 hal."

parents ba1dbb7d 8fd4c614
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -44,6 +44,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",
]

vr/1.0/Android.bp

0 → 100644
+42 −0
Original line number Diff line number Diff line
// 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",
    ],
}

vr/1.0/IVr.hal

0 → 100644
+41 −0
Original line number Diff line number Diff line
/*
 * 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 −0
Original line number Diff line number Diff line
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",
    ],
}

vr/1.0/default/Vr.cpp

0 → 100644
+60 −0
Original line number Diff line number Diff line
/*
 * 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
Loading