Add graphics composer support for HWC > HWC1.1
Test: Ryu, Marlin Change-Id: I58a7394f427534b942d64c93b1891a756c5f510c
This commit is contained in:
parent
f8654facce
commit
0d55a21044
3 changed files with 44 additions and 6 deletions
|
@ -37,6 +37,7 @@ cc_library_shared {
|
|||
"liblog",
|
||||
"libsync",
|
||||
"libutils",
|
||||
"libhwc2on1adapter"
|
||||
],
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "ComposerClient.h"
|
||||
#include "Hwc.h"
|
||||
#include "hardware/hwcomposer.h"
|
||||
#include "hwc2on1adapter/HWC2On1Adapter.h"
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
|
@ -30,13 +32,36 @@ namespace composer {
|
|||
namespace V2_1 {
|
||||
namespace implementation {
|
||||
|
||||
|
||||
HwcHal::HwcHal(const hw_module_t* module)
|
||||
: mDevice(nullptr), mDispatch()
|
||||
: mDevice(nullptr), mDispatch(), mAdapter()
|
||||
{
|
||||
int status = hwc2_open(module, &mDevice);
|
||||
if (status) {
|
||||
LOG_ALWAYS_FATAL("failed to open hwcomposer2 device: %s",
|
||||
strerror(-status));
|
||||
// Determine what kind of module is available (HWC2 vs HWC1.X).
|
||||
hw_device_t* device = nullptr;
|
||||
int error = module->methods->open(module, HWC_HARDWARE_COMPOSER, &device);
|
||||
if (error != 0) {
|
||||
ALOGE("Failed to open HWC device (%s), aborting", strerror(-error));
|
||||
abort();
|
||||
}
|
||||
uint32_t majorVersion = (device->version >> 24) & 0xF;
|
||||
|
||||
// If we don't have a HWC2, we need to wrap whatever we have in an adapter.
|
||||
if (majorVersion != 2) {
|
||||
uint32_t minorVersion = device->version & HARDWARE_API_VERSION_2_MAJ_MIN_MASK;
|
||||
minorVersion = (minorVersion >> 16) & 0xF;
|
||||
ALOGI("Found HWC implementation v%d.%d", majorVersion, minorVersion);
|
||||
if (minorVersion < 1) {
|
||||
ALOGE("Cannot adapt to HWC version %d.%d. Minimum supported is 1.1",
|
||||
majorVersion, minorVersion);
|
||||
abort();
|
||||
}
|
||||
mAdapter = std::make_unique<HWC2On1Adapter>(
|
||||
reinterpret_cast<hwc_composer_device_1*>(device));
|
||||
|
||||
// Place the adapter in front of the device module.
|
||||
mDevice = mAdapter.get();
|
||||
} else {
|
||||
mDevice = reinterpret_cast<hwc2_device_t*>(device);
|
||||
}
|
||||
|
||||
initCapabilities();
|
||||
|
|
|
@ -18,14 +18,22 @@
|
|||
#define ANDROID_HARDWARE_GRAPHICS_COMPOSER_V2_1_HWC_H
|
||||
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#include <android/hardware/graphics/composer/2.1/IComposer.h>
|
||||
#define HWC2_INCLUDE_STRINGIFICATION
|
||||
#define HWC2_USE_CPP11
|
||||
#include <hardware/hwcomposer2.h>
|
||||
|
||||
#undef HWC2_INCLUDE_STRINGIFICATION
|
||||
#undef HWC2_USE_CPP11
|
||||
#include "ComposerBase.h"
|
||||
|
||||
namespace android {
|
||||
class HWC2On1Adapter;
|
||||
}
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace graphics {
|
||||
|
@ -204,6 +212,10 @@ private:
|
|||
|
||||
std::mutex mClientMutex;
|
||||
wp<ComposerClient> mClient;
|
||||
|
||||
// If the HWC implementation version is < 2.0, use an adapter to interface
|
||||
// between HWC 2.0 <-> HWC 1.X.
|
||||
std::unique_ptr<HWC2On1Adapter> mAdapter;
|
||||
};
|
||||
|
||||
extern "C" IComposer* HIDL_FETCH_IComposer(const char* name);
|
||||
|
|
Loading…
Reference in a new issue