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 5014f0eb03cc37419590c1a59433689f29fa9cb2.
Change-Id: Ib68c5b2e2ff475250b7251822515e51fb7b31869
CRs-fixed: 2138173
diff --git a/libdrmutils/drm_interface.h b/libdrmutils/drm_interface.h
index d64d904..6bf7f97 100644
--- a/libdrmutils/drm_interface.h
+++ b/libdrmutils/drm_interface.h
@@ -443,22 +443,10 @@
COMMAND,
};
-/* Per Connector Info*/
-struct DRMConnectorInfo {
- uint32_t mmWidth;
- uint32_t mmHeight;
- uint32_t type;
- std::vector<drmModeModeInfo> modes;
+/* Per mode info */
+struct DRMModeInfo {
+ drmModeModeInfo mode;
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
int num_roi;
int xstart;
@@ -468,6 +456,23 @@
int wmin;
int hmin;
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;
drm_panel_hdr_properties panel_hdr_prop;
uint32_t transfer_time_us;
diff --git a/sdm/libs/core/drm/hw_device_drm.cpp b/sdm/libs/core/drm/hw_device_drm.cpp
index c1e14ee..e129a7d 100644
--- a/sdm/libs/core/drm/hw_device_drm.cpp
+++ b/sdm/libs/core/drm/hw_device_drm.cpp
@@ -333,29 +333,29 @@
}
DisplayError HWDeviceDRM::Init() {
- default_mode_ = (DRMLibLoader::GetInstance()->IsLoaded() == false);
+ DRMMaster *drm_master = {};
+ DRMMaster::GetInstance(&drm_master);
+ drm_master->GetHandle(&dev_fd_);
+ DRMLibLoader::GetInstance()->FuncGetDRMManager()(dev_fd_, &drm_mgr_intf_);
- if (!default_mode_) {
- DRMMaster *drm_master = {};
- DRMMaster::GetInstance(&drm_master);
- drm_master->GetHandle(&dev_fd_);
- DRMLibLoader::GetInstance()->FuncGetDRMManager()(dev_fd_, &drm_mgr_intf_);
- if (drm_mgr_intf_->RegisterDisplay(disp_type_, &token_)) {
- DLOGE("RegisterDisplay failed for %s", device_name_);
- return kErrorResources;
- }
-
- drm_mgr_intf_->CreateAtomicReq(token_, &drm_atomic_intf_);
- } else {
- display_attributes_.push_back(HWDisplayAttributes());
- PopulateDisplayAttributes(current_mode_index_);
+ if (drm_mgr_intf_->RegisterDisplay(disp_type_, &token_)) {
+ DLOGE("RegisterDisplay failed for %s", device_name_);
+ return kErrorResources;
}
+ drm_mgr_intf_->CreateAtomicReq(token_, &drm_atomic_intf_);
+ drm_mgr_intf_->GetConnectorInfo(token_.conn_id, &connector_info_);
hw_info_intf_->GetHWResourceInfo(&hw_resource_);
+
+ InitializeConfigs();
+ PopulateHWPanelInfo();
+ UpdateMixerAttributes();
+
// TODO(user): In future, remove has_qseed3 member, add version and pass version to constructor
if (hw_resource_.has_qseed3) {
hw_scale_ = new HWScaleDRM(HWScaleDRM::Version::V2);
}
+
return kErrorNone;
}
@@ -384,7 +384,7 @@
current_mode_index_ = 0;
// Update current mode with preferred mode
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;
break;
}
@@ -392,10 +392,10 @@
display_attributes_.resize(connector_info_.modes.size());
- uint32_t width = connector_info_.modes[current_mode_index_].hdisplay;
- uint32_t height = connector_info_.modes[current_mode_index_].vdisplay;
+ uint32_t width = connector_info_.modes[current_mode_index_].mode.hdisplay;
+ uint32_t height = connector_info_.modes[current_mode_index_].mode.vdisplay;
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) {
resolution_switch_enabled_ = true;
}
@@ -420,10 +420,10 @@
res_mgr->GetMode(&mode);
res_mgr->GetDisplayDimInMM(&mm_width, &mm_height);
} else {
- mode = connector_info_.modes[index];
+ mode = connector_info_.modes[index].mode;
mm_width = connector_info_.mmWidth;
mm_height = connector_info_.mmHeight;
- topology = connector_info_.topology;
+ topology = connector_info_.modes[index].topology;
}
display_attributes_[index].x_pixels = mode.hdisplay;
@@ -490,29 +490,29 @@
display_attributes_[index].x_pixels / 2;
}
- hw_panel_info_.partial_update = connector_info_.num_roi;
- hw_panel_info_.left_roi_count = UINT32(connector_info_.num_roi);
- hw_panel_info_.right_roi_count = UINT32(connector_info_.num_roi);
- hw_panel_info_.left_align = connector_info_.xstart;
- hw_panel_info_.top_align = connector_info_.ystart;
- hw_panel_info_.width_align = connector_info_.walign;
- hw_panel_info_.height_align = connector_info_.halign;
- hw_panel_info_.min_roi_width = connector_info_.wmin;
- hw_panel_info_.min_roi_height = connector_info_.hmin;
- hw_panel_info_.needs_roi_merge = connector_info_.roi_merge;
+ hw_panel_info_.partial_update = connector_info_.modes[index].num_roi;
+ hw_panel_info_.left_roi_count = UINT32(connector_info_.modes[index].num_roi);
+ hw_panel_info_.right_roi_count = UINT32(connector_info_.modes[index].num_roi);
+ hw_panel_info_.left_align = connector_info_.modes[index].xstart;
+ hw_panel_info_.top_align = connector_info_.modes[index].ystart;
+ hw_panel_info_.width_align = connector_info_.modes[index].walign;
+ hw_panel_info_.height_align = connector_info_.modes[index].halign;
+ hw_panel_info_.min_roi_width = connector_info_.modes[index].wmin;
+ hw_panel_info_.min_roi_height = connector_info_.modes[index].hmin;
+ hw_panel_info_.needs_roi_merge = connector_info_.modes[index].roi_merge;
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) {
uint32_t min_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++) {
- if ((current_mode.vdisplay == connector_info_.modes[mode_index].vdisplay) &&
- (current_mode.hdisplay == connector_info_.modes[mode_index].hdisplay)) {
- if (min_fps > connector_info_.modes[mode_index].vrefresh) {
- min_fps = connector_info_.modes[mode_index].vrefresh;
+ if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
+ (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay)) {
+ if (min_fps > connector_info_.modes[mode_index].mode.vrefresh) {
+ min_fps = connector_info_.modes[mode_index].mode.vrefresh;
}
- if (max_fps < connector_info_.modes[mode_index].vrefresh) {
- 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].mode.vrefresh;
}
}
}
@@ -676,13 +676,21 @@
DLOGE("Invalid mode index %d mode size %d", index, UINT32(display_attributes_.size()));
return kErrorParameters;
}
+
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();
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;
}
@@ -701,6 +709,10 @@
return kErrorUndefined;
}
+ if (first_cycle_) {
+ return kErrorNone;
+ }
+
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);
int ret = drm_atomic_intf_->Commit(true /* synchronous */, true /* retain_planes */);
@@ -771,7 +783,7 @@
HWQosData &qos_data = hw_layers->qos_data;
DRMSecurityLevel crtc_security_level = DRMSecurityLevel::SECURE_NON_SECURE;
uint32_t index = current_mode_index_;
- drmModeModeInfo current_mode = connector_info_.modes[index];
+ drmModeModeInfo current_mode = connector_info_.modes[index].mode;
solid_fills_.clear();
@@ -908,14 +920,20 @@
// Set refresh rate
if (vrefresh_) {
for (uint32_t mode_index = 0; mode_index < connector_info_.modes.size(); mode_index++) {
- if ((current_mode.vdisplay == connector_info_.modes[mode_index].vdisplay) &&
- (current_mode.hdisplay == connector_info_.modes[mode_index].hdisplay) &&
- (vrefresh_ == connector_info_.modes[mode_index].vrefresh)) {
- current_mode = connector_info_.modes[mode_index];
+ if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
+ (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay) &&
+ (vrefresh_ == connector_info_.modes[mode_index].mode.vrefresh)) {
+ current_mode = connector_info_.modes[mode_index].mode;
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, ¤t_mode);
drm_atomic_intf_->Perform(DRMOps::CRTC_SET_ACTIVE, token_.crtc_id, 1);
@@ -1082,11 +1100,11 @@
if (vrefresh_) {
// 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++) {
- if ((current_mode.vdisplay == connector_info_.modes[mode_index].vdisplay) &&
- (current_mode.hdisplay == connector_info_.modes[mode_index].hdisplay) &&
- (vrefresh_ == connector_info_.modes[mode_index].vrefresh)) {
+ if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
+ (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay) &&
+ (vrefresh_ == connector_info_.modes[mode_index].mode.vrefresh)) {
current_mode_index_ = mode_index;
break;
}
@@ -1094,12 +1112,7 @@
vrefresh_ = 0;
}
- if (switch_mode_) {
- // Reload connector info for updated info after 1st commit
- drm_mgr_intf_->GetConnectorInfo(token_.conn_id, &connector_info_);
- PopulateHWPanelInfo();
- switch_mode_ = false;
- }
+ first_cycle_ = false;
return kErrorNone;
}
@@ -1281,11 +1294,11 @@
DisplayError HWDeviceDRM::SetRefreshRate(uint32_t refresh_rate) {
// 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++) {
- if ((current_mode.vdisplay == connector_info_.modes[mode_index].vdisplay) &&
- (current_mode.hdisplay == connector_info_.modes[mode_index].hdisplay) &&
- (refresh_rate == connector_info_.modes[mode_index].vrefresh)) {
+ if ((current_mode.vdisplay == connector_info_.modes[mode_index].mode.vdisplay) &&
+ (current_mode.hdisplay == connector_info_.modes[mode_index].mode.hdisplay) &&
+ (refresh_rate == connector_info_.modes[mode_index].mode.vrefresh)) {
vrefresh_ = refresh_rate;
DLOGV_IF(kTagDriverConfig, "Set refresh rate to %d", refresh_rate);
return kErrorNone;
diff --git a/sdm/libs/core/drm/hw_device_drm.h b/sdm/libs/core/drm/hw_device_drm.h
index e02d936..16355c8 100644
--- a/sdm/libs/core/drm/hw_device_drm.h
+++ b/sdm/libs/core/drm/hw_device_drm.h
@@ -183,7 +183,6 @@
std::vector<sde_drm::DRMSolidfillStage> solid_fills_ {};
bool resolution_switch_enabled_ = false;
uint32_t vrefresh_ = 0;
- bool switch_mode_ = false;
bool autorefresh_ = false;
};
diff --git a/sdm/libs/core/drm/hw_peripheral_drm.cpp b/sdm/libs/core/drm/hw_peripheral_drm.cpp
index e78c862..44c22e7 100644
--- a/sdm/libs/core/drm/hw_peripheral_drm.cpp
+++ b/sdm/libs/core/drm/hw_peripheral_drm.cpp
@@ -35,7 +35,6 @@
using sde_drm::DRMDisplayType;
using sde_drm::DRMOps;
-using sde_drm::DRMTopology;
using sde_drm::DRMPowerMode;
namespace sdm {
@@ -57,41 +56,11 @@
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;
}
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;
- 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);
return HWDeviceDRM::Validate(hw_layers);
@@ -104,14 +73,6 @@
return HWDeviceDRM::Commit(hw_layers);
}
-DisplayError HWPeripheralDRM::PowerOn() {
- if (first_cycle_) {
- return kErrorNone;
- }
-
- return HWDeviceDRM::PowerOn();
-}
-
void HWPeripheralDRM::ResetDisplayParams() {
sde_dest_scalar_data_ = {};
for (uint32_t j = 0; j < scalar_data_.size(); j++) {
diff --git a/sdm/libs/core/drm/hw_peripheral_drm.h b/sdm/libs/core/drm/hw_peripheral_drm.h
index 0b596ad..e4b33cf 100644
--- a/sdm/libs/core/drm/hw_peripheral_drm.h
+++ b/sdm/libs/core/drm/hw_peripheral_drm.h
@@ -46,7 +46,6 @@
virtual DisplayError Init();
virtual DisplayError Validate(HWLayers *hw_layers);
virtual DisplayError Commit(HWLayers *hw_layers);
- virtual DisplayError PowerOn();
virtual DisplayError Flush();
private:
void SetDestScalarData(HWLayersInfo hw_layer_info);
diff --git a/sdm/libs/core/drm/hw_tv_drm.cpp b/sdm/libs/core/drm/hw_tv_drm.cpp
index b2075a8..565652e 100644
--- a/sdm/libs/core/drm/hw_tv_drm.cpp
+++ b/sdm/libs/core/drm/hw_tv_drm.cpp
@@ -67,54 +67,26 @@
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) {
if (index >= connector_info_.modes.size()) {
DLOGE("Invalid mode index %d mode size %d", index, UINT32(connector_info_.modes.size()));
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;
- PopulateDisplayAttributes(index);
PopulateHWPanelInfo();
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;
}
@@ -134,15 +106,15 @@
}
for (size_t idex = 0; idex < connector_info_.modes.size(); idex ++) {
- if ((height == connector_info_.modes[idex].vdisplay) &&
- (width == connector_info_.modes[idex].hdisplay) &&
- (fps == connector_info_.modes[idex].vrefresh)) {
- if ((format >> 1) & (connector_info_.modes[idex].flags >> kBitYUV)) {
+ if ((height == connector_info_.modes[idex].mode.vdisplay) &&
+ (width == connector_info_.modes[idex].mode.hdisplay) &&
+ (fps == connector_info_.modes[idex].mode.vrefresh)) {
+ if ((format >> 1) & (connector_info_.modes[idex].mode.flags >> kBitYUV)) {
*index = UINT32(idex);
break;
}
- if (format & (connector_info_.modes[idex].flags >> kBitRGB)) {
+ if (format & (connector_info_.modes[idex].mode.flags >> kBitRGB)) {
*index = UINT32(idex);
break;
}
diff --git a/sdm/libs/core/drm/hw_tv_drm.h b/sdm/libs/core/drm/hw_tv_drm.h
index ff07ac2..54ce327 100644
--- a/sdm/libs/core/drm/hw_tv_drm.h
+++ b/sdm/libs/core/drm/hw_tv_drm.h
@@ -40,7 +40,6 @@
HWInfoInterface *hw_info_intf);
protected:
- virtual DisplayError Init();
virtual DisplayError SetDisplayAttributes(uint32_t index);
virtual DisplayError GetConfigIndex(char *mode, uint32_t *index);
virtual DisplayError PowerOff();
diff --git a/sdm/libs/core/drm/hw_virtual_drm.cpp b/sdm/libs/core/drm/hw_virtual_drm.cpp
index 5f07fd3..28d81bb 100644
--- a/sdm/libs/core/drm/hw_virtual_drm.cpp
+++ b/sdm/libs/core/drm/hw_virtual_drm.cpp
@@ -39,12 +39,15 @@
#define __CLASS__ "HWVirtualDRM"
+using std::vector;
+
using sde_drm::DRMDisplayType;
using sde_drm::DRMConnectorInfo;
using sde_drm::DRMRect;
using sde_drm::DRMOps;
using sde_drm::DRMPowerMode;
using sde_drm::DRMSecureMode;
+
namespace sdm {
HWVirtualDRM::HWVirtualDRM(BufferSyncHandler *buffer_sync_handler,
@@ -83,24 +86,29 @@
}
DisplayError HWVirtualDRM::SetWbConfigs(const HWDisplayAttributes &display_attributes) {
- int ret = -EINVAL;
- int mode_index = -1;
- // Add new connector mode to the list
drmModeModeInfo mode = {};
+ vector<drmModeModeInfo> modes;
+
mode.hdisplay = mode.hsync_start = mode.hsync_end = mode.htotal =
UINT16(display_attributes.x_pixels);
mode.vdisplay = mode.vsync_start = mode.vsync_end = mode.vtotal =
UINT16(display_attributes.y_pixels);
mode.vrefresh = UINT32(display_attributes.fps);
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
struct sde_drm_wb_cfg wb_cfg = {};
wb_cfg.connector_id = token_.conn_id;
wb_cfg.flags = SDE_DRM_WB_CFG_FLAGS_CONNECTED;
- wb_cfg.count_modes = UINT32(connector_info_.modes.size());
- wb_cfg.modes = (uint64_t)connector_info_.modes.data();
+ wb_cfg.count_modes = UINT32(modes.size());
+ wb_cfg.modes = (uint64_t)modes.data();
+
+ int ret = -EINVAL;
#ifdef DRM_IOCTL_SDE_WB_CONFIG
ret = drmIoctl(dev_fd_, DRM_IOCTL_SDE_WB_CONFIG, &wb_cfg);
#endif
@@ -109,45 +117,19 @@
DumpConnectorModeInfo();
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;
}
void HWVirtualDRM::DumpConnectorModeInfo() {
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" \
- "vdisp: %d\tvsync_s: %d\tvsync_e: %d\tvtotal: %d\n", i, connector_info_.modes[i].name,
- connector_info_.modes[i].vrefresh, connector_info_.modes[i].hdisplay,
- connector_info_.modes[i].hsync_start, connector_info_.modes[i].hsync_end,
- connector_info_.modes[i].htotal, connector_info_.modes[i].vdisplay,
- connector_info_.modes[i].vsync_start, connector_info_.modes[i].vsync_end,
- connector_info_.modes[i].vtotal);
+ DLOGI("Mode[%d] Name:%s vref:%d hdisp:%d hsync_s:%d hsync_e:%d htotal:%d " \
+ "vdisp:%d vsync_s:%d vsync_e:%d vtotal:%d\n", i, connector_info_.modes[i].mode.name,
+ connector_info_.modes[i].mode.vrefresh, connector_info_.modes[i].mode.hdisplay,
+ connector_info_.modes[i].mode.hsync_start, connector_info_.modes[i].mode.hsync_end,
+ connector_info_.modes[i].mode.htotal, connector_info_.modes[i].mode.vdisplay,
+ connector_info_.modes[i].mode.vsync_start, connector_info_.modes[i].mode.vsync_end,
+ connector_info_.modes[i].mode.vtotal);
}
}
@@ -155,12 +137,6 @@
LayerBuffer *output_buffer = hw_layers->info.stack->output_buffer;
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_.MapBufferToFbId(output_buffer);
uint32_t fb_id = registry_.GetFbId(output_buffer->planes[0].fd);
@@ -181,11 +157,6 @@
DisplayError HWVirtualDRM::Validate(HWLayers *hw_layers) {
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);
uint32_t fb_id = registry_.GetFbId(output_buffer->planes[0].fd);
@@ -203,30 +174,36 @@
int mode_index = -1;
GetModeIndex(display_attributes, &mode_index);
+
if (mode_index < 0) {
DisplayError error = SetWbConfigs(display_attributes);
if (error != kErrorNone) {
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();
UpdateMixerAttributes();
DLOGI("New WB Resolution: %dx%d cur_mode_index %d", display_attributes.x_pixels,
display_attributes.y_pixels, current_mode_index_);
+
return kErrorNone;
}
-DisplayError HWVirtualDRM::PowerOn() {
- if (first_cycle_) {
- return kErrorNone;
- }
-
- return HWDeviceDRM::PowerOn();
-}
-
DisplayError HWVirtualDRM::GetPPFeaturesVersion(PPFeatureVersion *vers) {
return kErrorNone;
}
@@ -234,9 +211,9 @@
void HWVirtualDRM::GetModeIndex(const HWDisplayAttributes &display_attributes, int *mode_index) {
*mode_index = -1;
for (uint32_t i = 0; i < connector_info_.modes.size(); i++) {
- if (display_attributes.x_pixels == connector_info_.modes[i].hdisplay &&
- display_attributes.y_pixels == connector_info_.modes[i].vdisplay &&
- display_attributes.fps == connector_info_.modes[i].vrefresh) {
+ if (display_attributes.x_pixels == connector_info_.modes[i].mode.hdisplay &&
+ display_attributes.y_pixels == connector_info_.modes[i].mode.vdisplay &&
+ display_attributes.fps == connector_info_.modes[i].mode.vrefresh) {
*mode_index = INT32(i);
break;
}
diff --git a/sdm/libs/core/drm/hw_virtual_drm.h b/sdm/libs/core/drm/hw_virtual_drm.h
index 29ef7b2..257e08a 100644
--- a/sdm/libs/core/drm/hw_virtual_drm.h
+++ b/sdm/libs/core/drm/hw_virtual_drm.h
@@ -47,7 +47,6 @@
return kErrorNotSupported;
}
virtual DisplayError SetDisplayAttributes(const HWDisplayAttributes &display_attributes);
- virtual DisplayError PowerOn();
protected:
virtual DisplayError Validate(HWLayers *hw_layers);