1
0
Fork 0

Create DrmDisplayPipeline through BackendManager

Additionally, move the creation of the Backend into BackendManager so
that it the Backend is created along with the DrmDisplayPipeline

Change-Id: I24dc19cadb324429f229fe7751b60b70ab512265
This commit is contained in:
Drew Davenport 2025-10-21 20:12:10 -06:00
parent 043be2b9e3
commit 0f5244ef78
4 changed files with 28 additions and 15 deletions

View file

@ -43,9 +43,21 @@ int BackendManager::RegisterBackend(const std::string &name,
return 0; return 0;
} }
std::unique_ptr<DrmDisplayPipeline> BackendManager::CreatePipelineForConnector(
DrmConnector &connector) {
auto pipeline = DrmDisplayPipeline::CreatePipeline(connector);
if (pipeline) {
pipeline->backend = CreateBackendForConnector(connector);
}
if (!pipeline || !pipeline->backend) {
return nullptr;
}
return pipeline;
}
std::unique_ptr<Backend> BackendManager::CreateBackendForConnector( std::unique_ptr<Backend> BackendManager::CreateBackendForConnector(
const DrmConnector *connector) { const DrmConnector &connector) {
auto driver_name(connector->GetDev().GetName()); auto driver_name(connector.GetDev().GetName());
std::string backend_name = Properties::GetBackendOverride(); std::string backend_name = Properties::GetBackendOverride();
if (backend_name.empty()) { if (backend_name.empty()) {
backend_name = driver_name; backend_name = driver_name;
@ -54,14 +66,13 @@ std::unique_ptr<Backend> BackendManager::CreateBackendForConnector(
auto backend = GetBackendByName(backend_name); auto backend = GetBackendByName(backend_name);
if (backend == nullptr) { if (backend == nullptr) {
ALOGE("Failed to create backend '%s' for '%s' and driver '%s'", ALOGE("Failed to create backend '%s' for '%s' and driver '%s'",
backend_name.c_str(), connector->GetName().c_str(), backend_name.c_str(), connector.GetName().c_str(),
driver_name.c_str()); driver_name.c_str());
return nullptr; return nullptr;
} }
ALOGI("Backend '%s' for '%s' and driver '%s' was successfully created", ALOGI("Backend '%s' for '%s' and driver '%s' was successfully created",
backend_name.c_str(), connector->GetName().c_str(), backend_name.c_str(), connector.GetName().c_str(), driver_name.c_str());
driver_name.c_str());
return backend; return backend;
} }

View file

@ -40,10 +40,14 @@ class BackendManager {
static BackendManager &GetInstance(); static BackendManager &GetInstance();
int RegisterBackend(const std::string &name, int RegisterBackend(const std::string &name,
BackendConstructorT backend_constructor); BackendConstructorT backend_constructor);
std::unique_ptr<Backend> CreateBackendForConnector(
const DrmConnector *connector); std::unique_ptr<DrmDisplayPipeline> CreatePipelineForConnector(
DrmConnector &connector);
private: private:
std::unique_ptr<Backend> CreateBackendForConnector(
const DrmConnector &connector);
std::unique_ptr<Backend> GetBackendByName(std::string &name); std::unique_ptr<Backend> GetBackendByName(std::string &name);
BackendManager() = default; BackendManager() = default;

View file

@ -24,7 +24,6 @@
#include <sstream> #include <sstream>
#include <utility> #include <utility>
#include "backend/BackendManager.h"
#include "stats/CompositionStats.h" #include "stats/CompositionStats.h"
#include "utils/log.h" #include "utils/log.h"
#include "utils/properties.h" #include "utils/properties.h"
@ -129,8 +128,6 @@ bool DrmHwc::BindDisplay(std::shared_ptr<DrmDisplayPipeline> pipeline) {
pipeline->connector->Get()->GetName().c_str(), (int)disp_handle, pipeline->connector->Get()->GetName().c_str(), (int)disp_handle,
disp_handle == kPrimaryDisplay ? " (Primary)" : ""); disp_handle == kPrimaryDisplay ? " (Primary)" : "");
pipeline->backend = BackendManager::GetInstance().CreateBackendForConnector(
pipeline->connector->Get());
displays_[disp_handle]->SetPipeline(pipeline); displays_[disp_handle]->SetPipeline(pipeline);
display_handles_[pipeline] = disp_handle; display_handles_[pipeline] = disp_handle;
@ -185,9 +182,6 @@ std::optional<DisplayHandle> DrmHwc::CreateVirtualDisplay(uint32_t width,
/* is_virtual */ true, this); /* is_virtual */ true, this);
disp->SetVirtualDisplayResolution(width, height); disp->SetVirtualDisplayResolution(width, height);
virtual_pipeline->backend = BackendManager::GetInstance()
.CreateBackendForConnector(
virtual_pipeline->connector->Get());
disp->SetPipeline(virtual_pipeline); disp->SetPipeline(virtual_pipeline);
displays_[new_display_handle] = std::move(disp); displays_[new_display_handle] = std::move(disp);
return new_display_handle; return new_display_handle;

View file

@ -24,6 +24,7 @@
#include <ctime> #include <ctime>
#include <sstream> #include <sstream>
#include "backend/BackendManager.h"
#include "bufferinfo/BufferInfoGetter.h" #include "bufferinfo/BufferInfoGetter.h"
#include "drm/DrmAtomicStateManager.h" #include "drm/DrmAtomicStateManager.h"
#include "drm/DrmDevice.h" #include "drm/DrmDevice.h"
@ -147,8 +148,11 @@ void ResourceManager::UpdateFrontendDisplays() {
if (connected) { if (connected) {
std::shared_ptr<DrmDisplayPipeline> std::shared_ptr<DrmDisplayPipeline>
pipeline = DrmDisplayPipeline::CreatePipeline(*conn); pipeline = BackendManager::GetInstance().CreatePipelineForConnector(
*conn);
ALOGE_IF(pipeline == nullptr,
"Failed to create pipeline for connector %s",
conn->GetName().c_str());
if (pipeline) { if (pipeline) {
frontend_interface_->BindDisplay(pipeline); frontend_interface_->BindDisplay(pipeline);
attached_pipelines_[conn] = std::move(pipeline); attached_pipelines_[conn] = std::move(pipeline);