sdm: Update layer parameters based on panel orientation

Update layer rotation parameters with panel orientation.
Recalculate destination rect for all layers.

CRs-fixed: 1112326
Change-Id: I95f6428c77b23cf2437c319f6ab519aa3ad245e9
This commit is contained in:
Pullakavi Srinivas
2016-12-30 12:51:06 +05:30
committed by Gerrit - the friendly Code Review server
parent 9b50abe92f
commit 1494a93fc8
5 changed files with 55 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2015-2017, 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 met:
@@ -224,6 +224,12 @@ struct HWColorPrimaries {
uint32_t blue[2] = {}; // Blue color primary
};
struct HWPanelOrientation {
bool rotation = false;
bool flip_horizontal = false;
bool flip_vertical = false;
};
struct HWPanelInfo {
DisplayPort port = kPortDefault; // Display port
HWDisplayMode mode = kModeDefault; // Display mode
@@ -253,6 +259,7 @@ struct HWPanelInfo {
uint32_t average_luminance = 0; // Panel's average luminance level
uint32_t blackness_level = 0; // Panel's blackness level
HWColorPrimaries primaries = {}; // WRGB color primaries
HWPanelOrientation panel_orientation = {}; // Panel Orientation
bool operator !=(const HWPanelInfo &panel_info) {
return ((port != panel_info.port) || (mode != panel_info.mode) ||

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2015-2017, 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
@@ -57,6 +57,7 @@ namespace sdm {
bool flip_horizontal, LayerRect *out_rects);
void MapRect(const LayerRect &src_domain, const LayerRect &dst_domain, const LayerRect &in_rect,
LayerRect *out_rect);
void TransformHV(const LayerRect &src_domain, const LayerRect &in_rect, LayerRect *out_rect);
RectOrientation GetOrientation(const LayerRect &in_rect);
} // namespace sdm

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2014 - 2017, 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 met:
@@ -88,6 +88,29 @@ DisplayError DisplayPrimary::Prepare(LayerStack *layer_stack) {
uint32_t new_mixer_height = 0;
uint32_t display_width = display_attributes_.x_pixels;
uint32_t display_height = display_attributes_.y_pixels;
bool needs_hv_flip = hw_panel_info_.panel_orientation.flip_horizontal &&
hw_panel_info_.panel_orientation.flip_vertical;
LayerRect src_domain = {};
DisplayConfigVariableInfo variable_info = {};
if (needs_hv_flip) {
DisplayBase::GetFrameBufferConfig(&variable_info);
src_domain.right = variable_info.x_pixels;
src_domain.bottom = variable_info.y_pixels;
for (Layer *layer : layer_stack->layers) {
// Modify destination based on panel flip
TransformHV(src_domain, layer->dst_rect, &layer->dst_rect);
if (layer->flags.solid_fill) {
continue;
}
layer->transform.flip_horizontal ^= (hw_panel_info_.panel_orientation.flip_horizontal);
layer->transform.flip_vertical ^= (hw_panel_info_.panel_orientation.flip_vertical);
// TODO(user): Check how to handle rotation, if panel has rotation.
}
}
if (NeedsMixerReconfiguration(layer_stack, &new_mixer_width, &new_mixer_height)) {
error = ReconfigureMixer(new_mixer_width, new_mixer_height);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 - 2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2014 - 2017, 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
@@ -899,6 +899,11 @@ void HWDevice::GetHWPanelInfoByNode(int device_node, HWPanelInfo *panel_info) {
panel_info->primaries.blue[0] = UINT32(atoi(tokens[1]));
} else if (!strncmp(tokens[0], "blue_chromaticity_y", strlen("blue_chromaticity_y"))) {
panel_info->primaries.blue[1] = UINT32(atoi(tokens[1]));
} else if (!strncmp(tokens[0], "panel_orientation", strlen("panel_orientation"))) {
int32_t panel_orient = atoi(tokens[1]);
panel_info->panel_orientation.flip_horizontal = ((panel_orient & MDP_FLIP_LR) > 0);
panel_info->panel_orientation.flip_vertical = ((panel_orient & MDP_FLIP_UD) > 0);
panel_info->panel_orientation.rotation = ((panel_orient & MDP_ROT_90) > 0);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
* Copyright (c) 2015-2017, 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
@@ -223,6 +223,20 @@ void MapRect(const LayerRect &src_domain, const LayerRect &dst_domain, const Lay
out_rect->bottom = dst_domain.top + (height_ratio * modified_in_rect.bottom);
}
void TransformHV(const LayerRect &src_domain, const LayerRect &in_rect, LayerRect *out_rect) {
if (!IsValid(src_domain) || !IsValid(in_rect)) {
return;
}
float in_width = in_rect.right - in_rect.left;
float in_height = in_rect.bottom - in_rect.top;
out_rect->right = src_domain.right - in_rect.left;
out_rect->bottom = src_domain.bottom - in_rect.top;
out_rect->left = out_rect->right - in_width;
out_rect->top = out_rect->bottom - in_height;
}
RectOrientation GetOrientation(const LayerRect &in_rect) {
if (!IsValid(in_rect)) {
return kOrientationUnknown;