Skip to content

Commit

Permalink
sdm: Send current display config to SVM on TUITransition start
Browse files Browse the repository at this point in the history
Send the display config mode information to SVM at the end of TUI
transition start commit to make sure the current display config
mode is configured appropriately in SVM.

Change-Id: Ia9567fe0f1129d484a3f768384053fa71e88de37
  • Loading branch information
Ramkumar Radhakrishnan committed Nov 20, 2020
1 parent c25c006 commit 9dd6bd5
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 24 deletions.
42 changes: 34 additions & 8 deletions composer/ipc_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@ int IPCImpl::Init() {
DLOGW("Unable to load symbols, error = %s", qrtr_client_lib_.Error());
}

QRTRConfig qrtr_config = {};
qrtr_config.server_id = SDM_COMP_SERVICE_ID;
qrtr_config.server_version = SDM_COMP_SERVICE_VERSION;
qrtr_config.server_instance = SDM_COMP_SERVICE_INSTANCE;

int error = create_qrtr_client_intf_(qrtr_config, this, &qrtr_client_intf_);
if (error != 0) {
DLOGW("Unable to create interface");
if (create_qrtr_client_intf_) {
QRTRConfig qrtr_config = {};
qrtr_config.server_id = SDM_COMP_SERVICE_ID;
qrtr_config.server_version = SDM_COMP_SERVICE_VERSION;
qrtr_config.server_instance = SDM_COMP_SERVICE_INSTANCE;
int error = create_qrtr_client_intf_(qrtr_config, this, &qrtr_client_intf_);
if (error != 0) {
DLOGW("Unable to create interface");
}
}
} else {
DLOGW("Unable to load = %s, error = %s", QRTR_CLIENT_LIB_NAME, qrtr_client_lib_.Error());
Expand Down Expand Up @@ -95,6 +96,31 @@ int IPCImpl::SetParameter(IPCParams param, const GenericPayload &in) {
return qrtr_client_intf_->SendCommand(cmd);
}
} break;
case kIpcParamSetDisplayConfigs: {
if (qrtr_client_intf_) {
IPCDisplayConfigParams *disp_configs = nullptr;
uint32_t sz = 0;
Command cmd = {};
if ((ret = in.GetPayload(disp_configs, &sz))) {
DLOGE("Failed to get input payload error = %d", ret);
return ret;
}
CmdSetDisplayConfigs &cmd_disp_configs = cmd.cmd_set_disp_configs;
cmd.id = kCmdSetDisplayConfig;
cmd_disp_configs.x_pixels= disp_configs->x_pixels;
cmd_disp_configs.y_pixels= disp_configs->y_pixels;
cmd_disp_configs.fps= disp_configs->fps;
cmd_disp_configs.config_idx= disp_configs->config_idx;
cmd_disp_configs.smart_panel= disp_configs->smart_panel;
cmd_disp_configs.disp_type = disp_configs->is_primary ? kDisplayTypePrimary :
kDisplayTypeSecondary1;
DLOGI("Send display configs: WxH %dx%d, fps %d, config_idx %d, %s panel, disp_type %d to SVM",
cmd_disp_configs.x_pixels, cmd_disp_configs.y_pixels, cmd_disp_configs.fps,
cmd_disp_configs.config_idx, cmd_disp_configs.smart_panel ? "cmdmode" : "videomode",
cmd_disp_configs.disp_type);
return qrtr_client_intf_->SendCommand(cmd);
}
} break;
default:
break;
}
Expand Down
36 changes: 32 additions & 4 deletions include/vm_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
#define SDM_COMP_SERVICE_INSTANCE 1

#define VM_INTF_REVISION_MAJOR (1)
#define VM_INTF_REVISION_MINOR (0)
#define VM_INTF_REVISION_MINOR (1)

#define VM_INTF_VERSION ((uint16_t) ((VM_INTF_REVISION_MAJOR << 8) | VM_INTF_REVISION_MINOR))

enum CommandId {
kCmdExportDemuraBuffers = 0,
kCmdSetBacklight = 1,
kCmdSetDisplayConfig = 2,
kCmdMax,
};

Expand All @@ -47,9 +48,13 @@ enum DisplayType {
};

typedef struct {
int cfg_mem_hdl = -1;
int calib_mem_hdl = -1;
int hfc_mem_hdl = -1;
} DemuraMemHandle;
uint32_t calib_mem_size = 0;
uint32_t hfc_mem_size = 0;
uint64_t panel_id = 0;
DisplayType disp_type = kDisplayTypeMax;
} DemuraMemInfo;

typedef struct {
uint16_t version = VM_INTF_VERSION;
Expand All @@ -64,7 +69,7 @@ typedef struct {
// Command and Response structure definitions to start TUI session
typedef struct {
union {
DemuraMemHandle demura_mem_handle;
DemuraMemInfo demura_mem_info;
uint32_t reserve[128] = { 0 };
};
} CmdExportDemuraBuffer;
Expand Down Expand Up @@ -92,11 +97,33 @@ typedef struct {
};
} RspSetBacklight;

// Command and Response structure definitions to set display config mode
typedef struct {
union {
struct {
uint32_t x_pixels;
uint32_t y_pixels;
uint32_t fps;
int config_idx ;
DisplayType disp_type;
bool smart_panel;
};
uint32_t reserve[128] = { 0 };
};
} CmdSetDisplayConfigs;

typedef struct {
union {
uint32_t reserve[128] = { 0 };
};
} RspSetDisplayConfigs;

struct Command : CommandHeader {
Command() {}
union {
CmdExportDemuraBuffer cmd_export_demura_buf;
CmdSetBacklight cmd_set_backlight;
CmdSetDisplayConfigs cmd_set_disp_configs;
};
};

Expand All @@ -105,6 +132,7 @@ struct Response : ResponseHeader {
union {
RspExportDemuraBuffer rsp_export_demura_buf;
RspSetBacklight rsp_set_backlight;
RspSetDisplayConfigs rsp_set_disp_configs;
};
};

Expand Down
16 changes: 13 additions & 3 deletions sdm/include/core/ipc_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
namespace sdm {

enum IPCParams {
kIpcParamSetBacklight,
kIpcParamSetBacklight, //!< Send backlight params to SVM
kIpcParamSetDisplayConfigs, //!< Send display config information to SVM
kIPCParamMax,
};

Expand All @@ -40,8 +41,17 @@ enum IPCOps {
};

struct IPCBacklightParams {
float brightness = 0.0f;
bool is_primary = false;
float brightness = 0.0f; //!< Specifies the brightness level to be passed to SVM
bool is_primary = false; //!< Flag specifies primary/secondary
};

struct IPCDisplayConfigParams {
uint32_t x_pixels = 0; //!< Total number of pixels in X-direction on the display panel.
uint32_t y_pixels = 0; //!< Total number of pixels in Y-direction on the display panel.
uint32_t fps = 0; //!< Frame rate per second.
int config_idx = -1; //!< Specifies the config index of the display resolution mode.
bool is_primary = false; //!< Flag specifies primary/secondary
bool smart_panel = false; //!< If the display config has smart panel.
};

using IPCIntf = sdm::GenericIntf<IPCParams, IPCOps, GenericPayload>;
Expand Down
53 changes: 44 additions & 9 deletions sdm/libs/core/display_builtin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,17 +420,17 @@ DisplayError DisplayBuiltIn::Commit(LayerStack *layer_stack) {
SetPanelBrightness(cached_brightness_);
pending_brightness_ = false;
} else {
// Send the panel brightness event to secondary VM on TUI session start
if (secure_event_ == kTUITransitionStart) {
DisplayError err = kErrorNone;
int level = 0;
if ((err = hw_intf_->GetPanelBrightness(&level)) != kErrorNone) {
return err;
}
HandleBacklightEvent(level);
// Send the panel brightness event to secondary VM on TUI session start
SendBacklight();
}
}

if (secure_event_ == kTUITransitionStart) {
// Send display config information to secondary VM on TUI session start
SendDisplayConfigs();
}

if (commit_event_enabled_) {
dpps_info_.DppsNotifyOps(kDppsCommitEvent, &display_type_, sizeof(display_type_));
}
Expand Down Expand Up @@ -806,7 +806,7 @@ void DisplayBuiltIn::HandleBacklightEvent(float brightness_level) {
IPCBacklightParams *backlight_params = nullptr;
int ret = in.CreatePayload<IPCBacklightParams>(backlight_params);
if (ret) {
DLOGE("failed to create the payload. Error:%d", ret);
DLOGW("failed to create the payload. Error:%d", ret);
return;
}
float brightness = 0.0f;
Expand All @@ -816,7 +816,7 @@ void DisplayBuiltIn::HandleBacklightEvent(float brightness_level) {
backlight_params->brightness = brightness;
backlight_params->is_primary = IsPrimaryDisplay();
if ((ret = ipc_intf_->SetParameter(kIpcParamSetBacklight, in))) {
DLOGE("Failed to set backlight, error = %d", ret);
DLOGW("Failed to set backlight, error = %d", ret);
}
lock_guard<recursive_mutex> obj(brightness_lock_);
cached_brightness_ = brightness;
Expand Down Expand Up @@ -1732,4 +1732,39 @@ DisplayError DisplayBuiltIn::GetConfig(DisplayConfigFixedInfo *fixed_info) {
return kErrorNone;
}

void DisplayBuiltIn::SendBacklight() {
DisplayError err = kErrorNone;
int level = 0;
if ((err = hw_intf_->GetPanelBrightness(&level)) != kErrorNone) {
return;
}
HandleBacklightEvent(level);
}

void DisplayBuiltIn::SendDisplayConfigs() {
if (ipc_intf_) {
GenericPayload in;
uint32_t active_index = 0;
IPCDisplayConfigParams *disp_configs = nullptr;
int ret = in.CreatePayload<IPCDisplayConfigParams>(disp_configs);
if (ret) {
DLOGW("failed to create the payload. Error:%d", ret);
return;
}
DisplayError error = hw_intf_->GetActiveConfig(&active_index);
if (error != kErrorNone) {
return;
}
disp_configs->x_pixels = display_attributes_.x_pixels;
disp_configs->y_pixels = display_attributes_.y_pixels;
disp_configs->fps = display_attributes_.fps;
disp_configs->config_idx = active_index;
disp_configs->smart_panel = display_attributes_.smart_panel;
disp_configs->is_primary = IsPrimaryDisplay();
if ((ret = ipc_intf_->SetParameter(kIpcParamSetDisplayConfigs, in))) {
DLOGW("Failed to send display config, error = %d", ret);
}
}
}

} // namespace sdm
2 changes: 2 additions & 0 deletions sdm/libs/core/display_builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ class DisplayBuiltIn : public DisplayBase, HWEventHandler, DppsPropIntf {
void HandleQsyncPostCommit(LayerStack *layer_stack);
void UpdateQsyncMode();
void SetVsyncStatus(bool enable);
void SendBacklight();
void SendDisplayConfigs();

const uint32_t kPuTimeOutMs = 1000;
std::vector<HWEvent> event_list_;
Expand Down

0 comments on commit 9dd6bd5

Please sign in to comment.