Implement backend-dependent validation (and later provisioning)
I am holding this idea in my head for a couple of month, but it looks like it can help to solve several unmerged MRs (!95 (merged) !107 (closed) ) in a generic way, so it's time to share:
Problem:
Different DRM/KMS backends have different set of limitation, which is not always exposes via DRM ioctls.
For example:
rcar-du: No scaling support, AB24 mode is unsupported.
sun4i-drm: Layer order matters. Limitations on HW scaling resolution. But currently unusable due to bugs.
Suggested implementation:
Add backend-specific validation function:
backend/rcar-du.cpp:
static ret_type rcar_du_validate() {
// Filter-out unsupported layers (mark client)
return generic_validate();
}
REGISTER_BACKEND(rcar_du_validate, "rcar-du");
backend/generic.cpp:
static ret_type generic_validate() {
// Current ValidateDisplay() logic here
}
REGISTER_BACKEND(generic_validate, "generic");
backend/client.cpp:
static ret_type validate_to_client() {
// Mark all as client and return
}
REGISTER_BACKEND(validate_to_client, "client");
resources.cpp:
ret_type (*validator)()
Init() {
...
// 1. Open KMS device, read driver name.
// 2. Read property "hwc.backend_override", fallback to current KMS name by default
// 3. Find backend among registered using name property.
// 4. If nothing found, select "generic"
// 5. Set (*validator) variable
}
drmhwc.cpp:
HWC::ValidateDisplay() {
return resources->validator(); // Invoke a selected validator
}