Commit ea1c5e5a authored by Alexandru Gheorghe's avatar Alexandru Gheorghe
Browse files

drm_hwcomposer: Add z order support



Currently, the planner just pops the first available drm plane and if
that can't be used for the DrmHwcLayer it just returns error.

This proposes a slighlty smarter way to do that by trying to see if
any of the DrmPlane can be used for the DrmHwcLayer in question.

More, if the drm_plane doesn't have a fix zorder then we could re-add
him to the list of unused planes, so it could be used for hosting
other less demanding DrmHwcLayers.
Signed-off-by: Alexandru Gheorghe's avatarAlexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
parent 2234d377
Pipeline #5564 passed with stage
in 40 seconds
......@@ -359,6 +359,17 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp,
}
}
if (plane->zpos_property().id() && !plane->zpos_property().immutable()) {
ret = drmModeAtomicAddProperty(pset, plane->id(),
plane->zpos_property().id(),
source_layers.front()) < 0;
if (ret) {
ALOGE("Failed to add zpos property %d to plane %d",
plane->zpos_property().id(), plane->id());
break;
}
}
rotation = 0;
if (layer.transform & DrmHwcTransform::kFlipH)
rotation |= DRM_MODE_REFLECT_X;
......
......@@ -118,6 +118,10 @@ int DrmPlane::Init() {
return ret;
}
ret = drm_->GetPlaneProperty(*this, "zpos", &zpos_property_);
if (ret)
ALOGE("Could not get zpos property for plane %u", id());
ret = drm_->GetPlaneProperty(*this, "rotation", &rotation_property_);
if (ret)
ALOGE("Could not get rotation property");
......@@ -189,6 +193,10 @@ const DrmProperty &DrmPlane::src_h_property() const {
return src_h_property_;
}
const DrmProperty &DrmPlane::zpos_property() const {
return zpos_property_;
}
const DrmProperty &DrmPlane::rotation_property() const {
return rotation_property_;
}
......
......@@ -52,6 +52,7 @@ class DrmPlane {
const DrmProperty &src_y_property() const;
const DrmProperty &src_w_property() const;
const DrmProperty &src_h_property() const;
const DrmProperty &zpos_property() const;
const DrmProperty &rotation_property() const;
const DrmProperty &alpha_property() const;
const DrmProperty &blend_property() const;
......@@ -75,6 +76,7 @@ class DrmPlane {
DrmProperty src_y_property_;
DrmProperty src_w_property_;
DrmProperty src_h_property_;
DrmProperty zpos_property_;
DrmProperty rotation_property_;
DrmProperty alpha_property_;
DrmProperty blend_property_;
......
......@@ -100,6 +100,10 @@ int DrmProperty::value(uint64_t *value) const {
}
}
bool DrmProperty::immutable() const {
return id_ && (flags_ & DRM_MODE_PROP_IMMUTABLE);
}
std::tuple<uint64_t, int> DrmProperty::GetEnumValueWithName(
std::string name) const {
for (auto it : enums_) {
......
......@@ -46,6 +46,7 @@ class DrmProperty {
std::string name() const;
int value(uint64_t *value) const;
bool immutable() const;
private:
class DrmPropertyEnum {
......
......@@ -81,16 +81,24 @@ class Planner {
DrmCompositionPlane::Type type, DrmCrtc *crtc,
std::pair<size_t, DrmHwcLayer *> layer) {
DrmPlane *plane = PopPlane(planes);
int ret;
if (!plane)
return -ENOENT;
ret = ValidatePlane(plane, layer.second);
if (ret)
return -EINVAL;
composition->emplace_back(type, plane, crtc, layer.first);
return 0;
std::vector<DrmPlane *> unused_planes;
int ret = -ENOENT;
while (plane) {
ret = ValidatePlane(plane, layer.second);
if (!ret)
break;
if (!plane->zpos_property().immutable())
unused_planes.push_back(plane);
plane = PopPlane(planes);
}
if (!ret) {
composition->emplace_back(type, plane, crtc, layer.first);
planes->insert(planes->begin(), unused_planes.begin(),
unused_planes.end());
}
return ret;
}
};
......
Markdown is supported
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