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

Commit 51a0a563 authored by Daniel Nicoara's avatar Daniel Nicoara
Browse files

VR: Create VR implementation for HWC HIDL interface

* Implement the IComposerClient interface for a VR HWC.
* Introduce new command to send layer information to the VR HWC.
* Add observer interface in the VR HWC service allowing VR Window
  Manager to consume SurfaceFlinger output.

Bug: 32541196, 33297385
Test: Compiled and ran with modified surfaceflinger that connects to the
VR hwcomposer and made sure there are no crashes.

Change-Id: Ic2c882ba5e4c570cbd0b7a180845a5e61a768cad
parent e895863c
Loading
Loading
Loading
Loading

services/vr/Android.bp

0 → 100644
+3 −0
Original line number Diff line number Diff line
subdirs = [
  "*",
]
+39 −0
Original line number Diff line number Diff line
subdirs = [
  "composer/1.0",
]

cc_library_shared {
  name: "libvrhwc",

  srcs: [
    "composer/impl/sync_timeline.cpp",
    "composer/impl/vr_hwc.cpp",
    "composer/impl/vr_composer_client.cpp",
  ],

  static_libs: [
    "libhwcomposer-client",
  ],

  shared_libs: [
    "android.dvr.composer@1.0",
    "android.hardware.graphics.composer@2.1",
    "libbase",
    "libcutils",
    "libfmq",
    "libhardware",
    "libhidlbase",
    "libhidltransport",
    "liblog",
    "libsync",
    "libui",
    "libutils",
  ],

  // Access to software sync timeline.
  include_dirs: [ "system/core/libsync" ],

  cflags: [
    "-DLOG_TAG=\"vrhwc\"",
  ],
}
+54 −0
Original line number Diff line number Diff line
// This file is autogenerated by hidl-gen. Do not edit manually.

genrule {
    name: "android.dvr.composer@1.0_genc++",
    tools: ["hidl-gen"],
    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hidl:system/libhidl/transport -randroid.hardware:hardware/interfaces/ -randroid.dvr:frameworks/native/services/vr/vr_window_manager android.dvr.composer@1.0",
    srcs: [
        "IVrComposerClient.hal",
    ],
    out: [
        "android/dvr/composer/1.0/VrComposerClientAll.cpp",
    ],
}

genrule {
    name: "android.dvr.composer@1.0_genc++_headers",
    tools: ["hidl-gen"],
    cmd: "$(location hidl-gen) -o $(genDir) -Lc++ -randroid.hidl:system/libhidl/transport -randroid.hardware:hardware/interfaces/ -randroid.dvr:frameworks/native/services/vr/vr_window_manager android.dvr.composer@1.0",
    srcs: [
        "IVrComposerClient.hal",
    ],
    out: [
        "android/dvr/composer/1.0/IVrComposerClient.h",
        "android/dvr/composer/1.0/IHwVrComposerClient.h",
        "android/dvr/composer/1.0/BnVrComposerClient.h",
        "android/dvr/composer/1.0/BpVrComposerClient.h",
        "android/dvr/composer/1.0/BsVrComposerClient.h",
    ],
}

cc_library_shared {
    name: "android.dvr.composer@1.0",
    generated_sources: ["android.dvr.composer@1.0_genc++"],
    generated_headers: ["android.dvr.composer@1.0_genc++_headers"],
    export_generated_headers: ["android.dvr.composer@1.0_genc++_headers"],
    shared_libs: [
        "libhidlbase",
        "libhidltransport",
        "libhwbinder",
        "liblog",
        "libutils",
        "libcutils",
        "android.hardware.graphics.composer@2.1",
        "android.hidl.base@1.0",
    ],
    export_shared_lib_headers: [
        "libhidlbase",
        "libhidltransport",
        "libhwbinder",
        "libutils",
        "android.hardware.graphics.composer@2.1",
        "android.hidl.base@1.0",
    ],
}
+49 −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.dvr.composer@1.0;

import android.hardware.graphics.composer@2.1::IComposerClient;

interface IVrComposerClient
    extends android.hardware.graphics.composer@2.1::IComposerClient {
    /*
     * Used to annotate the layer with additional information, which will be
     * used to describe the content of the layer (ie: notification, permission,
     * etc) which allows VR window manager to treat certain layer types
     * specially.
     *
     * @param display is the display on which the layer was created.
     * @param layer is the layer affected by the change.
     * @param layer_type the type of the layer as described by the window
     * manager.
     * @param application_id the application id the layer belongs to.
     * @return error is NONE upon success. Otherwise,
     *         BAD_DISPLAY when an invalid display handle was passed in.
     *         BAD_LAYER when an invalid layer handle was passed in.
     *
     * setLayerInfo(Display display,
     *              Layer layer,
     *              uint32_t layer_type,
     *              uint32_t application_id)
     *     generates(Error error);
     */

    enum VrCommand : int32_t {
        OPCODE_SHIFT         = android.hardware.graphics.composer@2.1::IComposerClient.Command:OPCODE_SHIFT,

        SET_LAYER_INFO = 0x800 << OPCODE_SHIFT,
    };
};
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright 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.
 */
#include "composer/impl/sync_timeline.h"

#include <sys/cdefs.h>
#include <sw_sync.h>
#include <unistd.h>

namespace android {
namespace dvr {

SyncTimeline::SyncTimeline() {}

SyncTimeline::~SyncTimeline() {}

bool SyncTimeline::Initialize() {
  timeline_fd_.reset(sw_sync_timeline_create());
  return timeline_fd_ >= 0;
}

int SyncTimeline::CreateFence(int time) {
  return sw_sync_fence_create(timeline_fd_.get(), "dummy fence", time);
}

bool SyncTimeline::IncrementTimeline() {
  return sw_sync_timeline_inc(timeline_fd_.get(), 1) == 0;
}

}  // namespace dvr
}  // namespace android
Loading