Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vde hwc vhal #16

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// Copyright 2016-2024 Intel Corporation
//
// 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_defaults {
name: "hwc_vhal_defaults",

srcs: [
"common/RemoteDisplay.cpp",
"common/RemoteDisplayMgr.cpp",
"common/LocalDisplay.cpp",
"common/BufferMapper.cpp",
"hwc2/Hwc2Device.cpp",
"hwc2/Hwc2Display.cpp",
"hwc2/Hwc2Layer.cpp",
],

local_include_dirs: [
"common",
],

shared_libs: [
"liblog",
"libcutils",
"libhardware",
],

cflags: [
"-Werror",
"-Wno-error",
"-DLOG_TAG=\"hwc_vhal\"",
"-DHWC2_INCLUDE_STRINGIFICATION",
"-DHWC2_USE_CPP11",
"-DSUPPORT_HWC_2_0",
"-DSUPPORT_HWC_2_1",
"-DSUPPORT_HWC_2_2",
"-DSUPPORT_HWC_2_3",
"-DSUPPORT_HWC_2_4",
],
}

cc_library_shared {
name: "hwcomposer.remote",
defaults: ["hwc_vhal_defaults"],

cflags: [
"-DENABLE_HWC_REMOTE",
"-DUSE_ABSTRACT_SOCKET",
],

vendor: true,
relative_install_path: "hw",
}

cc_library_shared {
name: "hwcomposer.uio",
defaults: ["hwc_vhal_defaults"],

srcs: [
"uio/UioDisplay.cpp",
],

local_include_dirs: [
"uio",
],

cflags: [
"-DENABLE_HWC_UIO",
"-DENABLE_MULTI_DISPLAY",
],

vendor: true,
relative_install_path: "hw",
}
125 changes: 0 additions & 125 deletions Android.mk

This file was deleted.

36 changes: 26 additions & 10 deletions common/RemoteDisplayMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Date: 2021.06.09
//#define LOG_NDEBUG 0

#include <cutils/log.h>
#include <cutils/properties.h>

#include <sys/epoll.h>
#include <sys/ioctl.h>
Expand All @@ -52,9 +53,6 @@ RemoteDisplayMgr::~RemoteDisplayMgr() {
}

int RemoteDisplayMgr::init(IRemoteDevice* dev) {

return -1;

mEpollFd = epoll_create(kMaxEvents);
if (mEpollFd == -1) {
ALOGE("epoll_create:%s", strerror(errno));
Expand Down Expand Up @@ -215,26 +213,44 @@ void RemoteDisplayMgr::socketThreadProc() {
addr.sun_family = AF_UNIX;
strncpy(&addr.sun_path[0], kServerSock, strlen(kServerSock));

unlink(kServerSock);
const char* path = kServerSock;
#ifdef USE_ABSTRACT_SOCKET
bool abstract = true;
#else
bool abstract = false;
#endif
if (abstract) {
path = "hwc-sock";
strncpy(&addr.sun_path[1], path, strlen(path));
addr.sun_path[0] = 0;
} else {
strncpy(&addr.sun_path[0], path, strlen(path));
unlink(path);
}

if (bind(mServerFd, (struct sockaddr*)&addr,
sizeof(sa_family_t) + strlen(kServerSock) + 1) < 0) {
sizeof(sa_family_t) + strlen(path) + 1) < 0) {
ALOGE("Failed to bind server socket address");
return;
}

// TODO: use group access only for security
struct stat st;
__mode_t mod = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
if (fstat(mServerFd, &st) == 0) {
mod |= st.st_mode;
if (!abstract) {
struct stat st;
__mode_t mod = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
if (fstat(mServerFd, &st) == 0) {
mod |= st.st_mode;
}
chmod(path, mod);
}
chmod(kServerSock, mod);

if (listen(mServerFd, 1) < 0) {
ALOGE("Failed to listen on server socket");
return;
}

property_set("vendor.hwc_vhal.ready", "1");

while (true) {
struct epoll_event events[kMaxEvents];
int nfds = epoll_wait(mEpollFd, events, kMaxEvents, -1);
Expand Down
14 changes: 11 additions & 3 deletions hwc2/Hwc2Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Hwc2Device::Hwc2Device() {
Error Hwc2Device::init() {
ALOGV("%s", __func__);

#ifdef ENABLE_HWC_REMOTE
mRemoteDisplayMgr = std::unique_ptr<RemoteDisplayMgr>(new RemoteDisplayMgr());
if (!mRemoteDisplayMgr) {
ALOGE("Failed to create remote display manager, out of memory");
Expand All @@ -68,6 +69,7 @@ Error Hwc2Device::init() {
mDisplays.emplace(kPrimayDisplay, 0);
onHotplug(kPrimayDisplay, true);
}
#endif

#ifdef ENABLE_MULTI_DISPLAY
int maxDisplayCount = kMaxDisplayCount;
Expand Down Expand Up @@ -519,9 +521,15 @@ hwc2_function_pointer_t Hwc2Device::getFunctionHook(struct hwc2_device* dev,

case FunctionDescriptor::Invalid:
default:
ALOGE("%s:Unsupported HWC2 function, descriptor=%d", __func__,
descriptor);
return nullptr;
if (descriptor == HWC3_FUNCTION_SET_EXPECTED_PRESENT_TIME)
return asFP<HWC3_PFN_SET_EXPECTED_PRESENT_TIME>(
DisplayHook<decltype(&Hwc2Display::setExpectedPresentTime),
&Hwc2Display::setExpectedPresentTime, const std::optional<ClockMonotonicTimestamp>&>);
else {
ALOGE("%s:Unsupported HWC2 function, descriptor=%d", __func__,
descriptor);
return nullptr;
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion hwc2/Hwc2Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Hwc2Display::Hwc2Display(hwc2_display_t id) {
ALOGD("Display %" PRIu64 " default size <%d %d> from debug fs", id, w, h);
}

if (w & h) {
if (w && h) {
mWidth = w;
mHeight = h;
}
Expand Down Expand Up @@ -631,3 +631,8 @@ Error Hwc2Display::setActiveConfigWithConstraints(hwc2_config_t config,
ALOGV("Hwc2Display(%" PRIu64 ")::%s", mDisplayID, __func__);
return Error::None;
}

HWC2::Error Hwc2Display::setExpectedPresentTime(
const std::optional<ClockMonotonicTimestamp>& expectedPresentTime) {
return HWC2::Error::None;
}
14 changes: 14 additions & 0 deletions hwc2/Hwc2Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Date: 2021.06.09
#include <map>
#include <memory>
#include <vector>
#include <optional>

#include <hardware/hwcomposer2.h>

Expand All @@ -42,6 +43,17 @@ Date: 2021.06.09
#include "UioDisplay.h"
#endif

//TODO: include HWC3 headers
struct ClockMonotonicTimestamp {
int64_t timestampNanos;
};
typedef enum {
HWC3_FUNCTION_SET_EXPECTED_PRESENT_TIME = HWC2_FUNCTION_GET_LAYER_GENERIC_METADATA_KEY + 1,
} hwc3_function_descriptor_t;
typedef int32_t /*hwc_error_t*/ (*HWC3_PFN_SET_EXPECTED_PRESENT_TIME)(hwc2_device_t* device,
hwc2_display_t display, const std::optional<ClockMonotonicTimestamp>& expectedPresentTime);


class RemoteDisplay;

class Hwc2Display : public DisplayEventListener {
Expand Down Expand Up @@ -116,6 +128,8 @@ class Hwc2Display : public DisplayEventListener {
HWC2::Error setActiveConfigWithConstraints(hwc2_config_t config,
hwc_vsync_period_change_constraints_t* constraints,
hwc_vsync_period_change_timeline_t* timeline_t);
HWC2::Error setExpectedPresentTime(
const std::optional<ClockMonotonicTimestamp>& expectedPresentTime);

protected:
HWC2::Error hotplug(bool in);
Expand Down