sdm: Remove null commits used for obtaining topology

Driver exports per mode topology and panel params which obviates
the need for null commits after crtc->connector chain setup or
mode switch. Remove null commits for all display types.

Revert "sdm: Fix topology after adding new mode"
This reverts commit 5014f0eb03.

Change-Id: Ib68c5b2e2ff475250b7251822515e51fb7b31869
CRs-fixed: 2138173
This commit is contained in:
Saurabh Shah
2017-11-03 17:55:36 -07:00
parent 28f871daba
commit 7e16c93421
9 changed files with 149 additions and 225 deletions

View File

@@ -443,22 +443,10 @@ enum struct DRMPanelMode {
COMMAND, COMMAND,
}; };
/* Per Connector Info*/ /* Per mode info */
struct DRMConnectorInfo { struct DRMModeInfo {
uint32_t mmWidth; drmModeModeInfo mode;
uint32_t mmHeight;
uint32_t type;
std::vector<drmModeModeInfo> modes;
DRMTopology topology; DRMTopology topology;
std::string panel_name;
DRMPanelMode panel_mode;
bool is_primary;
// Valid only if DRMPanelMode is VIDEO
bool dynamic_fps;
// FourCC format enum and modifier
std::vector<std::pair<uint32_t, uint64_t>> formats_supported;
// Valid only if type is DRM_MODE_CONNECTOR_VIRTUAL
uint32_t max_linewidth;
// Valid only if mode is command // Valid only if mode is command
int num_roi; int num_roi;
int xstart; int xstart;
@@ -468,6 +456,23 @@ struct DRMConnectorInfo {
int wmin; int wmin;
int hmin; int hmin;
bool roi_merge; bool roi_merge;
};
/* Per Connector Info*/
struct DRMConnectorInfo {
uint32_t mmWidth;
uint32_t mmHeight;
uint32_t type;
std::vector<DRMModeInfo> modes;
std::string panel_name;
DRMPanelMode panel_mode;
bool is_primary;
// Valid only if DRMPanelMode is VIDEO
bool dynamic_fps;
// FourCC format enum and modifier
std::vector<std::pair<uint32_t, uint64_t>> formats_supported;
// Valid only if type is DRM_MODE_CONNECTOR_VIRTUAL
uint32_t max_linewidth;
DRMRotation panel_orientation; DRMRotation panel_orientation;
drm_panel_hdr_properties panel_hdr_prop; drm_panel_hdr_properties panel_hdr_prop;
uint32_t transfer_time_us; uint32_t transfer_time_us;

View File

@@ -333,29 +333,29 @@ HWDeviceDRM::HWDeviceDRM(BufferSyncHandler *buffer_sync_handler, BufferAllocator
} }
DisplayError HWDeviceDRM::Init() { DisplayError HWDeviceDRM::Init() {
default_mode_ = (DRMLibLoader::GetInstance()->IsLoaded() == false);
if (!default_mode_) {
DRMMaster *drm_master = {}; DRMMaster *drm_master = {};
DRMMaster::GetInstance(&drm_master); DRMMaster::GetInstance(&drm_master);
drm_master->GetHandle(&dev_fd_); drm_master->GetHandle(&dev_fd_);
DRMLibLoader::GetInstance()->FuncGetDRMManager()(dev_fd_, &drm_mgr_intf_); DRMLibLoader::GetInstance()->FuncGetDRMManager()(dev_fd_, &drm_mgr_intf_);
if (drm_mgr_intf_->RegisterDisplay(disp_type_, &token_)) { if (drm_mgr_intf_->RegisterDisplay(disp_type_, &token_)) {
DLOGE("RegisterDisplay failed for %s", device_name_); DLOGE("RegisterDisplay failed for %s", device_name_);
return kErrorResources; return kErrorResources;
} }
drm_mgr_intf_->CreateAtomicReq(token_, &drm_atomic_intf_); drm_mgr_intf_->CreateAtomicReq(token_, &drm_atomic_intf_);
} else { drm_mgr_intf_->GetConnectorInfo(token_.conn_id, &connector_info_);
display_attributes_.push_back(HWDisplayAttributes());
PopulateDisplayAttributes(current_mode_index_);
}
hw_info_intf_->GetHWResourceInfo(&hw_resource_); hw_info_intf_->GetHWResourceInfo(&hw_resource_);
InitializeConfigs();
PopulateHWPanelInfo();
UpdateMixerAttributes();
// TODO(user): In future, remove has_qseed3 member, add version and pass version to constructor // TODO(user): In future, remove has_qseed3 member, add version and pass version to constructor
if (hw_resource_.has_qseed3) { if (hw_resource_.has_qseed3) {
hw_scale_ = new HWScaleDRM(HWScaleDRM::Version::V2); hw_scale_ = new HWScaleDRM(HWScaleDRM::Version::V2);
} }
return kErrorNone; return kErrorNone;
} }
@@ -384,7 +384,7 @@ void HWDeviceDRM::InitializeConfigs() {
current_mode_index_ = 0; current_mode_index_ = 0;
// Update current mode with preferred mode // Update current mode with preferred mode
for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) { for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) {
if (connector_info_.modes[mode_index].type & DRM_MODE_TYPE_PREFERRED) { if (connector_info_.modes[mode_index].mode.type & DRM_MODE_TYPE_PREFERRED) {
current_mode_index_ = mode_index; current_mode_index_ = mode_index;
break; break;
} }
@@ -392,10 +392,10 @@ void HWDeviceDRM::InitializeConfigs() {
display_attributes_.resize(connector_info_.modes.size()); display_attributes_.resize(connector_info_.modes.size());
uint32_t width = connector_info_.modes[current_mode_index_].hdisplay; uint32_t width = connector_info_.modes[current_mode_index_].mode.hdisplay;
uint32_t height = connector_info_.modes[current_mode_index_].vdisplay; uint32_t height = connector_info_.modes[current_mode_index_].mode.vdisplay;
for (uint32_t i = 0; i < connector_info_.modes.size(); i++) { for (uint32_t i = 0; i < connector_info_.modes.size(); i++) {
auto &mode = connector_info_.modes[i]; auto &mode = connector_info_.modes[i].mode;
if (mode.hdisplay != width || mode.vdisplay != height) { if (mode.hdisplay != width || mode.vdisplay != height) {
resolution_switch_enabled_ = true; resolution_switch_enabled_ = true;
} }
@@ -420,10 +420,10 @@ DisplayError HWDeviceDRM::PopulateDisplayAttributes(uint32_t index) {
res_mgr->GetMode(&mode); res_mgr->GetMode(&mode);
res_mgr->GetDisplayDimInMM(&mm_width, &mm_height); res_mgr->GetDisplayDimInMM(&mm_width, &mm_height);
} else { } else {
mode = connector_info_.modes[index]; mode = connector_info_.modes[index].mode;
mm_width = connector_info_.mmWidth; mm_width = connector_info_.mmWidth;
mm_height = connector_info_.mmHeight; mm_height = connector_info_.mmHeight;
topology = connector_info_.topology; topology = connector_info_.modes[index].topology;
} }
display_attributes_[index].x_pixels = mode.hdisplay; display_attributes_[index].x_pixels = mode.hdisplay;
@@ -490,29 +490,29 @@ void HWDeviceDRM::PopulateHWPanelInfo() {
display_attributes_[index].x_pixels / 2; display_attributes_[index].x_pixels / 2;
} }
hw_panel_info_.partial_update = connector_info_.num_roi; hw_panel_info_.partial_update = connector_info_.modes[index].num_roi;
hw_panel_info_.left_roi_count = UINT32(connector_info_.num_roi); hw_panel_info_.left_roi_count = UINT32(connector_info_.modes[index].num_roi);
hw_panel_info_.right_roi_count = UINT32(connector_info_.num_roi); hw_panel_info_.right_roi_count = UINT32(connector_info_.modes[index].num_roi);
hw_panel_info_.left_align = connector_info_.xstart; hw_panel_info_.left_align = connector_info_.modes[index].xstart;
hw_panel_info_.top_align = connector_info_.ystart; hw_panel_info_.top_align = connector_info_.modes[index].ystart;
hw_panel_info_.width_align = connector_info_.walign; hw_panel_info_.width_align = connector_info_.modes[index].walign;
hw_panel_info_.height_align = connector_info_.halign; hw_panel_info_.height_align = connector_info_.modes[index].halign;
hw_panel_info_.min_roi_width = connector_info_.wmin; hw_panel_info_.min_roi_width = connector_info_.modes[index].wmin;
hw_panel_info_.min_roi_height = connector_info_.hmin; hw_panel_info_.min_roi_height = connector_info_.modes[index].hmin;
hw_panel_info_.needs_roi_merge = connector_info_.roi_merge; hw_panel_info_.needs_roi_merge = connector_info_.modes[index].roi_merge;
hw_panel_info_.dynamic_fps = connector_info_.dynamic_fps; hw_panel_info_.dynamic_fps = connector_info_.dynamic_fps;
drmModeModeInfo current_mode = connector_info_.modes[current_mode_index_]; drmModeModeInfo current_mode = connector_info_.modes[current_mode_index_].mode;
if (hw_panel_info_.dynamic_fps) { if (hw_panel_info_.dynamic_fps) {
uint32_t min_fps = current_mode.vrefresh; uint32_t min_fps = current_mode.vrefresh;
uint32_t max_fps = current_mode.vrefresh; uint32_t max_fps = current_mode.vrefresh;
for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) { for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) {
if ((current_mode.vdisplay == connector_info_.modes[mode_index].vdisplay) && if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
(current_mode.hdisplay == connector_info_.modes[mode_index].hdisplay)) { (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay)) {
if (min_fps > connector_info_.modes[mode_index].vrefresh) { if (min_fps > connector_info_.modes[mode_index].mode.vrefresh) {
min_fps = connector_info_.modes[mode_index].vrefresh; min_fps = connector_info_.modes[mode_index].mode.vrefresh;
} }
if (max_fps < connector_info_.modes[mode_index].vrefresh) { if (max_fps < connector_info_.modes[mode_index].mode.vrefresh) {
max_fps = connector_info_.modes[mode_index].vrefresh; max_fps = connector_info_.modes[mode_index].mode.vrefresh;
} }
} }
} }
@@ -676,13 +676,21 @@ DisplayError HWDeviceDRM::SetDisplayAttributes(uint32_t index) {
DLOGE("Invalid mode index %d mode size %d", index, UINT32(display_attributes_.size())); DLOGE("Invalid mode index %d mode size %d", index, UINT32(display_attributes_.size()));
return kErrorParameters; return kErrorParameters;
} }
current_mode_index_ = index; current_mode_index_ = index;
// TODO(user): Topology/panel roi alignment information will be updated as a part of next commit
// which is too late for the requested mode that has different panel alignments. So driver needs
// to update panel/topology information for all modes during probe to reslove this issue.
PopulateHWPanelInfo(); PopulateHWPanelInfo();
UpdateMixerAttributes(); UpdateMixerAttributes();
switch_mode_ = true;
DLOGI("Display attributes[%d]: WxH: %dx%d, DPI: %fx%f, FPS: %d, LM_SPLIT: %d, V_BACK_PORCH: %d," \
" V_FRONT_PORCH: %d, V_PULSE_WIDTH: %d, V_TOTAL: %d, H_TOTAL: %d, CLK: %dKHZ, TOPOLOGY: %d",
index, display_attributes_[index].x_pixels, display_attributes_[index].y_pixels,
display_attributes_[index].x_dpi, display_attributes_[index].y_dpi,
display_attributes_[index].fps, display_attributes_[index].is_device_split,
display_attributes_[index].v_back_porch, display_attributes_[index].v_front_porch,
display_attributes_[index].v_pulse_width, display_attributes_[index].v_total,
display_attributes_[index].h_total, display_attributes_[index].clock_khz,
display_attributes_[index].topology);
return kErrorNone; return kErrorNone;
} }
@@ -701,6 +709,10 @@ DisplayError HWDeviceDRM::PowerOn() {
return kErrorUndefined; return kErrorUndefined;
} }
if (first_cycle_) {
return kErrorNone;
}
drm_atomic_intf_->Perform(DRMOps::CRTC_SET_ACTIVE, token_.crtc_id, 1); drm_atomic_intf_->Perform(DRMOps::CRTC_SET_ACTIVE, token_.crtc_id, 1);
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_POWER_MODE, token_.conn_id, DRMPowerMode::ON); drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_POWER_MODE, token_.conn_id, DRMPowerMode::ON);
int ret = drm_atomic_intf_->Commit(true /* synchronous */, true /* retain_planes */); int ret = drm_atomic_intf_->Commit(true /* synchronous */, true /* retain_planes */);
@@ -771,7 +783,7 @@ void HWDeviceDRM::SetupAtomic(HWLayers *hw_layers, bool validate) {
HWQosData &qos_data = hw_layers->qos_data; HWQosData &qos_data = hw_layers->qos_data;
DRMSecurityLevel crtc_security_level = DRMSecurityLevel::SECURE_NON_SECURE; DRMSecurityLevel crtc_security_level = DRMSecurityLevel::SECURE_NON_SECURE;
uint32_t index = current_mode_index_; uint32_t index = current_mode_index_;
drmModeModeInfo current_mode = connector_info_.modes[index]; drmModeModeInfo current_mode = connector_info_.modes[index].mode;
solid_fills_.clear(); solid_fills_.clear();
@@ -908,14 +920,20 @@ void HWDeviceDRM::SetupAtomic(HWLayers *hw_layers, bool validate) {
// Set refresh rate // Set refresh rate
if (vrefresh_) { if (vrefresh_) {
for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) { for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) {
if ((current_mode.vdisplay == connector_info_.modes[mode_index].vdisplay) && if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
(current_mode.hdisplay == connector_info_.modes[mode_index].hdisplay) && (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay) &&
(vrefresh_ == connector_info_.modes[mode_index].vrefresh)) { (vrefresh_ == connector_info_.modes[mode_index].mode.vrefresh)) {
current_mode = connector_info_.modes[mode_index]; current_mode = connector_info_.modes[mode_index].mode;
break; break;
} }
} }
} }
if (first_cycle_) {
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_CRTC, token_.conn_id, token_.crtc_id);
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_POWER_MODE, token_.conn_id, DRMPowerMode::ON);
}
drm_atomic_intf_->Perform(DRMOps::CRTC_SET_MODE, token_.crtc_id, &current_mode); drm_atomic_intf_->Perform(DRMOps::CRTC_SET_MODE, token_.crtc_id, &current_mode);
drm_atomic_intf_->Perform(DRMOps::CRTC_SET_ACTIVE, token_.crtc_id, 1); drm_atomic_intf_->Perform(DRMOps::CRTC_SET_ACTIVE, token_.crtc_id, 1);
@@ -1082,11 +1100,11 @@ DisplayError HWDeviceDRM::AtomicCommit(HWLayers *hw_layers) {
if (vrefresh_) { if (vrefresh_) {
// Update current mode index if refresh rate is changed // Update current mode index if refresh rate is changed
drmModeModeInfo current_mode = connector_info_.modes[current_mode_index_]; drmModeModeInfo current_mode = connector_info_.modes[current_mode_index_].mode;
for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) { for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) {
if ((current_mode.vdisplay == connector_info_.modes[mode_index].vdisplay) && if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
(current_mode.hdisplay == connector_info_.modes[mode_index].hdisplay) && (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay) &&
(vrefresh_ == connector_info_.modes[mode_index].vrefresh)) { (vrefresh_ == connector_info_.modes[mode_index].mode.vrefresh)) {
current_mode_index_ = mode_index; current_mode_index_ = mode_index;
break; break;
} }
@@ -1094,12 +1112,7 @@ DisplayError HWDeviceDRM::AtomicCommit(HWLayers *hw_layers) {
vrefresh_ = 0; vrefresh_ = 0;
} }
if (switch_mode_) { first_cycle_ = false;
// Reload connector info for updated info after 1st commit
drm_mgr_intf_->GetConnectorInfo(token_.conn_id, &connector_info_);
PopulateHWPanelInfo();
switch_mode_ = false;
}
return kErrorNone; return kErrorNone;
} }
@@ -1281,11 +1294,11 @@ DisplayError HWDeviceDRM::SetDisplayMode(const HWDisplayMode hw_display_mode) {
DisplayError HWDeviceDRM::SetRefreshRate(uint32_t refresh_rate) { DisplayError HWDeviceDRM::SetRefreshRate(uint32_t refresh_rate) {
// Check if requested refresh rate is valid // Check if requested refresh rate is valid
drmModeModeInfo current_mode = connector_info_.modes[current_mode_index_]; drmModeModeInfo current_mode = connector_info_.modes[current_mode_index_].mode;
for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) { for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) {
if ((current_mode.vdisplay == connector_info_.modes[mode_index].vdisplay) && if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
(current_mode.hdisplay == connector_info_.modes[mode_index].hdisplay) && (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay) &&
(refresh_rate == connector_info_.modes[mode_index].vrefresh)) { (refresh_rate == connector_info_.modes[mode_index].mode.vrefresh)) {
vrefresh_ = refresh_rate; vrefresh_ = refresh_rate;
DLOGV_IF(kTagDriverConfig, "Set refresh rate to %d", refresh_rate); DLOGV_IF(kTagDriverConfig, "Set refresh rate to %d", refresh_rate);
return kErrorNone; return kErrorNone;

View File

@@ -183,7 +183,6 @@ class HWDeviceDRM : public HWInterface {
std::vector<sde_drm::DRMSolidfillStage> solid_fills_ {}; std::vector<sde_drm::DRMSolidfillStage> solid_fills_ {};
bool resolution_switch_enabled_ = false; bool resolution_switch_enabled_ = false;
uint32_t vrefresh_ = 0; uint32_t vrefresh_ = 0;
bool switch_mode_ = false;
bool autorefresh_ = false; bool autorefresh_ = false;
}; };

View File

@@ -35,7 +35,6 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using sde_drm::DRMDisplayType; using sde_drm::DRMDisplayType;
using sde_drm::DRMOps; using sde_drm::DRMOps;
using sde_drm::DRMTopology;
using sde_drm::DRMPowerMode; using sde_drm::DRMPowerMode;
namespace sdm { namespace sdm {
@@ -57,41 +56,11 @@ DisplayError HWPeripheralDRM::Init() {
scalar_data_.resize(hw_resource_.hw_dest_scalar_info.count); scalar_data_.resize(hw_resource_.hw_dest_scalar_info.count);
drm_mgr_intf_->GetConnectorInfo(token_.conn_id, &connector_info_);
if (connector_info_.topology == DRMTopology::UNKNOWN) {
connector_info_.topology = DRMTopology::DUAL_LM;
if (connector_info_.modes[current_mode_index_].hdisplay <= 1080) {
connector_info_.topology = DRMTopology::SINGLE_LM;
}
}
InitializeConfigs();
PopulateHWPanelInfo();
UpdateMixerAttributes();
return kErrorNone; return kErrorNone;
} }
DisplayError HWPeripheralDRM::Validate(HWLayers *hw_layers) { DisplayError HWPeripheralDRM::Validate(HWLayers *hw_layers) {
// Hijack the first validate to setup pipeline. This is a stopgap solution
HWLayersInfo &hw_layer_info = hw_layers->info; HWLayersInfo &hw_layer_info = hw_layers->info;
if (first_cycle_) {
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_CRTC, token_.conn_id, token_.crtc_id);
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_POWER_MODE, token_.conn_id, DRMPowerMode::ON);
drm_atomic_intf_->Perform(DRMOps::CRTC_SET_MODE, token_.crtc_id,
&connector_info_.modes[current_mode_index_]);
drm_atomic_intf_->Perform(DRMOps::CRTC_SET_ACTIVE, token_.crtc_id, 1);
if (drm_atomic_intf_->Commit(true /* synchronous */, false /* retain pipes*/)) {
DLOGE("Setting up CRTC %d, Connector %d for %s failed",
token_.crtc_id, token_.conn_id, device_name_);
return kErrorResources;
}
// Reload connector info for updated info after 1st commit
drm_mgr_intf_->GetConnectorInfo(token_.conn_id, &connector_info_);
PopulateDisplayAttributes(current_mode_index_);
PopulateHWPanelInfo();
first_cycle_ = false;
}
SetDestScalarData(hw_layer_info); SetDestScalarData(hw_layer_info);
return HWDeviceDRM::Validate(hw_layers); return HWDeviceDRM::Validate(hw_layers);
@@ -104,14 +73,6 @@ DisplayError HWPeripheralDRM::Commit(HWLayers *hw_layers) {
return HWDeviceDRM::Commit(hw_layers); return HWDeviceDRM::Commit(hw_layers);
} }
DisplayError HWPeripheralDRM::PowerOn() {
if (first_cycle_) {
return kErrorNone;
}
return HWDeviceDRM::PowerOn();
}
void HWPeripheralDRM::ResetDisplayParams() { void HWPeripheralDRM::ResetDisplayParams() {
sde_dest_scalar_data_ = {}; sde_dest_scalar_data_ = {};
for (uint32_t j = 0; j < scalar_data_.size(); j++) { for (uint32_t j = 0; j < scalar_data_.size(); j++) {

View File

@@ -46,7 +46,6 @@ class HWPeripheralDRM : public HWDeviceDRM {
virtual DisplayError Init(); virtual DisplayError Init();
virtual DisplayError Validate(HWLayers *hw_layers); virtual DisplayError Validate(HWLayers *hw_layers);
virtual DisplayError Commit(HWLayers *hw_layers); virtual DisplayError Commit(HWLayers *hw_layers);
virtual DisplayError PowerOn();
virtual DisplayError Flush(); virtual DisplayError Flush();
private: private:
void SetDestScalarData(HWLayersInfo hw_layer_info); void SetDestScalarData(HWLayersInfo hw_layer_info);

View File

@@ -67,54 +67,26 @@ HWTVDRM::HWTVDRM(BufferSyncHandler *buffer_sync_handler, BufferAllocator *buffer
device_name_ = "TV Display Device"; device_name_ = "TV Display Device";
} }
DisplayError HWTVDRM::Init() {
DisplayError error = HWDeviceDRM::Init();
if (error != kErrorNone) {
DLOGE("Init failed for %s", device_name_);
return error;
}
drm_mgr_intf_->GetConnectorInfo(token_.conn_id, &connector_info_);
InitializeConfigs();
return error;
}
DisplayError HWTVDRM::SetDisplayAttributes(uint32_t index) { DisplayError HWTVDRM::SetDisplayAttributes(uint32_t index) {
if (index >= connector_info_.modes.size()) { if (index >= connector_info_.modes.size()) {
DLOGE("Invalid mode index %d mode size %d", index, UINT32(connector_info_.modes.size())); DLOGE("Invalid mode index %d mode size %d", index, UINT32(connector_info_.modes.size()));
return kErrorNotSupported; return kErrorNotSupported;
} }
if (first_cycle_) {
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_CRTC, token_.conn_id, token_.crtc_id);
}
drm_atomic_intf_->Perform(DRMOps::CRTC_SET_MODE, token_.crtc_id, &connector_info_.modes[index]);
drm_atomic_intf_->Perform(DRMOps::CRTC_SET_ACTIVE, token_.crtc_id, 1);
// Commit to setup pipeline with mode, which then tells us the topology etc
if (drm_atomic_intf_->Commit(true /* synchronous */, false /* retain_planes*/)) {
DLOGE("Setting up CRTC %d, Connector %d for %s failed", token_.crtc_id,
token_.conn_id, device_name_);
return kErrorResources;
}
DLOGI("Setup CRTC %d, Connector %d for %s", token_.crtc_id, token_.conn_id, device_name_);
first_cycle_ = false;
// Reload connector info for updated info after 1st commit
drm_mgr_intf_->GetConnectorInfo(token_.conn_id, &connector_info_);
if (index >= connector_info_.modes.size()) {
DLOGE("Invalid mode index %d mode size %d", index, UINT32(connector_info_.modes.size()));
return kErrorNotSupported;
}
current_mode_index_ = index; current_mode_index_ = index;
PopulateDisplayAttributes(index);
PopulateHWPanelInfo(); PopulateHWPanelInfo();
UpdateMixerAttributes(); UpdateMixerAttributes();
DLOGI("Display attributes[%d]: WxH: %dx%d, DPI: %fx%f, FPS: %d, LM_SPLIT: %d, V_BACK_PORCH: %d," \
" V_FRONT_PORCH: %d, V_PULSE_WIDTH: %d, V_TOTAL: %d, H_TOTAL: %d, CLK: %dKHZ, TOPOLOGY: %d",
index, display_attributes_[index].x_pixels, display_attributes_[index].y_pixels,
display_attributes_[index].x_dpi, display_attributes_[index].y_dpi,
display_attributes_[index].fps, display_attributes_[index].is_device_split,
display_attributes_[index].v_back_porch, display_attributes_[index].v_front_porch,
display_attributes_[index].v_pulse_width, display_attributes_[index].v_total,
display_attributes_[index].h_total, display_attributes_[index].clock_khz,
display_attributes_[index].topology);
return kErrorNone; return kErrorNone;
} }
@@ -134,15 +106,15 @@ DisplayError HWTVDRM::GetConfigIndex(char *mode, uint32_t *index) {
} }
for (size_t idex = 0; idex < connector_info_.modes.size(); idex ++) { for (size_t idex = 0; idex < connector_info_.modes.size(); idex ++) {
if ((height == connector_info_.modes[idex].vdisplay) && if ((height == connector_info_.modes[idex].mode.vdisplay) &&
(width == connector_info_.modes[idex].hdisplay) && (width == connector_info_.modes[idex].mode.hdisplay) &&
(fps == connector_info_.modes[idex].vrefresh)) { (fps == connector_info_.modes[idex].mode.vrefresh)) {
if ((format >> 1) & (connector_info_.modes[idex].flags >> kBitYUV)) { if ((format >> 1) & (connector_info_.modes[idex].mode.flags >> kBitYUV)) {
*index = UINT32(idex); *index = UINT32(idex);
break; break;
} }
if (format & (connector_info_.modes[idex].flags >> kBitRGB)) { if (format & (connector_info_.modes[idex].mode.flags >> kBitRGB)) {
*index = UINT32(idex); *index = UINT32(idex);
break; break;
} }

View File

@@ -40,7 +40,6 @@ class HWTVDRM : public HWDeviceDRM {
HWInfoInterface *hw_info_intf); HWInfoInterface *hw_info_intf);
protected: protected:
virtual DisplayError Init();
virtual DisplayError SetDisplayAttributes(uint32_t index); virtual DisplayError SetDisplayAttributes(uint32_t index);
virtual DisplayError GetConfigIndex(char *mode, uint32_t *index); virtual DisplayError GetConfigIndex(char *mode, uint32_t *index);
virtual DisplayError PowerOff(); virtual DisplayError PowerOff();

View File

@@ -39,12 +39,15 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define __CLASS__ "HWVirtualDRM" #define __CLASS__ "HWVirtualDRM"
using std::vector;
using sde_drm::DRMDisplayType; using sde_drm::DRMDisplayType;
using sde_drm::DRMConnectorInfo; using sde_drm::DRMConnectorInfo;
using sde_drm::DRMRect; using sde_drm::DRMRect;
using sde_drm::DRMOps; using sde_drm::DRMOps;
using sde_drm::DRMPowerMode; using sde_drm::DRMPowerMode;
using sde_drm::DRMSecureMode; using sde_drm::DRMSecureMode;
namespace sdm { namespace sdm {
HWVirtualDRM::HWVirtualDRM(BufferSyncHandler *buffer_sync_handler, HWVirtualDRM::HWVirtualDRM(BufferSyncHandler *buffer_sync_handler,
@@ -83,24 +86,29 @@ void HWVirtualDRM::InitializeConfigs() {
} }
DisplayError HWVirtualDRM::SetWbConfigs(const HWDisplayAttributes &display_attributes) { DisplayError HWVirtualDRM::SetWbConfigs(const HWDisplayAttributes &display_attributes) {
int ret = -EINVAL;
int mode_index = -1;
// Add new connector mode to the list
drmModeModeInfo mode = {}; drmModeModeInfo mode = {};
vector<drmModeModeInfo> modes;
mode.hdisplay = mode.hsync_start = mode.hsync_end = mode.htotal = mode.hdisplay = mode.hsync_start = mode.hsync_end = mode.htotal =
UINT16(display_attributes.x_pixels); UINT16(display_attributes.x_pixels);
mode.vdisplay = mode.vsync_start = mode.vsync_end = mode.vtotal = mode.vdisplay = mode.vsync_start = mode.vsync_end = mode.vtotal =
UINT16(display_attributes.y_pixels); UINT16(display_attributes.y_pixels);
mode.vrefresh = UINT32(display_attributes.fps); mode.vrefresh = UINT32(display_attributes.fps);
mode.clock = (mode.htotal * mode.vtotal * mode.vrefresh) / 1000; mode.clock = (mode.htotal * mode.vtotal * mode.vrefresh) / 1000;
connector_info_.modes.push_back(mode); snprintf(mode.name, DRM_DISPLAY_MODE_LEN, "%dx%d", mode.hdisplay, mode.vdisplay);
modes.push_back(mode);
for (auto &item : connector_info_.modes) {
modes.push_back(item.mode);
}
// Inform the updated mode list to the driver // Inform the updated mode list to the driver
struct sde_drm_wb_cfg wb_cfg = {}; struct sde_drm_wb_cfg wb_cfg = {};
wb_cfg.connector_id = token_.conn_id; wb_cfg.connector_id = token_.conn_id;
wb_cfg.flags = SDE_DRM_WB_CFG_FLAGS_CONNECTED; wb_cfg.flags = SDE_DRM_WB_CFG_FLAGS_CONNECTED;
wb_cfg.count_modes = UINT32(connector_info_.modes.size()); wb_cfg.count_modes = UINT32(modes.size());
wb_cfg.modes = (uint64_t)connector_info_.modes.data(); wb_cfg.modes = (uint64_t)modes.data();
int ret = -EINVAL;
#ifdef DRM_IOCTL_SDE_WB_CONFIG #ifdef DRM_IOCTL_SDE_WB_CONFIG
ret = drmIoctl(dev_fd_, DRM_IOCTL_SDE_WB_CONFIG, &wb_cfg); ret = drmIoctl(dev_fd_, DRM_IOCTL_SDE_WB_CONFIG, &wb_cfg);
#endif #endif
@@ -109,45 +117,19 @@ DisplayError HWVirtualDRM::SetWbConfigs(const HWDisplayAttributes &display_attri
DumpConnectorModeInfo(); DumpConnectorModeInfo();
return kErrorHardware; return kErrorHardware;
} }
// Reload connector info for updated info after null commit
drm_mgr_intf_->GetConnectorInfo(token_.conn_id, &connector_info_);
// TODO(user): Remove this code once driver populates appropriate topology based on virtual
// display configuration
if (connector_info_.topology == sde_drm::DRMTopology::UNKNOWN) {
uint32_t max_width = 0;
for (uint32_t i = 0; i < (uint32_t)connector_info_.modes.size(); i++) {
max_width = std::max(max_width, UINT32(connector_info_.modes[i].hdisplay));
}
connector_info_.topology = sde_drm::DRMTopology::SINGLE_LM;
if (max_width > hw_resource_.max_mixer_width) {
connector_info_.topology = sde_drm::DRMTopology::DUAL_LM_MERGE;
}
}
InitializeConfigs();
GetModeIndex(display_attributes, &mode_index);
if (mode_index < 0) {
DLOGE("Mode not found for resolution %dx%d fps %d", display_attributes.x_pixels,
display_attributes.y_pixels, UINT32(display_attributes.fps));
DumpConnectorModeInfo();
return kErrorNotSupported;
}
current_mode_index_ = UINT32(mode_index);
DumpConnectorModeInfo();
return kErrorNone; return kErrorNone;
} }
void HWVirtualDRM::DumpConnectorModeInfo() { void HWVirtualDRM::DumpConnectorModeInfo() {
for (uint32_t i = 0; i < (uint32_t)connector_info_.modes.size(); i++) { for (uint32_t i = 0; i < (uint32_t)connector_info_.modes.size(); i++) {
DLOGI("Mode[%d]: Name: %s\tvref: %d\thdisp: %d\t hsync_s: %d\thsync_e:%d\thtotal: %d\t" \ DLOGI("Mode[%d] Name:%s vref:%d hdisp:%d hsync_s:%d hsync_e:%d htotal:%d " \
"vdisp: %d\tvsync_s: %d\tvsync_e: %d\tvtotal: %d\n", i, connector_info_.modes[i].name, "vdisp:%d vsync_s:%d vsync_e:%d vtotal:%d\n", i, connector_info_.modes[i].mode.name,
connector_info_.modes[i].vrefresh, connector_info_.modes[i].hdisplay, connector_info_.modes[i].mode.vrefresh, connector_info_.modes[i].mode.hdisplay,
connector_info_.modes[i].hsync_start, connector_info_.modes[i].hsync_end, connector_info_.modes[i].mode.hsync_start, connector_info_.modes[i].mode.hsync_end,
connector_info_.modes[i].htotal, connector_info_.modes[i].vdisplay, connector_info_.modes[i].mode.htotal, connector_info_.modes[i].mode.vdisplay,
connector_info_.modes[i].vsync_start, connector_info_.modes[i].vsync_end, connector_info_.modes[i].mode.vsync_start, connector_info_.modes[i].mode.vsync_end,
connector_info_.modes[i].vtotal); connector_info_.modes[i].mode.vtotal);
} }
} }
@@ -155,12 +137,6 @@ DisplayError HWVirtualDRM::Commit(HWLayers *hw_layers) {
LayerBuffer *output_buffer = hw_layers->info.stack->output_buffer; LayerBuffer *output_buffer = hw_layers->info.stack->output_buffer;
DisplayError err = kErrorNone; DisplayError err = kErrorNone;
if (first_cycle_) {
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_CRTC, token_.conn_id, token_.crtc_id);
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_POWER_MODE, token_.conn_id, DRMPowerMode::ON);
first_cycle_ = false;
}
registry_.RegisterCurrent(hw_layers); registry_.RegisterCurrent(hw_layers);
registry_.MapBufferToFbId(output_buffer); registry_.MapBufferToFbId(output_buffer);
uint32_t fb_id = registry_.GetFbId(output_buffer->planes[0].fd); uint32_t fb_id = registry_.GetFbId(output_buffer->planes[0].fd);
@@ -181,11 +157,6 @@ DisplayError HWVirtualDRM::Commit(HWLayers *hw_layers) {
DisplayError HWVirtualDRM::Validate(HWLayers *hw_layers) { DisplayError HWVirtualDRM::Validate(HWLayers *hw_layers) {
LayerBuffer *output_buffer = hw_layers->info.stack->output_buffer; LayerBuffer *output_buffer = hw_layers->info.stack->output_buffer;
if (first_cycle_) {
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_CRTC, token_.conn_id, token_.crtc_id);
drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_POWER_MODE, token_.conn_id, DRMPowerMode::ON);
}
registry_.MapBufferToFbId(output_buffer); registry_.MapBufferToFbId(output_buffer);
uint32_t fb_id = registry_.GetFbId(output_buffer->planes[0].fd); uint32_t fb_id = registry_.GetFbId(output_buffer->planes[0].fd);
@@ -203,28 +174,34 @@ DisplayError HWVirtualDRM::SetDisplayAttributes(const HWDisplayAttributes &displ
int mode_index = -1; int mode_index = -1;
GetModeIndex(display_attributes, &mode_index); GetModeIndex(display_attributes, &mode_index);
if (mode_index < 0) { if (mode_index < 0) {
DisplayError error = SetWbConfigs(display_attributes); DisplayError error = SetWbConfigs(display_attributes);
if (error != kErrorNone) { if (error != kErrorNone) {
return error; return error;
} }
} else {
current_mode_index_ = UINT32(mode_index);
} }
// Reload connector info for updated info
drm_mgr_intf_->GetConnectorInfo(token_.conn_id, &connector_info_);
GetModeIndex(display_attributes, &mode_index);
if (mode_index < 0) {
DLOGE("Mode not found for resolution %dx%d fps %d", display_attributes.x_pixels,
display_attributes.y_pixels, UINT32(display_attributes.fps));
DumpConnectorModeInfo();
return kErrorNotSupported;
}
current_mode_index_ = UINT32(mode_index);
InitializeConfigs();
PopulateHWPanelInfo(); PopulateHWPanelInfo();
UpdateMixerAttributes(); UpdateMixerAttributes();
DLOGI("New WB Resolution: %dx%d cur_mode_index %d", display_attributes.x_pixels, DLOGI("New WB Resolution: %dx%d cur_mode_index %d", display_attributes.x_pixels,
display_attributes.y_pixels, current_mode_index_); display_attributes.y_pixels, current_mode_index_);
return kErrorNone;
}
DisplayError HWVirtualDRM::PowerOn() {
if (first_cycle_) {
return kErrorNone; return kErrorNone;
}
return HWDeviceDRM::PowerOn();
} }
DisplayError HWVirtualDRM::GetPPFeaturesVersion(PPFeatureVersion *vers) { DisplayError HWVirtualDRM::GetPPFeaturesVersion(PPFeatureVersion *vers) {
@@ -234,9 +211,9 @@ DisplayError HWVirtualDRM::GetPPFeaturesVersion(PPFeatureVersion *vers) {
void HWVirtualDRM::GetModeIndex(const HWDisplayAttributes &display_attributes, int *mode_index) { void HWVirtualDRM::GetModeIndex(const HWDisplayAttributes &display_attributes, int *mode_index) {
*mode_index = -1; *mode_index = -1;
for (uint32_t i = 0; i < connector_info_.modes.size(); i++) { for (uint32_t i = 0; i < connector_info_.modes.size(); i++) {
if (display_attributes.x_pixels == connector_info_.modes[i].hdisplay && if (display_attributes.x_pixels == connector_info_.modes[i].mode.hdisplay &&
display_attributes.y_pixels == connector_info_.modes[i].vdisplay && display_attributes.y_pixels == connector_info_.modes[i].mode.vdisplay &&
display_attributes.fps == connector_info_.modes[i].vrefresh) { display_attributes.fps == connector_info_.modes[i].mode.vrefresh) {
*mode_index = INT32(i); *mode_index = INT32(i);
break; break;
} }

View File

@@ -47,7 +47,6 @@ class HWVirtualDRM : public HWDeviceDRM {
return kErrorNotSupported; return kErrorNotSupported;
} }
virtual DisplayError SetDisplayAttributes(const HWDisplayAttributes &display_attributes); virtual DisplayError SetDisplayAttributes(const HWDisplayAttributes &display_attributes);
virtual DisplayError PowerOn();
protected: protected:
virtual DisplayError Validate(HWLayers *hw_layers); virtual DisplayError Validate(HWLayers *hw_layers);