Merge "graphics: Add composer 2.3"

This commit is contained in:
Dominik Laskowski
2018-05-02 22:24:01 +00:00
committed by Android (Google) Code Review
21 changed files with 1038 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
// This file is autogenerated by hidl-gen -Landroidbp.
hidl_interface {
name: "android.hardware.graphics.composer@2.3",
root: "android.hardware",
vndk: {
enabled: true,
},
srcs: [
"IComposer.hal",
"IComposerClient.hal",
],
interfaces: [
"android.hardware.graphics.common@1.0",
"android.hardware.graphics.composer@2.1",
"android.hardware.graphics.composer@2.2",
"android.hidl.base@1.0",
],
gen_java: false,
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2018 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.graphics.composer@2.3;
import IComposerClient;
import @2.1::Error;
import @2.2::IComposer;
interface IComposer extends @2.2::IComposer {
/**
* Creates a v2.3 client of the composer. Supersedes @2.1::createClient.
*
* @return error is NONE upon success. Otherwise,
* NO_RESOURCES when the client could not be created.
* @return client is the newly created client.
*/
@entry
@callflow(next="*")
createClient_2_3() generates (Error error, IComposerClient client);
};

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2018 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.graphics.composer@2.3;
import @2.2::IComposerClient;
import @2.1::Display;
import @2.1::Error;
interface IComposerClient extends @2.2::IComposerClient {
/**
* Returns the port and data that describe a physical display. The port is
* a unique number that identifies a physical connector (e.g. eDP, HDMI)
* for display output. The data blob is parsed to determine its format,
* typically EDID 1.3 as specified in VESA E-EDID Standard Release A
* Revision 1.
*
* @param display is the display to query.
* @return error is NONE upon success. Otherwise,
* BAD_DISPLAY when an invalid display handle was passed in.
* UNSUPPORTED when identification data is unavailable.
* @return port is the connector to which the display is connected.
* @return data is the EDID 1.3 blob identifying the display.
*/
@callflow(next="*")
getDisplayIdentificationData(Display display)
generates (Error error,
uint8_t port,
vec<uint8_t> data);
};

View File

@@ -0,0 +1,45 @@
//
// Copyright (C) 2018 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_binary {
name: "android.hardware.graphics.composer@2.3-service",
defaults: ["hidl_defaults"],
vendor: true,
relative_install_path: "hw",
srcs: ["service.cpp"],
init_rc: ["android.hardware.graphics.composer@2.3-service.rc"],
header_libs: [
"android.hardware.graphics.composer@2.3-passthrough",
],
shared_libs: [
"android.hardware.graphics.composer@2.1",
"android.hardware.graphics.composer@2.2",
"android.hardware.graphics.composer@2.3",
"android.hardware.graphics.mapper@2.0",
"libbase",
"libbinder",
"libcutils",
"libfmq",
"libhardware",
"libhidlbase",
"libhidltransport",
"libhwc2on1adapter",
"libhwc2onfbadapter",
"liblog",
"libsync",
"libutils",
],
}

View File

@@ -0,0 +1,4 @@
# Graphics team
jessehall@google.com
olv@google.com
stoza@google.com

View File

@@ -0,0 +1,6 @@
service vendor.hwcomposer-2-3 /vendor/bin/hw/android.hardware.graphics.composer@2.3-service
class hal animation
user system
group graphics drmrpc
capabilities SYS_NICE
onrestart restart surfaceflinger

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2018 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 <sched.h>
#include <android/hardware/graphics/composer/2.3/IComposer.h>
#include <binder/ProcessState.h>
#include <composer-passthrough/2.3/HwcLoader.h>
#include <hidl/HidlTransportSupport.h>
using android::hardware::graphics::composer::V2_3::IComposer;
using android::hardware::graphics::composer::V2_3::passthrough::HwcLoader;
int main() {
// the conventional HAL might start binder services
android::ProcessState::initWithDriver("/dev/vndbinder");
android::ProcessState::self()->setThreadPoolMaxThreadCount(4);
android::ProcessState::self()->startThreadPool();
// same as SF main thread
struct sched_param param = {0};
param.sched_priority = 2;
if (sched_setscheduler(0, SCHED_FIFO | SCHED_RESET_ON_FORK, &param) != 0) {
ALOGE("Couldn't set SCHED_FIFO: %d", errno);
}
android::hardware::configureRpcThreadpool(4, true /* will join */);
android::sp<IComposer> composer = HwcLoader::load();
if (composer == nullptr) {
return 1;
}
if (composer->registerAsService() != android::NO_ERROR) {
ALOGE("failed to register service");
return 1;
}
android::hardware::joinRpcThreadpool();
ALOGE("service is terminating");
return 1;
}

View File

@@ -0,0 +1,7 @@
# Graphics team
olv@google.com
stoza@google.com
# VTS team
yim@google.com
zhuoyao@google.com

View File

@@ -0,0 +1,34 @@
//
// Copyright (C) 2018 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_library_headers {
name: "android.hardware.graphics.composer@2.3-hal",
defaults: ["hidl_defaults"],
vendor_available: true,
shared_libs: [
"android.hardware.graphics.composer@2.3",
],
export_shared_lib_headers: [
"android.hardware.graphics.composer@2.3",
],
header_libs: [
"android.hardware.graphics.composer@2.2-hal",
],
export_header_lib_headers: [
"android.hardware.graphics.composer@2.2-hal",
],
export_include_dirs: ["include"],
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright 2018 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.
*/
#pragma once
#ifndef LOG_TAG
#warning "Composer.h included without LOG_TAG"
#endif
#include <android/hardware/graphics/composer/2.3/IComposer.h>
#include <composer-hal/2.2/Composer.h>
#include <composer-hal/2.3/ComposerClient.h>
namespace android {
namespace hardware {
namespace graphics {
namespace composer {
namespace V2_3 {
namespace hal {
namespace detail {
// ComposerImpl implements V2_*::IComposer on top of V2_*::ComposerHal
template <typename Interface, typename Hal>
class ComposerImpl : public V2_2::hal::detail::ComposerImpl<Interface, Hal> {
public:
static std::unique_ptr<ComposerImpl> create(std::unique_ptr<Hal> hal) {
return std::make_unique<ComposerImpl>(std::move(hal));
}
explicit ComposerImpl(std::unique_ptr<Hal> hal) : BaseType2_2(std::move(hal)) {}
// IComposer 2.3 interface
Return<void> createClient_2_3(IComposer::createClient_2_3_cb hidl_cb) override {
std::unique_lock<std::mutex> lock(mClientMutex);
if (!waitForClientDestroyedLocked(lock)) {
hidl_cb(Error::NO_RESOURCES, nullptr);
return Void();
}
sp<ComposerClient> client = ComposerClient::create(mHal.get()).release();
if (!client) {
hidl_cb(Error::NO_RESOURCES, nullptr);
return Void();
}
auto clientDestroyed = [this]() { onClientDestroyed(); };
client->setOnClientDestroyed(clientDestroyed);
mClient = client;
hidl_cb(Error::NONE, client);
return Void();
}
private:
using BaseType2_2 = V2_2::hal::detail::ComposerImpl<Interface, Hal>;
using BaseType2_1 = V2_1::hal::detail::ComposerImpl<Interface, Hal>;
using BaseType2_1::mClient;
using BaseType2_1::mClientMutex;
using BaseType2_1::mHal;
using BaseType2_1::onClientDestroyed;
using BaseType2_1::waitForClientDestroyedLocked;
};
} // namespace detail
using Composer = detail::ComposerImpl<IComposer, ComposerHal>;
} // namespace hal
} // namespace V2_3
} // namespace composer
} // namespace graphics
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,74 @@
/*
* Copyright 2018 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.
*/
#pragma once
#ifndef LOG_TAG
#warning "ComposerClient.h included without LOG_TAG"
#endif
#include <android/hardware/graphics/composer/2.3/IComposerClient.h>
#include <composer-hal/2.3/ComposerClient.h>
#include <composer-hal/2.3/ComposerHal.h>
namespace android {
namespace hardware {
namespace graphics {
namespace composer {
namespace V2_3 {
namespace hal {
namespace detail {
// ComposerClientImpl implements V2_*::IComposerClient on top of V2_*::ComposerHal
template <typename Interface, typename Hal>
class ComposerClientImpl : public V2_2::hal::detail::ComposerClientImpl<Interface, Hal> {
public:
static std::unique_ptr<ComposerClientImpl> create(Hal* hal) {
auto client = std::make_unique<ComposerClientImpl>(hal);
return client->init() ? std::move(client) : nullptr;
}
ComposerClientImpl(Hal* hal) : BaseType2_2(hal) {}
// IComposerClient 2.3 interface
Return<void> getDisplayIdentificationData(
Display display, IComposerClient::getDisplayIdentificationData_cb hidl_cb) override {
uint8_t port = 0;
std::vector<uint8_t> data;
Error error = mHal->getDisplayIdentificationData(display, &port, &data);
hidl_cb(error, port, data);
return Void();
}
private:
using BaseType2_2 = V2_2::hal::detail::ComposerClientImpl<Interface, Hal>;
using BaseType2_1 = V2_1::hal::detail::ComposerClientImpl<Interface, Hal>;
using BaseType2_1::mHal;
};
} // namespace detail
using ComposerClient = detail::ComposerClientImpl<IComposerClient, ComposerHal>;
} // namespace hal
} // namespace V2_3
} // namespace composer
} // namespace graphics
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2018 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.
*/
#pragma once
#include <composer-hal/2.2/ComposerHal.h>
namespace android {
namespace hardware {
namespace graphics {
namespace composer {
namespace V2_3 {
namespace hal {
using V2_1::Display;
using V2_1::Error;
class ComposerHal : public V2_2::hal::ComposerHal {
public:
virtual Error getDisplayIdentificationData(Display display, uint8_t* outPort,
std::vector<uint8_t>* outData) = 0;
};
} // namespace hal
} // namespace V2_3
} // namespace composer
} // namespace graphics
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,30 @@
//
// Copyright (C) 2018 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_library_headers {
name: "android.hardware.graphics.composer@2.3-passthrough",
defaults: ["hidl_defaults"],
vendor: true,
header_libs: [
"android.hardware.graphics.composer@2.2-passthrough",
"android.hardware.graphics.composer@2.3-hal",
],
export_header_lib_headers: [
"android.hardware.graphics.composer@2.2-passthrough",
"android.hardware.graphics.composer@2.3-hal",
],
export_include_dirs: ["include"],
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright 2018 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.
*/
#pragma once
#ifndef LOG_TAG
#warning "HwcHal.h included without LOG_TAG"
#endif
#include <type_traits>
#include <composer-hal/2.3/ComposerHal.h>
#include <composer-passthrough/2.2/HwcHal.h>
namespace android {
namespace hardware {
namespace graphics {
namespace composer {
namespace V2_3 {
namespace passthrough {
namespace detail {
using V2_1::Display;
using V2_1::Error;
// HwcHalImpl implements V2_*::hal::ComposerHal on top of hwcomposer2
template <typename Hal>
class HwcHalImpl : public V2_2::passthrough::detail::HwcHalImpl<Hal> {
public:
Error getDisplayIdentificationData(Display display, uint8_t* outPort,
std::vector<uint8_t>* outData) override {
if (!mDispatch.getDisplayIdentificationData) {
return Error::UNSUPPORTED;
}
uint32_t size = 0;
int32_t error =
mDispatch.getDisplayIdentificationData(mDevice, display, outPort, &size, nullptr);
if (error != HWC2_ERROR_NONE) {
return static_cast<Error>(error);
}
std::vector<uint8_t> data(size);
error =
mDispatch.getDisplayIdentificationData(mDevice, display, outPort, &size, data.data());
if (error != HWC2_ERROR_NONE) {
return static_cast<Error>(error);
}
data.resize(size);
*outData = std::move(data);
return Error::NONE;
}
protected:
bool initDispatch() override {
if (!BaseType2_2::initDispatch()) {
return false;
}
this->initOptionalDispatch(HWC2_FUNCTION_GET_DISPLAY_IDENTIFICATION_DATA,
&mDispatch.getDisplayIdentificationData);
return true;
}
private:
struct {
HWC2_PFN_GET_DISPLAY_IDENTIFICATION_DATA getDisplayIdentificationData;
} mDispatch = {};
using BaseType2_2 = V2_2::passthrough::detail::HwcHalImpl<Hal>;
using BaseType2_1 = V2_1::passthrough::detail::HwcHalImpl<Hal>;
using BaseType2_1::mDevice;
};
} // namespace detail
using HwcHal = detail::HwcHalImpl<hal::ComposerHal>;
} // namespace passthrough
} // namespace V2_3
} // namespace composer
} // namespace graphics
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,79 @@
/*
* Copyright 2018 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.
*/
#pragma once
#ifndef LOG_TAG
#warning "HwcLoader.h included without LOG_TAG"
#endif
#include <composer-hal/2.3/Composer.h>
#include <composer-hal/2.3/ComposerHal.h>
#include <composer-passthrough/2.2/HwcLoader.h>
#include <composer-passthrough/2.3/HwcHal.h>
namespace android {
namespace hardware {
namespace graphics {
namespace composer {
namespace V2_3 {
namespace passthrough {
class HwcLoader : public V2_2::passthrough::HwcLoader {
public:
static IComposer* load() {
const hw_module_t* module = loadModule();
if (!module) {
return nullptr;
}
auto hal = createHalWithAdapter(module);
if (!hal) {
return nullptr;
}
return createComposer(std::move(hal)).release();
}
// create a ComposerHal instance
static std::unique_ptr<hal::ComposerHal> createHal(const hw_module_t* module) {
auto hal = std::make_unique<HwcHal>();
return hal->initWithModule(module) ? std::move(hal) : nullptr;
}
// create a ComposerHal instance, insert an adapter if necessary
static std::unique_ptr<hal::ComposerHal> createHalWithAdapter(const hw_module_t* module) {
bool adapted;
hwc2_device_t* device = openDeviceWithAdapter(module, &adapted);
if (!device) {
return nullptr;
}
auto hal = std::make_unique<HwcHal>();
return hal->initWithDevice(std::move(device), !adapted) ? std::move(hal) : nullptr;
}
// create an IComposer instance
static std::unique_ptr<IComposer> createComposer(std::unique_ptr<hal::ComposerHal> hal) {
return hal::Composer::create(std::move(hal));
}
};
} // namespace passthrough
} // namespace V2_3
} // namespace composer
} // namespace graphics
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,41 @@
//
// Copyright (C) 2018 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_library_static {
name: "android.hardware.graphics.composer@2.3-vts",
defaults: ["hidl_defaults"],
srcs: [
"ComposerVts.cpp",
],
static_libs: [
"VtsHalHidlTargetTestBase",
"android.hardware.graphics.composer@2.1",
"android.hardware.graphics.composer@2.1-vts",
"android.hardware.graphics.composer@2.2",
"android.hardware.graphics.composer@2.2-vts",
"android.hardware.graphics.composer@2.3",
],
header_libs: [
"android.hardware.graphics.composer@2.1-command-buffer",
"android.hardware.graphics.composer@2.2-command-buffer",
],
cflags: [
"-O0",
"-g",
"-DLOG_TAG=\"ComposerVts\"",
],
export_include_dirs: ["include"],
}

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 2018 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-vts/2.3/ComposerVts.h>
#include <VtsHalHidlTargetTestBase.h>
namespace android {
namespace hardware {
namespace graphics {
namespace composer {
namespace V2_3 {
namespace vts {
using V2_1::Error;
Composer::Composer() : Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>()) {}
Composer::Composer(const std::string& name)
: Composer(::testing::VtsHalHidlTargetTestBase::getService<IComposer>(name)) {}
Composer::Composer(const sp<IComposer>& composer)
: V2_2::vts::Composer(composer), mComposer(composer) {}
std::unique_ptr<ComposerClient> Composer::createClient() {
std::unique_ptr<ComposerClient> client;
mComposer->createClient_2_3([&client](const auto& tmpError, const auto& tmpClient) {
ASSERT_EQ(Error::NONE, tmpError) << "failed to create client";
client = std::make_unique<ComposerClient>(tmpClient);
});
return client;
}
bool ComposerClient::getDisplayIdentificationData(Display display, uint8_t* outPort,
std::vector<uint8_t>* outData) {
bool supported = true;
mClient->getDisplayIdentificationData(
display, [&](const auto& tmpError, const auto& tmpPort, const auto& tmpData) {
if (tmpError == Error::UNSUPPORTED) {
supported = false;
return;
}
ASSERT_EQ(Error::NONE, tmpError) << "failed to get display identification data";
*outPort = tmpPort;
*outData = tmpData;
ASSERT_FALSE(outData->empty()) << "data is empty";
});
return supported;
}
} // namespace vts
} // namespace V2_3
} // namespace composer
} // namespace graphics
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,74 @@
/*
* Copyright (C) 2018 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.
*/
#pragma once
#include <memory>
#include <vector>
#include <VtsHalHidlTargetTestBase.h>
#include <android/hardware/graphics/composer/2.3/IComposer.h>
#include <android/hardware/graphics/composer/2.3/IComposerClient.h>
#include <composer-vts/2.2/ComposerVts.h>
#include <utils/StrongPointer.h>
namespace android {
namespace hardware {
namespace graphics {
namespace composer {
namespace V2_3 {
namespace vts {
using V2_1::Display;
using V2_3::IComposer;
using V2_3::IComposerClient;
class ComposerClient;
// A wrapper to IComposer.
class Composer : public V2_2::vts::Composer {
public:
Composer();
explicit Composer(const std::string& name);
std::unique_ptr<ComposerClient> createClient();
protected:
explicit Composer(const sp<IComposer>& composer);
private:
const sp<IComposer> mComposer;
};
// A wrapper to IComposerClient.
class ComposerClient : public V2_2::vts::ComposerClient {
public:
explicit ComposerClient(const sp<IComposerClient>& client)
: V2_2::vts::ComposerClient(client), mClient(client) {}
bool getDisplayIdentificationData(Display display, uint8_t* outPort,
std::vector<uint8_t>* outData);
private:
const sp<IComposerClient> mClient;
};
} // namespace vts
} // namespace V2_3
} // namespace composer
} // namespace graphics
} // namespace hardware
} // namespace android

View File

@@ -0,0 +1,44 @@
//
// Copyright (C) 2018 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: "VtsHalGraphicsComposerV2_3TargetTest",
defaults: ["VtsHalTargetTestDefaults"],
srcs: ["VtsHalGraphicsComposerV2_3TargetTest.cpp"],
// TODO(b/64437680): Assume these libs are always available on the device.
shared_libs: [
"libfmq",
"libhidltransport",
"libsync",
],
static_libs: [
"android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.composer@2.1",
"android.hardware.graphics.composer@2.1-vts",
"android.hardware.graphics.composer@2.2",
"android.hardware.graphics.composer@2.2-vts",
"android.hardware.graphics.composer@2.3",
"android.hardware.graphics.composer@2.3-vts",
"android.hardware.graphics.mapper@2.0",
"android.hardware.graphics.mapper@2.0-vts",
"android.hardware.graphics.mapper@2.1",
],
header_libs: [
"android.hardware.graphics.composer@2.1-command-buffer",
"android.hardware.graphics.composer@2.2-command-buffer",
],
}

View File

@@ -0,0 +1,7 @@
# Graphics team
olv@google.com
stoza@google.com
# VTS team
yim@google.com
zhuoyao@google.com

View File

@@ -0,0 +1,133 @@
/*
* Copyright (C) 2018 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 "graphics_composer_hidl_hal_test@2.3"
#include <algorithm>
#include <VtsHalHidlTargetTestBase.h>
#include <android-base/logging.h>
#include <composer-vts/2.1/GraphicsComposerCallback.h>
#include <composer-vts/2.3/ComposerVts.h>
namespace android {
namespace hardware {
namespace graphics {
namespace composer {
namespace V2_3 {
namespace vts {
namespace {
// Test environment for graphics.composer
class GraphicsComposerHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
public:
// get the test environment singleton
static GraphicsComposerHidlEnvironment* Instance() {
static GraphicsComposerHidlEnvironment* instance = new GraphicsComposerHidlEnvironment;
return instance;
}
virtual void registerTestServices() override { registerTestService<IComposer>(); }
private:
GraphicsComposerHidlEnvironment() {}
GTEST_DISALLOW_COPY_AND_ASSIGN_(GraphicsComposerHidlEnvironment);
};
class GraphicsComposerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
protected:
void SetUp() override {
ASSERT_NO_FATAL_FAILURE(
mComposer = std::make_unique<Composer>(
GraphicsComposerHidlEnvironment::Instance()->getServiceName<IComposer>()));
ASSERT_NO_FATAL_FAILURE(mComposerClient = mComposer->createClient());
mComposerCallback = new V2_1::vts::GraphicsComposerCallback;
mComposerClient->registerCallback(mComposerCallback);
// assume the first display is primary and is never removed
mPrimaryDisplay = waitForFirstDisplay();
// explicitly disable vsync
mComposerClient->setVsyncEnabled(mPrimaryDisplay, false);
mComposerCallback->setVsyncAllowed(false);
}
void TearDown() override {
if (mComposerCallback != nullptr) {
EXPECT_EQ(0, mComposerCallback->getInvalidHotplugCount());
EXPECT_EQ(0, mComposerCallback->getInvalidRefreshCount());
EXPECT_EQ(0, mComposerCallback->getInvalidVsyncCount());
}
}
std::unique_ptr<Composer> mComposer;
std::unique_ptr<ComposerClient> mComposerClient;
sp<V2_1::vts::GraphicsComposerCallback> mComposerCallback;
// the first display and is assumed never to be removed
Display mPrimaryDisplay;
private:
Display waitForFirstDisplay() {
while (true) {
std::vector<Display> displays = mComposerCallback->getDisplays();
if (displays.empty()) {
usleep(5 * 1000);
continue;
}
return displays[0];
}
}
};
/**
* Test IComposerClient::getDisplayIdentificationData.
*
* TODO: Check that ports are unique for multiple displays.
*/
TEST_F(GraphicsComposerHidlTest, GetDisplayIdentificationData) {
uint8_t port0;
std::vector<uint8_t> data0;
if (mComposerClient->getDisplayIdentificationData(mPrimaryDisplay, &port0, &data0)) {
uint8_t port1;
std::vector<uint8_t> data1;
ASSERT_TRUE(mComposerClient->getDisplayIdentificationData(mPrimaryDisplay, &port1, &data1));
ASSERT_EQ(port0, port1) << "ports are not stable";
ASSERT_TRUE(data0.size() == data1.size() &&
std::equal(data0.begin(), data0.end(), data1.begin()))
<< "data is not stable";
}
}
} // namespace
} // namespace vts
} // namespace V2_3
} // namespace composer
} // namespace graphics
} // namespace hardware
} // namespace android
int main(int argc, char** argv) {
using android::hardware::graphics::composer::V2_3::vts::GraphicsComposerHidlEnvironment;
::testing::AddGlobalTestEnvironment(GraphicsComposerHidlEnvironment::Instance());
::testing::InitGoogleTest(&argc, argv);
GraphicsComposerHidlEnvironment::Instance()->init(&argc, argv);
int status = RUN_ALL_TESTS();
return status;
}