Commit 8330c920 authored by Matvii Zorin's avatar Matvii Zorin
Browse files
parent ec75ccd0
Pipeline #182598 failed with stage
in 23 seconds
......@@ -94,6 +94,10 @@ cc_library_static {
"utils/autolock.cpp",
"utils/hwcutils.cpp",
"backend/backend.cpp",
"backend/backendgeneric.cpp",
"backend/backendrcardu.cpp",
],
}
......
#define LOG_TAG "hwc-backend"
#include "backend.h"
#include "drmhwctwo.h"
#include <log/log.h>
namespace android {
std::unique_ptr<Backend> Backend::backend = nullptr;
Backend::Backend() {
validator = nullptr;
}
int Backend::Register(const std::string &name, validator_t validator) {
if (!backend) {
backend.reset(new Backend());
}
backend->validators[name] = validator;
ALOGE("Register %s", name.c_str());
return 0;
}
HWC2::Error Backend::SetValidator(const std::string &name) {
validator_t validator = nullptr;
if (!backend) {
ALOGE("No validators are specified");
return HWC2::Error::Unsupported;
}
validator = backend->validators[name];
ALOGE("Register name = %s", name.c_str());
if (!validator) {
validator = backend->validators["generic"];
ALOGE("Register generic, name = %s", name.c_str());
}
backend->validator = validator;
return HWC2::Error::None;
}
HWC2::Error Backend::ValidateDisplay(DrmHwcTwo::HwcDisplay *display, uint32_t *num_types, uint32_t *num_requests) {
if (!backend || !backend->validator) {
ALOGE("Validator is not specified");
return HWC2::Error::Unsupported;
}
return backend->validator(display, num_types, num_requests);
}
} // namespace android
#include "backend.h"
#include "drmhwctwo.h"
namespace android {
HWC2::Error GenericValidator(DrmHwcTwo::HwcDisplay *display, uint32_t *num_types, uint32_t *num_requests) {
return display->ValidateDisplayGeneric(num_types, num_requests);
}
static int backend = Backend::Register("generic", &GenericValidator);
} // namespace android
#include "backend.h"
#include "drmhwctwo.h"
namespace android {
HWC2::Error RCarDuValidator(DrmHwcTwo::HwcDisplay *display, uint32_t *num_types, uint32_t *num_requests) {
return display->ValidateDisplayGeneric(num_types, num_requests);
}
static int backend = Backend::Register("rcar-du", &RCarDuValidator);
} // namespace android
#include "backend.h"
#include "drmhwctwo.h"
namespace android {
HWC2::Error SunXiValidator(DrmHwcTwo::HwcDisplay *display, uint32_t *num_types, uint32_t *num_requests) {
return display->ValidateDisplayGeneric(num_types, num_requests);
}
static int backend = Backend::Register("sun-xi", &SunXiValidator);
} // namespace android
......@@ -17,11 +17,13 @@
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#define LOG_TAG "hwc-drm-two"
#include "backend.h"
#include "drmhwctwo.h"
#include "drmdisplaycomposition.h"
#include "drmhwcomposer.h"
#include "platform.h"
#include "vsyncworker.h"
#include "xf86drm.h"
#include <inttypes.h>
#include <string>
......@@ -103,6 +105,18 @@ HWC2::Error DrmHwcTwo::Init() {
for (auto &device : drmDevices) {
device->RegisterHotplugHandler(new DrmHotplugHandler(this, device.get()));
}
auto ver = drmGetVersion(drmDevices.front()->fd());
std::string name = ver ? ver->name : "generic";
drmFreeVersion(ver);
ret = Backend::SetValidator(name);
if (ret != HWC2::Error::None) {
ALOGE("Failed to set validator for module %s with error %d", ver->name, ret);
}
return ret;
}
......@@ -898,6 +912,12 @@ void DrmHwcTwo::HwcDisplay::MarkValidated(
HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
uint32_t *num_requests) {
return Backend::ValidateDisplay(this, num_types, num_requests);
}
HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplayGeneric(uint32_t *num_types,
uint32_t *num_requests) {
supported(__func__);
*num_types = 0;
*num_requests = 0;
......
#ifndef ANDROID_BACKEND_H
#define ANDROID_BACKEND_H
#include "drmhwctwo.h"
#include <functional>
#include <string>
#include <map>
namespace android {
class Backend {
public:
typedef std::function<HWC2::Error(DrmHwcTwo::HwcDisplay *, uint32_t *, uint32_t *)> validator_t;
static int Register(const std::string &name, validator_t validator);
static HWC2::Error ValidateDisplay(DrmHwcTwo::HwcDisplay *display, uint32_t *num_types, uint32_t *num_requests);
static HWC2::Error SetValidator(const std::string &name);
private:
Backend();
static std::unique_ptr<Backend> backend;
validator_t validator;
std::map<std::string, validator_t> validators;
};
} // namespace android
#endif
......@@ -14,6 +14,9 @@
* limitations under the License.
*/
#ifndef ANDROID_DRM_HWC_TWO_H_
#define ANDROID_DRM_HWC_TWO_H_
#include "drmdisplaycompositor.h"
#include "drmhwcomposer.h"
#include "platform.h"
......@@ -37,7 +40,6 @@ class DrmHwcTwo : public hwc2_device_t {
HWC2::Error Init();
private:
class HwcLayer {
public:
HWC2::Composition sf_type() const {
......@@ -222,6 +224,7 @@ class DrmHwcTwo : public hwc2_device_t {
HWC2::Error SetPowerMode(int32_t mode);
HWC2::Error SetVsyncEnabled(int32_t enabled);
HWC2::Error ValidateDisplay(uint32_t *num_types, uint32_t *num_requests);
HWC2::Error ValidateDisplayGeneric(uint32_t *num_types, uint32_t *num_requests);
HwcLayer *get_layer(hwc2_layer_t layer) {
auto it = layers_.find(layer);
if (it == layers_.end())
......@@ -296,6 +299,7 @@ class DrmHwcTwo : public hwc2_device_t {
DrmDevice *drm_;
};
private:
static DrmHwcTwo *toDrmHwcTwo(hwc2_device_t *dev) {
return static_cast<DrmHwcTwo *>(dev);
}
......@@ -370,3 +374,5 @@ class DrmHwcTwo : public hwc2_device_t {
std::string mDumpString;
};
} // namespace android
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment