Skip to content

Commit

Permalink
sdm: add support for windowed display
Browse files Browse the repository at this point in the history
- window display feature is displaying framebuffer
  content in a given rectangle on panel.
- fill remaining area with default color i.e. black.
- inform SF with reduced display size but SDM
  will see the mixer resolution is equal to panel.
- window rectangle can be set using below property
     vendor.display.window_rect = 250,250,250,250

CRs-Fixed: 2200594
Change-Id: Ib4cd4ccd6839370b568dbcdbadcdd81cfae88af9
  • Loading branch information
Rajavenu Kyatham authored and Gerrit - the friendly Code Review server committed Jan 7, 2020
1 parent 3de8dd5 commit 2412cd0
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 5 deletions.
34 changes: 33 additions & 1 deletion composer/hwc_display.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright 2015 The Android Open Source Project
Expand Down Expand Up @@ -464,6 +464,12 @@ HWCDisplay::HWCDisplay(CoreInterface *core_intf, BufferAllocator *buffer_allocat
int HWCDisplay::Init() {
DisplayError error = kErrorNone;

Debug::GetWindowRect(&window_rect_.left, &window_rect_.top,
&window_rect_.right, &window_rect_.bottom);

DLOGI("Window rect : [%f %f %f %f]", window_rect_.left, window_rect_.top,
window_rect_.right, window_rect_.bottom);

HWCDebugHandler::Get()->GetProperty(ENABLE_NULL_DISPLAY_PROP, &null_display_mode_);
HWCDebugHandler::Get()->GetProperty(ENABLE_ASYNC_POWERMODE, &async_power_mode_);

Expand Down Expand Up @@ -1065,6 +1071,14 @@ HWC2::Error HWCDisplay::GetDisplayAttribute(hwc2_config_t config, HWC2::Attribut
}

DisplayConfigVariableInfo variable_config = variable_config_map_.at(config);

variable_config.x_pixels -= UINT32(window_rect_.right + window_rect_.left);
variable_config.y_pixels -= UINT32(window_rect_.bottom + window_rect_.top);
if (variable_config.x_pixels <= 0 || variable_config.y_pixels <= 0) {
DLOGE("window rects are not within the supported range");
return HWC2::Error::BadDisplay;
}

switch (attribute) {
case HWC2::Attribute::VsyncPeriod:
*out_value = INT32(variable_config.vsync_period_ns);
Expand Down Expand Up @@ -1873,6 +1887,19 @@ int HWCDisplay::SetFrameBufferConfig(uint32_t x_pixels, uint32_t y_pixels) {
return -EINVAL;
}

// Reduce the src_rect and dst_rect as per FBT config.
// SF sending reduced FBT but here the src_rect is equal to mixer which is
// higher than allocated buffer of FBT.
if (windowed_display_) {
x_pixels -= UINT32(window_rect_.right + window_rect_.left);
y_pixels -= UINT32(window_rect_.bottom + window_rect_.top);
}

if (x_pixels <= 0 || y_pixels <= 0) {
DLOGE("window rects are not within the supported range");
return -EINVAL;
}

// Create rects to represent the new source and destination crops
LayerRect crop = LayerRect(0, 0, FLOAT(x_pixels), FLOAT(y_pixels));
hwc_rect_t scaled_display_frame = {0, 0, INT(x_pixels), INT(y_pixels)};
Expand All @@ -1894,6 +1921,11 @@ int HWCDisplay::SetFrameBufferResolution(uint32_t x_pixels, uint32_t y_pixels) {
return error;
}

if (windowed_display_) {
x_pixels -= UINT32(window_rect_.right + window_rect_.left);
y_pixels -= UINT32(window_rect_.bottom + window_rect_.top);
windowed_display_ = false;
}
auto client_target_layer = client_target_->GetSDMLayer();

int aligned_width;
Expand Down
4 changes: 3 additions & 1 deletion composer/hwc_display.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright 2015 The Android Open Source Project
Expand Down Expand Up @@ -484,6 +484,8 @@ class HWCDisplay : public DisplayEventHandler {
bool pending_config_ = false;
bool has_client_composition_ = false;
HWCBufferSyncHandler buffer_sync_handler_ = {};
LayerRect window_rect_ = {};
bool windowed_display_ = true;

private:
void DumpInputBuffers(void);
Expand Down
3 changes: 2 additions & 1 deletion include/display_properties.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -129,6 +129,7 @@
// Add all persist.vendor.display.properties above

#define ZERO_SWAP_INTERVAL "vendor.debug.egl.swapinterval"
#define WINDOW_RECT_PROP DISPLAY_PROP("window_rect")

// Add all other.properties above
// End of property
Expand Down
3 changes: 2 additions & 1 deletion sdm/include/utils/debug.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2014 - 2018, 2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -60,6 +60,7 @@ class Debug {
static bool IsPartialSplitDisabled();
static bool IsSrcSplitPreferred();
static DisplayError GetMixerResolution(uint32_t *width, uint32_t *height);
static DisplayError GetWindowRect(float *left, float *top, float *right, float *bottom);
static DisplayError GetReducedConfig(uint32_t *num_vig_pipes, uint32_t *num_dma_pipes);
static int GetExtMaxlayers();
static DisplayError GetProperty(const char *property_name, char *value);
Expand Down
26 changes: 25 additions & 1 deletion sdm/libs/utils/debug.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 - 2018, The Linux Foundation. All rights reserved.
* Copyright (c) 2014 - 2018, 2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -183,6 +183,30 @@ DisplayError Debug::GetMixerResolution(uint32_t *width, uint32_t *height) {
return kErrorNone;
}

DisplayError Debug::GetWindowRect(float *left, float *top, float *right, float *bottom) {
char value[64] = {};

int error = DebugHandler::Get()->GetProperty(WINDOW_RECT_PROP, value);
if (error != 0) {
return kErrorUndefined;
}

std::string str(value);
*left = FLOAT(stof(str));
str = (str.substr(str.find(',') + 1));
*top = FLOAT(stof(str));
str = (str.substr(str.find(',') + 1));
*right = FLOAT(stof(str));
str = (str.substr(str.find(',') + 1));
*bottom = FLOAT(stof(str));

if (*left < 0 || *top < 0 || *right < 0 || *bottom < 0) {
*left = *top = *right = *bottom = 0;
}

return kErrorNone;
}

DisplayError Debug::GetReducedConfig(uint32_t *num_vig_pipes, uint32_t *num_dma_pipes) {
char value[64] = {};

Expand Down

0 comments on commit 2412cd0

Please sign in to comment.