Merge "hwc: Reset the refresh rate alone to avoid stack corruption."
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index 5949f27..8c8eb35 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -555,6 +555,13 @@
if(!isEnabled()) {
ALOGD_IF(isDebug(),"%s: MDP Comp. not enabled.", __FUNCTION__);
ret = false;
+ } else if (ctx->isDMAStateChanging) {
+ // Bail out if a padding round has been invoked in order to switch DMA
+ // state to block mode. We need this to cater for the case when a layer
+ // requires rotation in the current frame.
+ ALOGD_IF(isDebug(), "%s: padding round invoked to switch DMA state",
+ __FUNCTION__);
+ ret = false;
} else if(ctx->mVideoTransFlag && isSecondaryConnected(ctx)) {
//1 Padding round to shift pipes across mixers
ALOGD_IF(isDebug(),"%s: MDP Comp. video transition padding round",
@@ -584,13 +591,6 @@
__FUNCTION__,mDpy);
ret = false;
}
- } else if (ctx->isDMAStateChanging) {
- // Bail out if a padding round has been invoked in order to switch DMA
- // state to block mode. We need this to cater for the case when a layer
- // requires rotation in the current frame.
- ALOGD_IF(isDebug(), "%s: padding round invoked to switch DMA state",
- __FUNCTION__);
- return false;
}
return ret;
diff --git a/sdm/include/core/display_interface.h b/sdm/include/core/display_interface.h
index b16e43c..68bd5b1 100644
--- a/sdm/include/core/display_interface.h
+++ b/sdm/include/core/display_interface.h
@@ -97,11 +97,9 @@
float y_dpi; //!< Dots per inch in Y-direction.
uint32_t fps; //!< Frame rate per second.
uint32_t vsync_period_ns; //!< VSync period in nanoseconds.
- uint32_t v_total; //!< Total height of panel (vActive + vFP + vBP + vPulseWidth).
- uint32_t h_total; //!< Total width of panel (hActive + hFP + hBP + hPulseWidth).
DisplayConfigVariableInfo() : x_pixels(0), y_pixels(0), x_dpi(0.0f), y_dpi(0.0f),
- fps(0), vsync_period_ns(0), v_total(0), h_total(0) { }
+ fps(0), vsync_period_ns(0) { }
};
/*! @brief Event data associated with VSync event.
diff --git a/sdm/include/private/hw_info_types.h b/sdm/include/private/hw_info_types.h
index 2d639a8..fdfc582 100644
--- a/sdm/include/private/hw_info_types.h
+++ b/sdm/include/private/hw_info_types.h
@@ -88,6 +88,11 @@
uint32_t max_pipe_bw;
uint32_t max_sde_clk;
float clk_fudge_factor;
+ uint32_t macrotile_nv12_factor;
+ uint32_t macrotile_factor;
+ uint32_t linear_factor;
+ uint32_t scale_factor;
+ uint32_t extra_fudge_factor;
bool has_bwc;
bool has_ubwc;
bool has_decimation;
@@ -101,9 +106,11 @@
num_cursor_pipe(0), num_blending_stages(0), num_rotator(0), num_control(0),
num_mixer_to_disp(0), smp_total(0), smp_size(0), num_smp_per_pipe(0), max_scale_up(1),
max_scale_down(1), max_bandwidth_low(0), max_bandwidth_high(0), max_mixer_width(2048),
- max_pipe_width(2048), max_pipe_bw(0), max_sde_clk(0), clk_fudge_factor(1.0f), has_bwc(false),
- has_ubwc(false), has_decimation(false), has_macrotile(false), has_rotator_downscale(false),
- has_non_scalar_rgb(false), is_src_split(false) { }
+ max_pipe_width(2048), max_pipe_bw(0), max_sde_clk(0), clk_fudge_factor(1.0f),
+ macrotile_nv12_factor(0), macrotile_factor(0), linear_factor(0), scale_factor(0),
+ extra_fudge_factor(0), has_bwc(false), has_ubwc(false), has_decimation(false),
+ has_macrotile(false), has_rotator_downscale(false), has_non_scalar_rgb(false),
+ is_src_split(false) { }
void Reset() { *this = HWResourceInfo(); }
};
@@ -198,15 +205,15 @@
};
struct HWRotateInfo {
- uint32_t pipe_id;
+ int pipe_id;
+ int writeback_id;
LayerRect src_roi;
LayerRect dst_roi;
- HWBlockType writeback_id;
bool valid;
int rotate_id;
HWRotateInfo()
- : pipe_id(0), writeback_id(kHWWriteback0), valid(false), rotate_id(-1) { }
+ : pipe_id(-1), writeback_id(-1), valid(false), rotate_id(-1) { }
void Reset() { *this = HWRotateInfo(); }
};
@@ -316,8 +323,13 @@
bool is_device_split;
uint32_t split_left;
bool always_src_split;
+ uint32_t v_front_porch; //!< Vertical front porch of panel
+ uint32_t v_back_porch; //!< Vertical back porch of panel
+ uint32_t v_pulse_width; //!< Vertical pulse width of panel
+ uint32_t h_total; //!< Total width of panel (hActive + hFP + hBP + hPulseWidth)
- HWDisplayAttributes() : is_device_split(false), split_left(0), always_src_split(false) { }
+ HWDisplayAttributes() : is_device_split(false), split_left(0), always_src_split(false),
+ v_front_porch(0), v_back_porch(0), v_pulse_width(0), h_total(0) { }
void Reset() { *this = HWDisplayAttributes(); }
@@ -327,7 +339,10 @@
(always_src_split != attributes.always_src_split) ||
(x_pixels != attributes.x_pixels) || (y_pixels != attributes.y_pixels) ||
(x_dpi != attributes.x_dpi) || (y_dpi != attributes.y_dpi) || (fps != attributes.fps) ||
- (vsync_period_ns != attributes.vsync_period_ns) || (v_total != attributes.v_total));
+ (vsync_period_ns != attributes.vsync_period_ns) ||
+ (v_front_porch != attributes.v_front_porch) ||
+ (v_back_porch != attributes.v_back_porch) ||
+ (v_pulse_width != attributes.v_pulse_width));
}
bool operator ==(const HWDisplayAttributes &attributes) {
diff --git a/sdm/include/utils/debug.h b/sdm/include/utils/debug.h
index 2a9cc72..5b08129 100644
--- a/sdm/include/utils/debug.h
+++ b/sdm/include/utils/debug.h
@@ -33,6 +33,7 @@
#include <stdint.h>
#include <core/sdm_types.h>
#include <core/debug_interface.h>
+#include <core/display_interface.h>
#define DLOG(tag, method, format, ...) Debug::Get()->method(tag, __CLASS__ "::%s: " format, \
__FUNCTION__, ##__VA_ARGS__)
@@ -65,7 +66,8 @@
static bool IsRotatorDownScaleDisabled();
static bool IsDecimationDisabled();
static bool IsPartialUpdateEnabled();
- static int GetMaxPipesPerMixer();
+ static int GetMaxPipesPerMixer(DisplayType display_type);
+ static bool IsVideoModeEnabled();
private:
Debug();
diff --git a/sdm/libs/core/display_base.cpp b/sdm/libs/core/display_base.cpp
index 73b26f5..fcc69bb 100644
--- a/sdm/libs/core/display_base.cpp
+++ b/sdm/libs/core/display_base.cpp
@@ -93,7 +93,7 @@
HWResourceInfo hw_resource_info = HWResourceInfo();
hw_info_intf_->GetHWResourceInfo(&hw_resource_info);
int max_mixer_stages = hw_resource_info.num_blending_stages;
- int property_value = Debug::GetMaxPipesPerMixer();
+ int property_value = Debug::GetMaxPipesPerMixer(display_type_);
if (property_value >= 0) {
max_mixer_stages = MIN(UINT32(property_value), hw_resource_info.num_blending_stages);
}
diff --git a/sdm/libs/core/display_primary.cpp b/sdm/libs/core/display_primary.cpp
index 4c4a1dd..1b0a552 100644
--- a/sdm/libs/core/display_primary.cpp
+++ b/sdm/libs/core/display_primary.cpp
@@ -65,6 +65,14 @@
hw_primary_intf_->SetIdleTimeoutMs(Debug::GetIdleTimeoutMs());
}
+ if (hw_panel_info_.mode == kModeCommand && Debug::IsVideoModeEnabled()) {
+ error = hw_primary_intf_->SetDisplayMode(kModeVideo);
+ if (error != kErrorNone) {
+ DLOGW("Retaining current display mode. Current = %d, Requested = %d", hw_panel_info_.mode,
+ kModeVideo);
+ }
+ }
+
return error;
}
@@ -198,7 +206,7 @@
HWDisplayMode hw_display_mode = kModeDefault;
if (state_ != kStateOn) {
- DLOGW("Invalid display state (%d). Panel must be on.", state_);
+ DLOGW("Invalid display state = %d. Panel must be on.", state_);
return kErrorNotSupported;
}
@@ -210,19 +218,19 @@
hw_display_mode = kModeCommand;
break;
default:
- DLOGW("Invalid panel mode parameters. Requested (%d)", mode);
+ DLOGW("Invalid panel mode parameters. Requested = %d", mode);
return kErrorParameters;
}
if (hw_display_mode == hw_panel_info_.mode) {
- DLOGW("Same display mode requested. Current (%d) Requested (%d)", hw_panel_info_.mode,
+ DLOGW("Same display mode requested. Current = %d, Requested = %d", hw_panel_info_.mode,
hw_display_mode);
return kErrorNone;
}
error = hw_primary_intf_->SetDisplayMode(hw_display_mode);
if (error != kErrorNone) {
- DLOGW("Retaining current display mode. Current (%d), Requested (%d)", hw_panel_info_.mode,
+ DLOGW("Retaining current display mode. Current = %d, Requested = %d", hw_panel_info_.mode,
hw_display_mode);
return error;
}
diff --git a/sdm/libs/core/fb/hw_device.cpp b/sdm/libs/core/fb/hw_device.cpp
index 54b00ff..31b3da9 100644
--- a/sdm/libs/core/fb/hw_device.cpp
+++ b/sdm/libs/core/fb/hw_device.cpp
@@ -445,8 +445,6 @@
if (hw_rotator_session->hw_block_count) {
input_buffer = &hw_rotator_session->output_buffer;
- close_(input_buffer->acquire_fence_fd);
- input_buffer->acquire_fence_fd = -1;
}
input_buffer->release_fence_fd = dup(mdp_commit.release_fence);
@@ -714,7 +712,7 @@
} else if (!strncmp(tokens[0], "min_fps", strlen("min_fps"))) {
panel_info->min_fps = atoi(tokens[1]);
} else if (!strncmp(tokens[0], "max_fps", strlen("max_fps"))) {
- panel_info->max_fps= atoi(tokens[1]);
+ panel_info->max_fps = atoi(tokens[1]);
} else if (!strncmp(tokens[0], "primary_panel", strlen("primary_panel"))) {
panel_info->is_primary_panel = atoi(tokens[1]);
}
diff --git a/sdm/libs/core/fb/hw_hdmi.cpp b/sdm/libs/core/fb/hw_hdmi.cpp
index 3abda13..3df8e38 100644
--- a/sdm/libs/core/fb/hw_hdmi.cpp
+++ b/sdm/libs/core/fb/hw_hdmi.cpp
@@ -223,8 +223,9 @@
}
display_attributes->x_pixels = timing_mode->active_h;
display_attributes->y_pixels = timing_mode->active_v;
- display_attributes->v_total = timing_mode->active_v + timing_mode->front_porch_v +
- timing_mode->back_porch_v + timing_mode->pulse_width_v;
+ display_attributes->v_front_porch = timing_mode->front_porch_v;
+ display_attributes->v_back_porch = timing_mode->back_porch_v;
+ display_attributes->v_pulse_width = timing_mode->pulse_width_v;
uint32_t h_blanking = timing_mode->front_porch_h + timing_mode->back_porch_h +
timing_mode->pulse_width_h;
display_attributes->h_total = timing_mode->active_h + h_blanking;
diff --git a/sdm/libs/core/fb/hw_info.cpp b/sdm/libs/core/fb/hw_info.cpp
index 2b8a49d..c3fb41d 100644
--- a/sdm/libs/core/fb/hw_info.cpp
+++ b/sdm/libs/core/fb/hw_info.cpp
@@ -132,6 +132,16 @@
hw_resource->max_sde_clk = atoi(tokens[1]);
} else if (!strncmp(tokens[0], "clk_fudge_factor", strlen("clk_fudge_factor"))) {
hw_resource->clk_fudge_factor = FLOAT(atoi(tokens[1])) / FLOAT(atoi(tokens[2]));
+ } else if (!strncmp(tokens[0], "fmt_mt_nv12_factor", strlen("fmt_mt_nv12_factor"))) {
+ hw_resource->macrotile_nv12_factor = atoi(tokens[1]);
+ } else if (!strncmp(tokens[0], "fmt_mt_factor", strlen("fmt_mt_factor"))) {
+ hw_resource->macrotile_factor = atoi(tokens[1]);
+ } else if (!strncmp(tokens[0], "fmt_linear_factor", strlen("fmt_linear_factor"))) {
+ hw_resource->linear_factor = atoi(tokens[1]);
+ } else if (!strncmp(tokens[0], "scale_factor", strlen("scale_factor"))) {
+ hw_resource->scale_factor = atoi(tokens[1]);
+ } else if (!strncmp(tokens[0], "xtra_ff_factor", strlen("xtra_ff_factor"))) {
+ hw_resource->extra_fudge_factor = atoi(tokens[1]);
} else if (!strncmp(tokens[0], "features", strlen("features"))) {
for (uint32_t i = 0; i < token_count; i++) {
if (!strncmp(tokens[i], "bwc", strlen("bwc"))) {
@@ -166,6 +176,9 @@
hw_resource->max_bandwidth_high);
DLOGI("MaxPipeBw = %"PRIu64" KBps, MaxSDEClock = %"PRIu64" Hz, ClockFudgeFactor = %f",
hw_resource->max_pipe_bw, hw_resource->max_sde_clk, hw_resource->clk_fudge_factor);
+ DLOGI("Prefill factors: Tiled_NV12 = %d, Tiled = %d, Linear = %d, Scale = %d, Fudge_factor = %d",
+ hw_resource->macrotile_nv12_factor, hw_resource->macrotile_factor,
+ hw_resource->linear_factor, hw_resource->scale_factor, hw_resource->extra_fudge_factor);
return kErrorNone;
}
diff --git a/sdm/libs/core/fb/hw_primary.cpp b/sdm/libs/core/fb/hw_primary.cpp
index 4d1dad1..284cb67 100644
--- a/sdm/libs/core/fb/hw_primary.cpp
+++ b/sdm/libs/core/fb/hw_primary.cpp
@@ -207,12 +207,12 @@
display_attributes_.x_pixels = var_screeninfo.xres;
display_attributes_.y_pixels = var_screeninfo.yres;
- display_attributes_.v_total = var_screeninfo.yres + var_screeninfo.lower_margin +
- var_screeninfo.upper_margin + var_screeninfo.vsync_len;
+ display_attributes_.v_front_porch = var_screeninfo.lower_margin;
+ display_attributes_.v_back_porch = var_screeninfo.upper_margin;
+ display_attributes_.v_pulse_width = var_screeninfo.vsync_len;
uint32_t h_blanking = var_screeninfo.right_margin + var_screeninfo.left_margin +
var_screeninfo.hsync_len;
- display_attributes_.h_total = var_screeninfo.xres + var_screeninfo.right_margin +
- var_screeninfo.left_margin + var_screeninfo.hsync_len;
+ display_attributes_.h_total = var_screeninfo.xres + h_blanking;
display_attributes_.x_dpi =
(FLOAT(var_screeninfo.xres) * 25.4f) / FLOAT(var_screeninfo.width);
display_attributes_.y_dpi =
diff --git a/sdm/libs/hwc/hwc_display.cpp b/sdm/libs/hwc/hwc_display.cpp
index 8dce4c4..24bfcaa 100644
--- a/sdm/libs/hwc/hwc_display.cpp
+++ b/sdm/libs/hwc/hwc_display.cpp
@@ -30,6 +30,7 @@
#include <math.h>
#include <errno.h>
#include <gralloc_priv.h>
+#include <gr.h>
#include <utils/constants.h>
#include <qdMetaData.h>
#include <sync/sync.h>
@@ -58,9 +59,9 @@
return -EINVAL;
}
- char property[PROPERTY_VALUE_MAX];
- if (property_get("debug.egl.swapinterval", property, "1") > 0) {
- if (atoi(property) == 0) {
+ int property_swap_interval = 1;
+ if (HWCDebugHandler::Get()->GetProperty("debug.egl.swapinterval", &property_swap_interval)) {
+ if (property_swap_interval == 0) {
swap_interval_zero_ = true;
}
}
@@ -326,6 +327,87 @@
return 0;
}
+int HWCDisplay::PrepareLayerParams(hwc_layer_1_t *hwc_layer, Layer *layer, uint32_t fps) {
+ const private_handle_t *pvt_handle = static_cast<const private_handle_t *>(hwc_layer->handle);
+
+ LayerBuffer *layer_buffer = layer->input_buffer;
+
+ if (pvt_handle) {
+ layer_buffer->format = GetSDMFormat(pvt_handle->format, pvt_handle->flags);
+ if (layer_buffer->format == kFormatInvalid) {
+ return -EINVAL;
+ }
+
+ layer_buffer->width = pvt_handle->width;
+ layer_buffer->height = pvt_handle->height;
+ if (pvt_handle->bufferType == BUFFER_TYPE_VIDEO) {
+ layer_stack_.flags.video_present = true;
+ layer_buffer->flags.video = true;
+ }
+ if (pvt_handle->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER) {
+ layer_stack_.flags.secure_present = true;
+ layer_buffer->flags.secure = true;
+ }
+
+ layer->frame_rate = fps;
+ MetaData_t *meta_data = reinterpret_cast<MetaData_t *>(pvt_handle->base_metadata);
+ if (meta_data && meta_data->operation & UPDATE_REFRESH_RATE) {
+ layer->frame_rate = RoundToStandardFPS(meta_data->refreshrate);
+ }
+
+ if (meta_data && meta_data->operation == PP_PARAM_INTERLACED && meta_data->interlaced) {
+ layer_buffer->flags.interlace = true;
+ }
+
+ if (pvt_handle->flags & private_handle_t::PRIV_FLAGS_SECURE_DISPLAY) {
+ layer_buffer->flags.secure_display = true;
+ }
+ } else {
+ // for FBT layer
+ if (hwc_layer->compositionType == HWC_FRAMEBUFFER_TARGET) {
+ uint32_t x_pixels;
+ uint32_t y_pixels;
+ int aligned_width;
+ int aligned_height;
+ int usage = GRALLOC_USAGE_HW_FB;
+ int format = HAL_PIXEL_FORMAT_RGBA_8888;
+ int ubwc_enabled = 0;
+ HWCDebugHandler::Get()->GetProperty("debug.gralloc.enable_fb_ubwc", &ubwc_enabled);
+ if (ubwc_enabled == 1) {
+ usage |= GRALLOC_USAGE_PRIVATE_ALLOC_UBWC;
+ }
+
+ GetFrameBufferResolution(&x_pixels, &y_pixels);
+
+ AdrenoMemInfo::getInstance().getAlignedWidthAndHeight(INT(x_pixels), INT(y_pixels), format,
+ usage, aligned_width, aligned_height);
+ layer_buffer->width = aligned_width;
+ layer_buffer->height = aligned_height;
+ layer->frame_rate = fps;
+ }
+ }
+
+ return 0;
+}
+
+void HWCDisplay::CommitLayerParams(hwc_layer_1_t *hwc_layer, Layer *layer) {
+ const private_handle_t *pvt_handle = static_cast<const private_handle_t *>(hwc_layer->handle);
+ LayerBuffer *layer_buffer = layer->input_buffer;
+
+ if (pvt_handle) {
+ layer_buffer->planes[0].fd = pvt_handle->fd;
+ layer_buffer->planes[0].offset = pvt_handle->offset;
+ layer_buffer->planes[0].stride = pvt_handle->width;
+ }
+
+ // if swapinterval property is set to 0 then close and reset the acquireFd
+ if (swap_interval_zero_ && hwc_layer->acquireFenceFd >= 0) {
+ close(hwc_layer->acquireFenceFd);
+ hwc_layer->acquireFenceFd = -1;
+ }
+ layer_buffer->acquire_fence_fd = hwc_layer->acquireFenceFd;
+}
+
int HWCDisplay::PrepareLayerStack(hwc_display_contents_1_t *content_list) {
if (!content_list || !content_list->numHwLayers) {
DLOGW("Invalid content list");
@@ -341,6 +423,7 @@
DisplayConfigVariableInfo active_config;
uint32_t active_config_index = 0;
display_intf_->GetActiveConfig(&active_config_index);
+ int ret;
display_intf_->GetConfig(active_config_index, &active_config);
@@ -352,36 +435,11 @@
Layer &layer = layer_stack_.layers[i];
LayerBuffer *layer_buffer = layer.input_buffer;
- if (pvt_handle) {
- layer_buffer->format = GetSDMFormat(pvt_handle->format, pvt_handle->flags);
- if (layer_buffer->format == kFormatInvalid) {
- return -EINVAL;
- }
+ ret = PrepareLayerParams(&content_list->hwLayers[i], &layer_stack_.layers[i],
+ active_config.fps);
- layer_buffer->width = pvt_handle->width;
- layer_buffer->height = pvt_handle->height;
- if (pvt_handle->bufferType == BUFFER_TYPE_VIDEO) {
- layer_stack_.flags.video_present = true;
- layer_buffer->flags.video = true;
- }
- if (pvt_handle->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER) {
- layer_stack_.flags.secure_present = true;
- layer_buffer->flags.secure = true;
- }
-
- layer.frame_rate = UINT32(active_config.fps);
- MetaData_t *meta_data = reinterpret_cast<MetaData_t *>(pvt_handle->base_metadata);
- if (meta_data && meta_data->operation & UPDATE_REFRESH_RATE) {
- layer.frame_rate = RoundToStandardFPS(meta_data->refreshrate);
- }
-
- if (meta_data && meta_data->operation == PP_PARAM_INTERLACED && meta_data->interlaced) {
- layer_buffer->flags.interlace = true;
- }
-
- if (pvt_handle->flags & private_handle_t::PRIV_FLAGS_SECURE_DISPLAY) {
- layer_buffer->flags.secure_display = true;
- }
+ if (ret != kErrorNone) {
+ return ret;
}
hwc_rect_t scaled_display_frame = hwc_layer.displayFrame;
@@ -391,7 +449,7 @@
SetRect(scaled_display_frame, &layer.dst_rect);
SetRect(hwc_layer.sourceCropf, &layer.src_rect);
for (size_t j = 0; j < hwc_layer.visibleRegionScreen.numRects; j++) {
- SetRect(hwc_layer.visibleRegionScreen.rects[j], &layer.visible_regions.rect[j]);
+ SetRect(hwc_layer.visibleRegionScreen.rects[j], &layer.visible_regions.rect[j]);
}
SetRect(hwc_layer.dirtyRect, &layer.dirty_regions.rect[0]);
SetComposition(hwc_layer.compositionType, &layer.composition);
@@ -480,22 +538,7 @@
if (!flush_) {
for (size_t i = 0; i < num_hw_layers; i++) {
- hwc_layer_1_t &hwc_layer = content_list->hwLayers[i];
- const private_handle_t *pvt_handle = static_cast<const private_handle_t *>(hwc_layer.handle);
- LayerBuffer *layer_buffer = layer_stack_.layers[i].input_buffer;
-
- if (pvt_handle) {
- layer_buffer->planes[0].fd = pvt_handle->fd;
- layer_buffer->planes[0].offset = pvt_handle->offset;
- layer_buffer->planes[0].stride = pvt_handle->width;
- }
-
- // if swapinterval property is set to 0 then close and reset the acquireFd
- if (swap_interval_zero_ && hwc_layer.acquireFenceFd >= 0) {
- close(hwc_layer.acquireFenceFd);
- hwc_layer.acquireFenceFd = -1;
- }
- layer_buffer->acquire_fence_fd = hwc_layer.acquireFenceFd;
+ CommitLayerParams(&content_list->hwLayers[i], &layer_stack_.layers[i]);
}
DisplayError error = display_intf_->Commit(&layer_stack_);
diff --git a/sdm/libs/hwc/hwc_display.h b/sdm/libs/hwc/hwc_display.h
index 6c602dc..b20b00b 100644
--- a/sdm/libs/hwc/hwc_display.h
+++ b/sdm/libs/hwc/hwc_display.h
@@ -98,7 +98,6 @@
virtual int PrepareLayerStack(hwc_display_contents_1_t *content_list);
virtual int CommitLayerStack(hwc_display_contents_1_t *content_list);
virtual int PostCommitLayerStack(hwc_display_contents_1_t *content_list);
- bool NeedsFrameBufferRefresh(hwc_display_contents_1_t *content_list);
void CacheLayerStackInfo(hwc_display_contents_1_t *content_list);
inline void SetRect(const hwc_rect_t &source, LayerRect *target);
inline void SetRect(const hwc_frect_t &source, LayerRect *target);
@@ -107,11 +106,9 @@
inline void SetBlending(const int32_t &source, LayerBlending *target);
int SetFormat(const int32_t &source, const int flags, LayerBufferFormat *target);
LayerBufferFormat GetSDMFormat(const int32_t &source, const int flags);
- void DumpInputBuffers(hwc_display_contents_1_t *content_list);
const char *GetHALPixelFormatString(int format);
const char *GetDisplayString();
void ScaleDisplayFrame(hwc_rect_t *display_frame);
- bool IsFrameBufferScaled();
void MarkLayersForGPUBypass(hwc_display_contents_1_t *content_list);
void CloseAcquireFences(hwc_display_contents_1_t *content_list);
uint32_t RoundToStandardFPS(uint32_t fps);
@@ -140,6 +137,13 @@
bool display_paused_;
bool use_metadata_refresh_rate_;
uint32_t metadata_refresh_rate_;
+
+ private:
+ bool IsFrameBufferScaled();
+ void DumpInputBuffers(hwc_display_contents_1_t *content_list);
+ bool NeedsFrameBufferRefresh(hwc_display_contents_1_t *content_list);
+ int PrepareLayerParams(hwc_layer_1_t *hwc_layer, Layer *layer, uint32_t fps);
+ void CommitLayerParams(hwc_layer_1_t *hwc_layer, Layer *layer);
};
inline int HWCDisplay::Perform(uint32_t operation, ...) {
diff --git a/sdm/libs/hwc/hwc_display_external.cpp b/sdm/libs/hwc/hwc_display_external.cpp
index 52c64d1..c3a07e7 100644
--- a/sdm/libs/hwc/hwc_display_external.cpp
+++ b/sdm/libs/hwc/hwc_display_external.cpp
@@ -37,21 +37,63 @@
namespace sdm {
-HWCDisplayExternal::HWCDisplayExternal(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
- : HWCDisplay(core_intf, hwc_procs, kHDMI, HWC_DISPLAY_EXTERNAL) {
+static void AdjustSourceResolution(uint32_t dst_width, uint32_t dst_height, uint32_t *src_width,
+ uint32_t *src_height) {
+ *src_height = (dst_width * (*src_height)) / (*src_width);
+ *src_width = dst_width;
}
-int HWCDisplayExternal::Init() {
- int status = 0;
+int HWCDisplayExternal::Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs,
+ uint32_t primary_width, uint32_t primary_height,
+ HWCDisplay **hwc_display) {
+ uint32_t external_width = 0;
+ uint32_t external_height = 0;
+ char property[PROPERTY_VALUE_MAX];
- status = HWCDisplay::Init();
- if (status != 0) {
+ HWCDisplay *hwc_display_external = new HWCDisplayExternal(core_intf, hwc_procs);
+ int status = hwc_display_external->Init();
+ if (status) {
+ delete hwc_display_external;
return status;
}
+ hwc_display_external->GetPanelResolution(&external_width, &external_height);
+
+ int downscale_enabled = 0;
+ HWCDebugHandler::Get()->GetProperty("sdm.debug.sde_downscale_enabled", &downscale_enabled);
+ if (downscale_enabled == 1) {
+ uint32_t primary_area = primary_width * primary_height;
+ uint32_t external_area = external_width * external_height;
+
+ if (primary_area > external_area) {
+ if (primary_height > primary_width) {
+ Swap(primary_height, primary_width);
+ }
+ AdjustSourceResolution(primary_width, primary_height,
+ &external_width, &external_height);
+ }
+ }
+
+ status = hwc_display_external->SetFrameBufferResolution(external_width, external_height);
+ if (status) {
+ Destroy(hwc_display_external);
+ return status;
+ }
+
+ *hwc_display = hwc_display_external;
+
return status;
}
+void HWCDisplayExternal::Destroy(HWCDisplay *hwc_display) {
+ hwc_display->Deinit();
+ delete hwc_display;
+}
+
+HWCDisplayExternal::HWCDisplayExternal(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
+ : HWCDisplay(core_intf, hwc_procs, kHDMI, HWC_DISPLAY_EXTERNAL) {
+}
+
int HWCDisplayExternal::Prepare(hwc_display_contents_1_t *content_list) {
int status = 0;
@@ -109,11 +151,11 @@
}
// Read user defined width and height ratio
- char property[PROPERTY_VALUE_MAX];
- property_get("persist.sys.actionsafe.width", property, "0");
- float width_ratio = FLOAT(atoi(property)) / 100.0f;
- property_get("persist.sys.actionsafe.height", property, "0");
- float height_ratio = FLOAT(atoi(property)) / 100.0f;
+ int width = 0, height = 0;
+ HWCDebugHandler::Get()->GetProperty("sdm.external_action_safe_width", &width);
+ float width_ratio = FLOAT(width) / 100.0f;
+ HWCDebugHandler::Get()->GetProperty("sdm.external_action_safe_height", &height);
+ float height_ratio = FLOAT(height) / 100.0f;
if (width_ratio == 0.0f || height_ratio == 0.0f) {
return;
diff --git a/sdm/libs/hwc/hwc_display_external.h b/sdm/libs/hwc/hwc_display_external.h
index 6d3e229..a98ade3 100644
--- a/sdm/libs/hwc/hwc_display_external.h
+++ b/sdm/libs/hwc/hwc_display_external.h
@@ -31,13 +31,16 @@
class HWCDisplayExternal : public HWCDisplay {
public:
- explicit HWCDisplayExternal(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
- virtual int Init();
+ static int Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs, uint32_t primary_width,
+ uint32_t primary_height, HWCDisplay **hwc_display);
+ static void Destroy(HWCDisplay *hwc_display);
virtual int Prepare(hwc_display_contents_1_t *content_list);
virtual int Commit(hwc_display_contents_1_t *content_list);
virtual int GetDisplayConfigs(uint32_t *configs, size_t *num_configs);
+
private:
- virtual void ApplyScanAdjustment(hwc_rect_t *display_frame);
+ HWCDisplayExternal(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
+ void ApplyScanAdjustment(hwc_rect_t *display_frame);
};
} // namespace sdm
diff --git a/sdm/libs/hwc/hwc_display_primary.cpp b/sdm/libs/hwc/hwc_display_primary.cpp
index 3769d69..60505b0 100644
--- a/sdm/libs/hwc/hwc_display_primary.cpp
+++ b/sdm/libs/hwc/hwc_display_primary.cpp
@@ -27,6 +27,7 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <cutils/properties.h>
#include <utils/constants.h>
#include <stdarg.h>
@@ -37,6 +38,51 @@
namespace sdm {
+int HWCDisplayPrimary::Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs,
+ HWCDisplay **hwc_display) {
+ int status = 0;
+ uint32_t primary_width = 0;
+ uint32_t primary_height = 0;
+ char property[PROPERTY_VALUE_MAX];
+
+ HWCDisplay *hwc_display_primary = new HWCDisplayPrimary(core_intf, hwc_procs);
+ status = hwc_display_primary->Init();
+ if (status) {
+ delete hwc_display_primary;
+ return status;
+ }
+
+ status = hwc_display_primary->SetPowerMode(HWC_POWER_MODE_NORMAL);
+ if (status) {
+ Destroy(hwc_display_primary);
+ return status;
+ }
+
+ hwc_display_primary->GetPanelResolution(&primary_width, &primary_height);
+ int width = 0, height = 0;
+ HWCDebugHandler::Get()->GetProperty("sdm.fb_size_width", &width);
+ HWCDebugHandler::Get()->GetProperty("sdm.fb_size_height", &height);
+ if (width > 0 && height > 0) {
+ primary_width = width;
+ primary_height = height;
+ }
+
+ status = hwc_display_primary->SetFrameBufferResolution(primary_width, primary_height);
+ if (status) {
+ Destroy(hwc_display_primary);
+ return status;
+ }
+
+ *hwc_display = hwc_display_primary;
+
+ return status;
+}
+
+void HWCDisplayPrimary::Destroy(HWCDisplay *hwc_display) {
+ hwc_display->Deinit();
+ delete hwc_display;
+}
+
HWCDisplayPrimary::HWCDisplayPrimary(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
: HWCDisplay(core_intf, hwc_procs, kPrimary, HWC_DISPLAY_PRIMARY) {
}
diff --git a/sdm/libs/hwc/hwc_display_primary.h b/sdm/libs/hwc/hwc_display_primary.h
index b65457b..2b923a3 100644
--- a/sdm/libs/hwc/hwc_display_primary.h
+++ b/sdm/libs/hwc/hwc_display_primary.h
@@ -30,20 +30,24 @@
namespace sdm {
class HWCDisplayPrimary : public HWCDisplay {
-public:
+ public:
enum {
SET_METADATA_DYN_REFRESH_RATE,
SET_BINDER_DYN_REFRESH_RATE,
SET_DISPLAY_MODE,
};
- explicit HWCDisplayPrimary(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
+ static int Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs,
+ HWCDisplay **hwc_display);
+ static void Destroy(HWCDisplay *hwc_display);
virtual int Prepare(hwc_display_contents_1_t *content_list);
virtual int Commit(hwc_display_contents_1_t *content_list);
virtual int SetActiveConfig(uint32_t index);
virtual int SetRefreshRate(uint32_t refresh_rate);
virtual int Perform(uint32_t operation, ...);
-private:
+
+ private:
+ HWCDisplayPrimary(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
void SetMetaDataRefreshRateFlag(bool enable);
virtual DisplayError SetDisplayMode(uint32_t mode);
};
diff --git a/sdm/libs/hwc/hwc_display_virtual.cpp b/sdm/libs/hwc/hwc_display_virtual.cpp
index 4d01d28..319c0ee 100644
--- a/sdm/libs/hwc/hwc_display_virtual.cpp
+++ b/sdm/libs/hwc/hwc_display_virtual.cpp
@@ -30,6 +30,7 @@
#include <utils/constants.h>
#include <sync/sync.h>
#include <stdarg.h>
+#include <gr.h>
#include "hwc_display_virtual.h"
#include "hwc_debugger.h"
@@ -38,7 +39,7 @@
namespace sdm {
-static int GetWidthFromMetaData(const private_handle_t* handle) {
+static int GetWidthFromMetaData(const private_handle_t *handle) {
MetaData_t *metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
if (metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
return metadata->bufferDim.sliceWidth;
@@ -47,7 +48,7 @@
return handle->width;
}
-static int GetHeightFromMetaData(const private_handle_t* handle) {
+static int GetHeightFromMetaData(const private_handle_t *handle) {
MetaData_t *metadata = reinterpret_cast<MetaData_t *>(handle->base_metadata);
if (metadata && metadata->operation & UPDATE_BUFFER_GEOMETRY) {
return metadata->bufferDim.sliceHeight;
@@ -56,6 +57,46 @@
return handle->height;
}
+int HWCDisplayVirtual::Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs,
+ hwc_display_contents_1_t *content_list,
+ HWCDisplay **hwc_display) {
+ int status = 0;
+ HWCDisplay *hwc_display_virtual = new HWCDisplayVirtual(core_intf, hwc_procs);
+
+ status = hwc_display_virtual->Init();
+ if (status) {
+ delete hwc_display_virtual;
+ return status;
+ }
+
+ status = hwc_display_virtual->SetPowerMode(HWC_POWER_MODE_NORMAL);
+ if (status) {
+ Destroy(hwc_display_virtual);
+ return status;
+ }
+
+ const private_handle_t *output_handle =
+ static_cast<const private_handle_t *>(content_list->outbuf);
+ int virtual_width = 0;
+ int virtual_height = 0;
+ getBufferSizeAndDimensions(output_handle->width, output_handle->height, output_handle->format,
+ virtual_width, virtual_height);
+ status = hwc_display_virtual->SetFrameBufferResolution(virtual_width, virtual_height);
+ if (status) {
+ Destroy(hwc_display_virtual);
+ return status;
+ }
+
+ *hwc_display = hwc_display_virtual;
+
+ return status;
+}
+
+void HWCDisplayVirtual::Destroy(HWCDisplay *hwc_display) {
+ hwc_display->Deinit();
+ delete hwc_display;
+}
+
HWCDisplayVirtual::HWCDisplayVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs)
: HWCDisplay(core_intf, hwc_procs, kVirtual, HWC_DISPLAY_VIRTUAL),
dump_output_layer_(false), output_buffer_(NULL) {
@@ -89,6 +130,12 @@
int HWCDisplayVirtual::Prepare(hwc_display_contents_1_t *content_list) {
int status = 0;
+
+ status = SetOutputSliceFromMetadata(content_list);
+ if (status) {
+ return status;
+ }
+
if (display_paused_) {
MarkLayersForGPUBypass(content_list);
return status;
@@ -151,15 +198,7 @@
return 0;
}
-int HWCDisplayVirtual::Perform(uint32_t operation, ...) {
- if(operation != SET_OUTPUT_SLICE_FROM_METADATA) {
- return -EINVAL;
- }
-
- va_list args;
- va_start(args, operation);
- hwc_display_contents_1_t *content_list = va_arg(args, hwc_display_contents_1_t *);
- va_end(args);
+int HWCDisplayVirtual::SetOutputSliceFromMetadata(hwc_display_contents_1_t *content_list) {
const private_handle_t *output_handle =
static_cast<const private_handle_t *>(content_list->outbuf);
DisplayError error = kErrorNone;
diff --git a/sdm/libs/hwc/hwc_display_virtual.h b/sdm/libs/hwc/hwc_display_virtual.h
index 40088fb..e680f71 100644
--- a/sdm/libs/hwc/hwc_display_virtual.h
+++ b/sdm/libs/hwc/hwc_display_virtual.h
@@ -33,29 +33,27 @@
class HWCDisplayVirtual : public HWCDisplay {
public:
- enum {
- SET_OUTPUT_SLICE_FROM_METADATA,
- };
-
- explicit HWCDisplayVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
+ static int Create(CoreInterface *core_intf, hwc_procs_t const **hwc_procs,
+ hwc_display_contents_1_t *content_list, HWCDisplay **hwc_display);
+ static void Destroy(HWCDisplay *hwc_display);
+ static bool IsValidContentList(hwc_display_contents_1_t *content_list);
virtual int Init();
virtual int Deinit();
virtual int Prepare(hwc_display_contents_1_t *content_list);
virtual int Commit(hwc_display_contents_1_t *content_list);
virtual void SetFrameDumpConfig(uint32_t count, uint32_t bit_mask_layer_type);
- virtual int Perform(uint32_t operation, ...);
-
- static bool ValidateContentList(hwc_display_contents_1_t *content_list);
private:
+ HWCDisplayVirtual(CoreInterface *core_intf, hwc_procs_t const **hwc_procs);
int SetOutputBuffer(hwc_display_contents_1_t *content_list);
void DumpOutputBuffer(hwc_display_contents_1_t *content_list);
+ int SetOutputSliceFromMetadata(hwc_display_contents_1_t *content_list);
bool dump_output_layer_;
LayerBuffer *output_buffer_;
};
-inline bool HWCDisplayVirtual::ValidateContentList(hwc_display_contents_1_t *content_list) {
+inline bool HWCDisplayVirtual::IsValidContentList(hwc_display_contents_1_t *content_list) {
return (content_list && content_list->numHwLayers > 0 && content_list->outbuf);
}
diff --git a/sdm/libs/hwc/hwc_session.cpp b/sdm/libs/hwc/hwc_session.cpp
index 8014ae5..b0ff93d 100644
--- a/sdm/libs/hwc/hwc_session.cpp
+++ b/sdm/libs/hwc/hwc_session.cpp
@@ -130,47 +130,26 @@
}
// Create and power on primary display
- hwc_display_[HWC_DISPLAY_PRIMARY] = new HWCDisplayPrimary(core_intf_, &hwc_procs_);
- if (!hwc_display_[HWC_DISPLAY_PRIMARY]) {
- CoreInterface::DestroyCore();
- return -ENOMEM;
- }
-
- status = hwc_display_[HWC_DISPLAY_PRIMARY]->Init();
+ status = HWCDisplayPrimary::Create(core_intf_, &hwc_procs_,
+ &hwc_display_[HWC_DISPLAY_PRIMARY]);
if (status) {
CoreInterface::DestroyCore();
- delete hwc_display_[HWC_DISPLAY_PRIMARY];
- hwc_display_[HWC_DISPLAY_PRIMARY] = 0;
- return status;
- }
-
- status = hwc_display_[HWC_DISPLAY_PRIMARY]->SetPowerMode(HWC_POWER_MODE_NORMAL);
- if (status) {
- hwc_display_[HWC_DISPLAY_PRIMARY]->Deinit();
- delete hwc_display_[HWC_DISPLAY_PRIMARY];
- hwc_display_[HWC_DISPLAY_PRIMARY] = 0;
- CoreInterface::DestroyCore();
return status;
}
if (pthread_create(&uevent_thread_, NULL, &HWCUeventThread, this) < 0) {
DLOGE("Failed to start = %s, error = %s", uevent_thread_name_);
- hwc_display_[HWC_DISPLAY_PRIMARY]->Deinit();
- delete hwc_display_[HWC_DISPLAY_PRIMARY];
+ HWCDisplayPrimary::Destroy(hwc_display_[HWC_DISPLAY_PRIMARY]);
hwc_display_[HWC_DISPLAY_PRIMARY] = 0;
CoreInterface::DestroyCore();
return -errno;
}
- SetFrameBufferResolution(HWC_DISPLAY_PRIMARY, NULL);
-
return 0;
}
int HWCSession::Deinit() {
- hwc_display_[HWC_DISPLAY_PRIMARY]->SetPowerMode(HWC_POWER_MODE_OFF);
- hwc_display_[HWC_DISPLAY_PRIMARY]->Deinit();
- delete hwc_display_[HWC_DISPLAY_PRIMARY];
+ HWCDisplayPrimary::Destroy(hwc_display_[HWC_DISPLAY_PRIMARY]);
hwc_display_[HWC_DISPLAY_PRIMARY] = 0;
uevent_thread_exit_ = true;
pthread_join(uevent_thread_, NULL);
@@ -241,15 +220,11 @@
for (ssize_t dpy = (num_displays - 1); dpy >= 0; dpy--) {
hwc_display_contents_1_t *content_list = displays[dpy];
- if(dpy == HWC_DISPLAY_VIRTUAL) {
+ if (dpy == HWC_DISPLAY_VIRTUAL) {
if (hwc_session->hwc_display_[HWC_DISPLAY_EXTERNAL]) {
continue;
}
- if (HWCDisplayVirtual::ValidateContentList(content_list)) {
- hwc_session->CreateVirtualDisplay(content_list);
- } else {
- hwc_session->DestroyVirtualDisplay();
- }
+ hwc_session->HandleVirtualDisplayLifeCycle(content_list);
}
if (hwc_session->hwc_display_[dpy]) {
@@ -275,7 +250,7 @@
for (size_t dpy = 0; dpy < num_displays; dpy++) {
hwc_display_contents_1_t *content_list = displays[dpy];
- if(dpy == HWC_DISPLAY_VIRTUAL) {
+ if (dpy == HWC_DISPLAY_VIRTUAL) {
if (hwc_session->hwc_display_[HWC_DISPLAY_EXTERNAL]) {
if (content_list) {
for (size_t i = 0; i < content_list->numHwLayers; i++) {
@@ -311,7 +286,7 @@
HWCSession *hwc_session = static_cast<HWCSession *>(device);
int status = -EINVAL;
- if(hwc_session->hwc_display_[disp]) {
+ if (hwc_session->hwc_display_[disp]) {
status = hwc_session->hwc_display_[disp]->EventControl(event, enable);
}
@@ -327,10 +302,10 @@
HWCSession *hwc_session = static_cast<HWCSession *>(device);
int status = -EINVAL;
- if(hwc_session->hwc_display_[disp]) {
+ if (hwc_session->hwc_display_[disp]) {
status = hwc_session->hwc_display_[disp]->SetPowerMode(mode);
}
- if(disp == HWC_DISPLAY_PRIMARY && hwc_session->hwc_display_[HWC_DISPLAY_VIRTUAL]) {
+ if (disp == HWC_DISPLAY_PRIMARY && hwc_session->hwc_display_[HWC_DISPLAY_VIRTUAL]) {
// Set the power mode for virtual display while setting power mode for primary, as SF
// does not invoke SetPowerMode() for virtual display.
status = hwc_session->hwc_display_[HWC_DISPLAY_VIRTUAL]->SetPowerMode(mode);
@@ -378,7 +353,7 @@
HWCSession *hwc_session = static_cast<HWCSession *>(device);
int status = -EINVAL;
- if(hwc_session->hwc_display_[disp]) {
+ if (hwc_session->hwc_display_[disp]) {
status = hwc_session->hwc_display_[disp]->GetDisplayConfigs(configs, num_configs);
}
@@ -395,7 +370,7 @@
HWCSession *hwc_session = static_cast<HWCSession *>(device);
int status = -EINVAL;
- if(hwc_session->hwc_display_[disp]) {
+ if (hwc_session->hwc_display_[disp]) {
status = hwc_session->hwc_display_[disp]->GetDisplayAttributes(config, attributes, values);
}
@@ -411,7 +386,7 @@
HWCSession *hwc_session = static_cast<HWCSession *>(device);
int active_config = -1;
- if(hwc_session->hwc_display_[disp]) {
+ if (hwc_session->hwc_display_[disp]) {
active_config = hwc_session->hwc_display_[disp]->GetActiveConfig();
}
@@ -427,57 +402,26 @@
HWCSession *hwc_session = static_cast<HWCSession *>(device);
int status = -EINVAL;
- if(hwc_session->hwc_display_[disp]) {
+ if (hwc_session->hwc_display_[disp]) {
status = hwc_session->hwc_display_[disp]->SetActiveConfig(index);
}
return status;
}
-int HWCSession::CreateVirtualDisplay(hwc_display_contents_1_t *content_list) {
+int HWCSession::HandleVirtualDisplayLifeCycle(hwc_display_contents_1_t *content_list) {
int status = 0;
- if (!hwc_display_[HWC_DISPLAY_VIRTUAL]) {
- // Create virtual display device
- hwc_display_[HWC_DISPLAY_VIRTUAL] = new HWCDisplayVirtual(core_intf_, &hwc_procs_);
+ if (HWCDisplayVirtual::IsValidContentList(content_list)) {
if (!hwc_display_[HWC_DISPLAY_VIRTUAL]) {
- // This is not catastrophic. Leave a warning message for now.
- DLOGW("Virtual Display creation failed");
- return -ENOMEM;
+ // Create virtual display device
+ status = HWCDisplayVirtual::Create(core_intf_, &hwc_procs_, content_list,
+ &hwc_display_[HWC_DISPLAY_VIRTUAL]);
}
-
- status = hwc_display_[HWC_DISPLAY_VIRTUAL]->Init();
- if (status) {
- goto CleanupOnError;
- }
-
- status = hwc_display_[HWC_DISPLAY_VIRTUAL]->SetPowerMode(HWC_POWER_MODE_NORMAL);
- if (status) {
- goto CleanupOnError;
- }
- }
-
- if (hwc_display_[HWC_DISPLAY_VIRTUAL]) {
- SetFrameBufferResolution(HWC_DISPLAY_VIRTUAL, content_list);
- status = hwc_display_[HWC_DISPLAY_VIRTUAL]->Perform(
- HWCDisplayVirtual::SET_OUTPUT_SLICE_FROM_METADATA, content_list);
- }
-
- return status;
-
-CleanupOnError:
- DestroyVirtualDisplay();
- return status;
-}
-
-int HWCSession::DestroyVirtualDisplay() {
- int status = 0;
-
- if (hwc_display_[HWC_DISPLAY_VIRTUAL]) {
- status = hwc_display_[HWC_DISPLAY_VIRTUAL]->Deinit();
- if (!status) {
- delete hwc_display_[HWC_DISPLAY_VIRTUAL];
- hwc_display_[HWC_DISPLAY_VIRTUAL] = NULL;
+ } else {
+ if (hwc_display_[HWC_DISPLAY_VIRTUAL]) {
+ HWCDisplayVirtual::Destroy(hwc_display_[HWC_DISPLAY_VIRTUAL]);
+ hwc_display_[HWC_DISPLAY_VIRTUAL] = 0;
// Signal the HotPlug thread to continue with the external display connection
locker_.Signal();
}
@@ -543,7 +487,7 @@
uint32_t display_status = UINT32(input_parcel->readInt32());
DLOGI("Display %d Status %d", display_id, display_status);
- if(display_id < HWC_DISPLAY_EXTERNAL || display_id > HWC_DISPLAY_VIRTUAL) {
+ if (display_id < HWC_DISPLAY_EXTERNAL || display_id > HWC_DISPLAY_VIRTUAL) {
DLOGW("Not supported for display %d", display_id);
return -EINVAL;
}
@@ -780,28 +724,24 @@
DLOGE("HDMI already connected");
return -1;
}
+
+ uint32_t primary_width = 0;
+ uint32_t primary_height = 0;
+ hwc_display_[HWC_DISPLAY_PRIMARY]->GetFrameBufferResolution(&primary_width, &primary_height);
// Create hdmi display
- hwc_display_[HWC_DISPLAY_EXTERNAL] = new HWCDisplayExternal(core_intf_, &hwc_procs_);
- if (!hwc_display_[HWC_DISPLAY_EXTERNAL]) {
- return -1;
- }
- int status = hwc_display_[HWC_DISPLAY_EXTERNAL]->Init();
+ int status = HWCDisplayExternal::Create(core_intf_, &hwc_procs_, primary_width,
+ primary_height, &hwc_display_[HWC_DISPLAY_EXTERNAL]);
if (status) {
- delete hwc_display_[HWC_DISPLAY_EXTERNAL];
- hwc_display_[HWC_DISPLAY_EXTERNAL] = NULL;
- return -1;
+ return status;
}
- SetFrameBufferResolution(HWC_DISPLAY_EXTERNAL, NULL);
} else {
SEQUENCE_WAIT_SCOPE_LOCK(locker_);
if (!hwc_display_[HWC_DISPLAY_EXTERNAL]) {
DLOGE("HDMI not connected");
return -1;
}
- hwc_display_[HWC_DISPLAY_EXTERNAL]->SetPowerMode(HWC_POWER_MODE_OFF);
- hwc_display_[HWC_DISPLAY_EXTERNAL]->Deinit();
- delete hwc_display_[HWC_DISPLAY_EXTERNAL];
- hwc_display_[HWC_DISPLAY_EXTERNAL] = NULL;
+ HWCDisplayExternal::Destroy(hwc_display_[HWC_DISPLAY_EXTERNAL]);
+ hwc_display_[HWC_DISPLAY_EXTERNAL] = 0;
}
// notify client and trigger a screen refresh
@@ -811,72 +751,5 @@
return 0;
}
-void HWCSession::SetFrameBufferResolution(int disp, hwc_display_contents_1_t *content_list) {
- char property[PROPERTY_VALUE_MAX];
- uint32_t primary_width = 0;
- uint32_t primary_height = 0;
-
- switch (disp) {
- case HWC_DISPLAY_PRIMARY:
- {
- hwc_display_[HWC_DISPLAY_PRIMARY]->GetPanelResolution(&primary_width, &primary_height);
- if (property_get("debug.hwc.fbsize", property, NULL) > 0) {
- char *yptr = strcasestr(property, "x");
- primary_width = atoi(property);
- primary_height = atoi(yptr + 1);
- }
- hwc_display_[HWC_DISPLAY_PRIMARY]->SetFrameBufferResolution(primary_width, primary_height);
- break;
- }
-
- case HWC_DISPLAY_EXTERNAL:
- {
- uint32_t external_width = 0;
- uint32_t external_height = 0;
- hwc_display_[HWC_DISPLAY_EXTERNAL]->GetPanelResolution(&external_width, &external_height);
-
- if (property_get("sys.hwc.mdp_downscale_enabled", property, "false") &&
- !strcmp(property, "true")) {
- hwc_display_[HWC_DISPLAY_PRIMARY]->GetFrameBufferResolution(&primary_width, &primary_height);
- uint32_t primary_area = primary_width * primary_height;
- uint32_t external_area = external_width * external_height;
-
- if (primary_area > external_area) {
- if (primary_height > primary_width) {
- Swap(primary_height, primary_width);
- }
- AdjustSourceResolution(primary_width, primary_height,
- &external_width, &external_height);
- }
- }
- hwc_display_[HWC_DISPLAY_EXTERNAL]->SetFrameBufferResolution(external_width, external_height);
- break;
- }
-
- case HWC_DISPLAY_VIRTUAL:
- {
- if (HWCDisplayVirtual::ValidateContentList(content_list)) {
- const private_handle_t *output_handle =
- static_cast<const private_handle_t *>(content_list->outbuf);
- int virtual_width = 0;
- int virtual_height = 0;
- getBufferSizeAndDimensions(output_handle->width, output_handle->height, output_handle->format,
- virtual_width, virtual_height);
- hwc_display_[HWC_DISPLAY_VIRTUAL]->SetFrameBufferResolution(virtual_width, virtual_height);
- }
- break;
- }
-
- default:
- break;
- }
-}
-
-void HWCSession::AdjustSourceResolution(uint32_t dst_width, uint32_t dst_height,
- uint32_t *src_width, uint32_t *src_height) {
- *src_height = (dst_width * (*src_height)) / (*src_width);
- *src_width = dst_width;
-}
-
} // namespace sdm
diff --git a/sdm/libs/hwc/hwc_session.h b/sdm/libs/hwc/hwc_session.h
index 6d4a07a..5f844eb 100644
--- a/sdm/libs/hwc/hwc_session.h
+++ b/sdm/libs/hwc/hwc_session.h
@@ -76,8 +76,7 @@
int GetEventValue(const char *uevent_data, int length, const char *event_info);
int HotPlugHandler(bool connected);
void ResetPanel();
- int CreateVirtualDisplay(hwc_display_contents_1_t *content_list);
- int DestroyVirtualDisplay();
+ int HandleVirtualDisplayLifeCycle(hwc_display_contents_1_t *content_list);
// QClient methods
virtual android::status_t notifyCallback(uint32_t command, const android::Parcel *input_parcel,
@@ -87,9 +86,6 @@
android::status_t SetMaxMixerStages(const android::Parcel *input_parcel);
android::status_t SetDisplayMode(const android::Parcel *input_parcel);
android::status_t SetSecondaryDisplayStatus(const android::Parcel *input_parcel);
- void SetFrameBufferResolution(int disp, hwc_display_contents_1_t *content_list);
- void AdjustSourceResolution(uint32_t dst_width, uint32_t dst_height,
- uint32_t *src_width, uint32_t *src_height);
android::status_t ConfigureRefreshRate(const android::Parcel *input_parcel);
static Locker locker_;
diff --git a/sdm/libs/utils/debug.cpp b/sdm/libs/utils/debug.cpp
index abcfac1..cd7533b 100644
--- a/sdm/libs/utils/debug.cpp
+++ b/sdm/libs/utils/debug.cpp
@@ -40,7 +40,7 @@
uint32_t Debug::GetSimulationFlag() {
int value = 0;
- debug_.debug_handler_->GetProperty("debug.hwc.simulate", &value);
+ debug_.debug_handler_->GetProperty("sdm.composition_simulation", &value);
return value;
}
@@ -54,14 +54,14 @@
uint32_t Debug::GetIdleTimeoutMs() {
int value = IDLE_TIMEOUT_DEFAULT_MS;
- debug_.debug_handler_->GetProperty("debug.mdpcomp.idletime", &value);
+ debug_.debug_handler_->GetProperty("sdm.idle_time", &value);
return value;
}
bool Debug::IsRotatorDownScaleDisabled() {
int value = 0;
- debug_.debug_handler_->GetProperty("sdm.disable_rotator_downscaling", &value);
+ debug_.debug_handler_->GetProperty("sdm.debug.rotator_downscale", &value);
return (value == 1);
}
@@ -75,17 +75,36 @@
bool Debug::IsPartialUpdateEnabled() {
int value = 0;
- debug_.debug_handler_->GetProperty("sdm.hwc.partial_update", &value);
+ debug_.debug_handler_->GetProperty("sdm.partial_update", &value);
return (value == 1);
}
-int Debug::GetMaxPipesPerMixer() {
+int Debug::GetMaxPipesPerMixer(DisplayType display_type) {
int value = -1;
- debug_.debug_handler_->GetProperty("persist.hwc.mdpcomp.maxpermixer", &value);
+ switch (display_type) {
+ case kPrimary:
+ debug_.debug_handler_->GetProperty("sdm.primary.mixer_stages", &value);
+ break;
+ case kHDMI:
+ debug_.debug_handler_->GetProperty("sdm.external.mixer_stages", &value);
+ break;
+ case kVirtual:
+ debug_.debug_handler_->GetProperty("sdm.virtual.mixer_stages", &value);
+ break;
+ default:
+ break;
+ }
return value;
}
+bool Debug::IsVideoModeEnabled() {
+ int value = 0;
+ debug_.debug_handler_->GetProperty("sdm.video_mode_panel", &value);
+
+ return (value == 1);
+}
+
} // namespace sdm