Merge "hwc: hdmi: Add check for interlaced formats"
diff --git a/Android.mk b/Android.mk
index a128327..5070911 100644
--- a/Android.mk
+++ b/Android.mk
@@ -5,6 +5,7 @@
endif
display-hals := libgralloc libcopybit liblight libmemtrack libqservice libqdutils
+display-hals += hdmi_cec
ifeq ($(TARGET_USES_SDE), true)
sde-libs := displayengine/libs
diff --git a/displayengine/include/core/debug_interface.h b/displayengine/include/core/debug_interface.h
index c90e1ff..ff72321 100644
--- a/displayengine/include/core/debug_interface.h
+++ b/displayengine/include/core/debug_interface.h
@@ -48,6 +48,7 @@
kTagDriverConfig, //!< Debug log is tagged for driver config.
kTagBufferManager, //!< Debug log is tagged for buffer manager state transitions.
kTagOfflineCtrl, //!< Debug log is tagged for offline controller.
+ kTagScalar, //!< Debug log is tagged for Scalar Helper.
};
/*! @brief Display debug handler class.
diff --git a/displayengine/include/utils/constants.h b/displayengine/include/utils/constants.h
index 329dd86..447b22a 100644
--- a/displayengine/include/utils/constants.h
+++ b/displayengine/include/utils/constants.h
@@ -33,6 +33,7 @@
#define INT(exp) static_cast<int>(exp)
#define FLOAT(exp) static_cast<float>(exp)
#define UINT8(exp) static_cast<uint8_t>(exp)
+#define UINT16(exp) static_cast<uint16_t>(exp)
#define UINT32(exp) static_cast<uint32_t>(exp)
#define INT32(exp) static_cast<int32_t>(exp)
diff --git a/displayengine/libs/core/Android.mk b/displayengine/libs/core/Android.mk
index c4c3d87..b7d2478 100644
--- a/displayengine/libs/core/Android.mk
+++ b/displayengine/libs/core/Android.mk
@@ -4,11 +4,14 @@
LOCAL_MODULE := libsde
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES := hardware/qcom/display/displayengine/include/ \
- $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include \
- $(TARGET_OUT_HEADERS)/scalar/inc
+ $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_CFLAGS := -Wno-missing-field-initializers -Wno-unused-parameter \
-Wconversion -Wall -Werror \
-DLOG_TAG=\"SDE\"
+ifeq ($(TARGET_USES_SCALAR), true)
+ LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/scalar/inc
+ LOCAL_CFLAGS += -DUSES_SCALAR
+endif
LOCAL_SHARED_LIBRARIES := libdl libsdeutils libcutils
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
LOCAL_SRC_FILES := core_interface.cpp \
@@ -25,6 +28,7 @@
hw_interface.cpp \
hw_framebuffer.cpp \
dump_impl.cpp \
- buffer_manager.cpp
+ buffer_manager.cpp \
+ scalar_helper.cpp
include $(BUILD_SHARED_LIBRARY)
diff --git a/displayengine/libs/core/hw_framebuffer.cpp b/displayengine/libs/core/hw_framebuffer.cpp
index 69d1efa..f47361b 100644
--- a/displayengine/libs/core/hw_framebuffer.cpp
+++ b/displayengine/libs/core/hw_framebuffer.cpp
@@ -43,7 +43,7 @@
#include <utils/debug.h>
#include "hw_framebuffer.h"
-
+#include "scalar_helper.h"
#define __CLASS__ "HWFrameBuffer"
@@ -684,7 +684,7 @@
}
mdp_layer.alpha = layer.plane_alpha;
- mdp_layer.z_order = static_cast<uint16_t>(i);
+ mdp_layer.z_order = UINT16(pipe_info->z_order);
mdp_layer.transp_mask = 0xffffffff;
SetBlending(layer.blending, &mdp_layer.blend_op);
mdp_layer.pipe_ndx = pipe_info->pipe_id;
@@ -706,14 +706,16 @@
}
}
- if (pipe_info->scale_data.enable_pxl_ext) {
+ mdp_scale_data* mdp_scale = hw_display->GetScaleDataRef(mdp_layer_count);
+#ifdef USES_SCALAR
+ // Set the configured scale data for MDP driver
+ ScalarHelper::GetInstance()->SetScaleData(i, !count, mdp_scale);
+ if (mdp_scale->enable_pxl_ext) {
if ((mdp_layer.flags & MDP_LAYER_DEINTERLACE) && (layer.transform.rotation == 90.0f))
- mdp_buffer.width = pipe_info->scale_data.src_width;
- hw_display->SetScaleData(pipe_info->scale_data, mdp_layer_count);
+ ScalarHelper::GetInstance()->UpdateSrcWidth(i, !count, &mdp_buffer.width);
}
-
- // Send scale data to MDP driver
- mdp_layer.scale = hw_display->GetScaleRef(mdp_layer_count);
+#endif
+ mdp_layer.scale = mdp_scale;
mdp_layer_count++;
DLOGV_IF(kTagDriverConfig, "******************* Layer[%d] %s pipe Input ******************",
diff --git a/displayengine/libs/core/hw_framebuffer.h b/displayengine/libs/core/hw_framebuffer.h
index 68a0674..3ceb2b3 100644
--- a/displayengine/libs/core/hw_framebuffer.h
+++ b/displayengine/libs/core/hw_framebuffer.h
@@ -89,36 +89,7 @@
mdp_disp_commit.commit_v1.retire_fence = -1;
}
- mdp_scale_data* GetScaleRef(uint32_t index) { return &scale_data[index]; }
-
- void SetScaleData(scalar::Scale scale, uint32_t index) {
- mdp_scale_data *mdp_scale = &scale_data[index];
- mdp_scale->enable_pxl_ext = scale.enable_pxl_ext;
-
- for (int i = 0; i < MAX_PLANES; i++) {
- mdp_scale->init_phase_x[i] = scale.init_phase_x[i];
- mdp_scale->phase_step_x[i] = scale.phase_step_x[i];
- mdp_scale->init_phase_y[i] = scale.init_phase_y[i];
- mdp_scale->phase_step_y[i] = scale.phase_step_y[i];
-
- mdp_scale->num_ext_pxls_left[i] = scale.left.extension[i];
- mdp_scale->num_ext_pxls_top[i] = scale.top.extension[i];
- mdp_scale->num_ext_pxls_right[i] = scale.right.extension[i];
- mdp_scale->num_ext_pxls_btm[i] = scale.bottom.extension[i];
-
- mdp_scale->left_ftch[i] = scale.left.overfetch[i];
- mdp_scale->top_ftch[i] = scale.top.overfetch[i];
- mdp_scale->right_ftch[i] = scale.right.overfetch[i];
- mdp_scale->btm_ftch[i] = scale.bottom.overfetch[i];
-
- mdp_scale->left_rpt[i] = scale.left.repeat[i];
- mdp_scale->top_rpt[i] = scale.top.repeat[i];
- mdp_scale->right_rpt[i] = scale.right.repeat[i];
- mdp_scale->btm_rpt[i] = scale.bottom.repeat[i];
-
- mdp_scale->roi_w[i] = scale.roi_width[i];
- }
- }
+ mdp_scale_data* GetScaleDataRef(uint32_t index) { return &scale_data[index]; }
};
struct HWRotator {
diff --git a/displayengine/libs/core/hw_interface.h b/displayengine/libs/core/hw_interface.h
index 9e003bb..b92846f 100644
--- a/displayengine/libs/core/hw_interface.h
+++ b/displayengine/libs/core/hw_interface.h
@@ -30,7 +30,6 @@
#include <utils/constants.h>
#include <core/buffer_allocator.h>
#include <core/buffer_sync_handler.h>
-#include <scalar.h>
namespace sde {
@@ -89,8 +88,8 @@
HWResourceInfo()
: hw_version(0), hw_revision(0), num_dma_pipe(0), num_vig_pipe(0), num_rgb_pipe(0),
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(0),
- max_scale_down(0), max_bandwidth_low(0), max_bandwidth_high(0), max_mixer_width(2048),
+ 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_bw(0), max_sde_clk(0), clk_fudge_factor(1.0f), has_bwc(false),
has_decimation(false), has_macrotile(false), has_rotator_downscale(false),
has_non_scalar_rgb(false), is_src_split(false), always_src_split(false) { }
@@ -113,15 +112,14 @@
LayerRect dst_roi;
LayerBufferFormat dst_format;
HWBlockType writeback_id;
- float downscale_ratio_x;
- float downscale_ratio_y;
+ float downscale_ratio;
HWBufferInfo hw_buffer_info;
bool valid;
uint32_t frame_rate;
HWRotateInfo() : input_buffer(NULL), pipe_id(0), dst_format(kFormatInvalid),
- writeback_id(kHWWriteback0), downscale_ratio_x(1.0f), downscale_ratio_y(1.0f),
- valid(false), frame_rate(0) { }
+ writeback_id(kHWWriteback0), downscale_ratio(1.0f), valid(false),
+ frame_rate(0) { }
void Reset() { *this = HWRotateInfo(); }
};
@@ -132,10 +130,11 @@
LayerRect dst_roi;
uint8_t horizontal_decimation;
uint8_t vertical_decimation;
- scalar::Scale scale_data;
bool valid;
+ uint32_t z_order;
- HWPipeInfo() : pipe_id(0), horizontal_decimation(0), vertical_decimation(0), valid(false) { }
+ HWPipeInfo() : pipe_id(0), horizontal_decimation(0), vertical_decimation(0), valid(false),
+ z_order(0) { }
void Reset() { *this = HWPipeInfo(); }
};
diff --git a/displayengine/libs/core/res_config.cpp b/displayengine/libs/core/res_config.cpp
index 72edeb6..66f5cba 100644
--- a/displayengine/libs/core/res_config.cpp
+++ b/displayengine/libs/core/res_config.cpp
@@ -31,14 +31,11 @@
#define __CLASS__ "ResManager"
-using scalar::PipeInfo;
-using scalar::LayerInfo;
-
namespace sde {
-void ResManager::RotationConfig(const LayerTransform &transform, const float &scale_x,
- const float &scale_y, LayerRect *src_rect,
- struct HWLayerConfig *layer_config, uint32_t *rotate_count) {
+void ResManager::RotationConfig(const LayerTransform &transform, const float &downscale,
+ LayerRect *src_rect, struct HWLayerConfig *layer_config,
+ uint32_t *rotate_count) {
HWRotateInfo *rotate = &layer_config->rotates[0];
float src_width = src_rect->right - src_rect->left;
float src_height = src_rect->bottom - src_rect->top;
@@ -47,32 +44,27 @@
dst_rect.top = 0.0f;
dst_rect.left = 0.0f;
- rotate->downscale_ratio_x = scale_x;
- rotate->downscale_ratio_y = scale_y;
+ rotate->downscale_ratio = downscale;
// downscale when doing rotation
if (IsRotationNeeded(transform.rotation)) {
- if (rotate->downscale_ratio_x > 1.0f) {
- src_height = ROUND_UP_ALIGN_DOWN(src_height, rotate->downscale_ratio_x);
+ if (downscale > 1.0f) {
+ src_height = ROUND_UP_ALIGN_DOWN(src_height, downscale);
src_rect->bottom = src_rect->top + src_height;
- }
- if (rotate->downscale_ratio_y > 1.0f) {
- src_width = ROUND_UP_ALIGN_DOWN(src_width, rotate->downscale_ratio_y);
+ src_width = ROUND_UP_ALIGN_DOWN(src_width, downscale);
src_rect->right = src_rect->left + src_width;
}
- dst_rect.right = src_height / rotate->downscale_ratio_x;
- dst_rect.bottom = src_width / rotate->downscale_ratio_y;
+ dst_rect.right = src_height / downscale;
+ dst_rect.bottom = src_width / downscale;
} else {
- if (rotate->downscale_ratio_x > 1.0f) {
- src_width = ROUND_UP_ALIGN_DOWN(src_width, rotate->downscale_ratio_x);
+ if (downscale > 1.0f) {
+ src_width = ROUND_UP_ALIGN_DOWN(src_width, downscale);
src_rect->right = src_rect->left + src_width;
- }
- if (rotate->downscale_ratio_y > 1.0f) {
- src_height = ROUND_UP_ALIGN_DOWN(src_height, rotate->downscale_ratio_y);
+ src_height = ROUND_UP_ALIGN_DOWN(src_height, downscale);
src_rect->bottom = src_rect->top + src_height;
}
- dst_rect.right = src_width / rotate->downscale_ratio_x;
- dst_rect.bottom = src_height / rotate->downscale_ratio_y;
+ dst_rect.right = src_width / downscale;
+ dst_rect.bottom = src_height / downscale;
}
rotate->src_roi = *src_rect;
@@ -190,12 +182,6 @@
right_pipe->Reset();
}
- // TODO(user) remove this when zorder is assigned properly, check num_blending_stages on pipes
- if (!display_attributes.is_device_split && right_pipe->valid) {
- DLOGV_IF(kTagResources, "Non display split, do not support 2 pipes for now");
- return kErrorNotSupported;
- }
-
return kErrorNone;
}
@@ -205,10 +191,11 @@
HWDisplayAttributes &display_attributes = display_resource_ctx->display_attributes;
HWLayersInfo &layer_info = hw_layers->info;
DisplayError error = kErrorNone;
+ uint32_t z_order = 0;
for (uint32_t i = 0; i < layer_info.count; i++) {
Layer& layer = layer_info.stack->layers[layer_info.index[i]];
- float rot_scale_x = 1.0f, rot_scale_y = 1.0f;
+ float rot_scale = 1.0f;
if (!IsValidDimension(layer.src_rect, layer.dst_rect)) {
DLOGV_IF(kTagResources, "Input is invalid");
LogRect(kTagResources, "input layer src_rect", layer.src_rect);
@@ -241,7 +228,7 @@
NormalizeRect(align_x, align_y, &src_rect);
}
- if (ValidateScaling(layer, src_rect, dst_rect, &rot_scale_x, &rot_scale_y)) {
+ if (ValidateScaling(layer, src_rect, dst_rect, &rot_scale)) {
return kErrorNotSupported;
}
@@ -252,10 +239,8 @@
layer_config->num_rotate = 0;
LayerTransform transform = layer.transform;
- if (IsRotationNeeded(transform.rotation) ||
- UINT32(rot_scale_x) != 1 || UINT32(rot_scale_y) != 1) {
- RotationConfig(layer.transform, rot_scale_x, rot_scale_y, &src_rect, layer_config,
- rotate_count);
+ if (IsRotationNeeded(transform.rotation) || UINT32(rot_scale) != 1) {
+ RotationConfig(layer.transform, rot_scale, &src_rect, layer_config, rotate_count);
// rotator will take care of flipping, reset tranform
transform = LayerTransform();
}
@@ -282,8 +267,7 @@
LogRect(kTagResources, "input layer src_rect", layer.src_rect);
LogRect(kTagResources, "input layer dst_rect", layer.dst_rect);
for (uint32_t k = 0; k < layer_config->num_rotate; k++) {
- DLOGV_IF(kTagResources, "rotate num = %d, scale_x = %.2f, scale_y = %.2f",
- k, rot_scale_x, rot_scale_y);
+ DLOGV_IF(kTagResources, "rotate num = %d, scale_x = %.2f", k, rot_scale);
LogRect(kTagResources, "rotate src", layer_config->rotates[k].src_roi);
LogRect(kTagResources, "rotate dst", layer_config->rotates[k].dst_roi);
}
@@ -296,15 +280,32 @@
LogRect(kTagResources, "right pipe src", layer_config->right_pipe.src_roi);
LogRect(kTagResources, "right pipe dst", layer_config->right_pipe.dst_roi);
}
+ // set z_order, left_pipe should always be valid
+ left_pipe.z_order = z_order;
+ if (layer_config->right_pipe.valid) {
+ // use different z_order if 2 pipes are on one mixer and without src split support
+ if (!hw_res_info_.is_src_split &&
+ ((left_pipe.dst_roi.right <= display_attributes.split_left &&
+ right_pipe.dst_roi.right <= display_attributes.split_left) ||
+ (left_pipe.dst_roi.left >= display_attributes.split_left &&
+ right_pipe.dst_roi.left >= display_attributes.split_left))) {
+ z_order++;
+ }
+ layer_config->right_pipe.z_order = z_order;
+ }
+ z_order++;
+ if (z_order >= hw_res_info_.num_blending_stages) {
+ DLOGV_IF(kTagResources, "z_order is over the limit: z_order = %d", z_order);
+ return kErrorResources;
+ }
}
return error;
}
DisplayError ResManager::ValidateScaling(const Layer &layer, const LayerRect &crop,
- const LayerRect &dst, float *rot_scale_x,
- float *rot_scale_y) {
- bool rotated90 = IsRotationNeeded(layer.transform.rotation) && (rot_scale_x != NULL);
+ const LayerRect &dst, float *rot_scale) {
+ bool rotated90 = IsRotationNeeded(layer.transform.rotation) && (rot_scale != NULL);
float crop_width = rotated90 ? crop.bottom - crop.top : crop.right - crop.left;
float crop_height = rotated90 ? crop.right - crop.left : crop.bottom - crop.top;
float dst_width = dst.right - dst.left;
@@ -330,31 +331,43 @@
float scale_x = crop_width / dst_width;
float scale_y = crop_height / dst_height;
- bool use_rotator = false;
+ uint32_t rot_scale_local = 1;
if ((UINT32(scale_x) > 1) || (UINT32(scale_y) > 1)) {
- uint32_t max_scale_down = hw_res_info_.max_scale_down;
+ float max_scale_down = FLOAT(hw_res_info_.max_scale_down);
if (hw_res_info_.has_rotator_downscale && !property_setting_.disable_rotator_downscaling &&
- rot_scale_x) {
- max_scale_down *= kMaxRotateDownScaleRatio;
- use_rotator = true;
- } else if (hw_res_info_.has_decimation && !property_setting_.disable_decimation &&
- !IsMacroTileFormat(layer.input_buffer)) {
- max_scale_down *= kMaxDecimationDownScaleRatio;
+ rot_scale && !IsMacroTileFormat(layer.input_buffer)) {
+ float scale_min = MIN(scale_x, scale_y);
+ float scale_max = MAX(scale_x, scale_y);
+ // use rotator to downscale when over the pipe scaling ability
+ if (UINT32(scale_min) >= 2 && scale_max > max_scale_down) {
+ // downscaling ratio needs be the same for both direction, use the smaller one.
+ rot_scale_local = 1 << UINT32(ceilf(log2f(scale_min / max_scale_down)));
+ if (rot_scale_local > kMaxRotateDownScaleRatio)
+ rot_scale_local = kMaxRotateDownScaleRatio;
+ scale_x /= FLOAT(rot_scale_local);
+ scale_y /= FLOAT(rot_scale_local);
+ }
+ *rot_scale = FLOAT(rot_scale_local);
}
- if (scale_x > FLOAT(max_scale_down) || scale_y > FLOAT(max_scale_down)) {
+ if (hw_res_info_.has_decimation && !property_setting_.disable_decimation &&
+ !IsMacroTileFormat(layer.input_buffer)) {
+ max_scale_down *= FLOAT(kMaxDecimationDownScaleRatio);
+ }
+
+ if (scale_x > max_scale_down || scale_y > max_scale_down) {
DLOGV_IF(kTagResources,
"Scaling down is over the limit: is_tile = %d, scale_x = %.0f, scale_y = %.0f, " \
- "crop_w = %.0f, dst_w = %.0f, has_deci = %d, disable_deci = %d",
+ "crop_w = %.0f, dst_w = %.0f, has_deci = %d, disable_deci = %d, rot_scale = %d",
IsMacroTileFormat(layer.input_buffer), scale_x, scale_y, crop_width, dst_width,
- hw_res_info_.has_decimation, property_setting_.disable_decimation);
+ hw_res_info_.has_decimation, property_setting_.disable_decimation, rot_scale_local);
return kErrorNotSupported;
}
}
- const uint32_t max_scale_up = hw_res_info_.max_scale_up;
+ float max_scale_up = FLOAT(hw_res_info_.max_scale_up);
if (UINT32(scale_x) < 1 && scale_x > 0.0f) {
if ((1.0f / scale_x) > max_scale_up) {
DLOGV_IF(kTagResources, "Scaling up is over limit scale_x = %f", 1.0f / scale_x);
@@ -369,24 +382,8 @@
}
}
- if (rot_scale_x == NULL) {
- return kErrorNone;
- }
-
- // Calculate rotator downscale ratio
- if (scale_x > hw_res_info_.max_scale_down && use_rotator) {
- *rot_scale_x = FLOAT(1 << UINT32(ceilf(log2f(scale_x / FLOAT(hw_res_info_.max_scale_down)))));
- } else {
- *rot_scale_x = 1.0f;
- }
-
- if (scale_y > hw_res_info_.max_scale_down && use_rotator) {
- *rot_scale_y = FLOAT(1 << UINT32(ceilf(log2f(scale_y / FLOAT(hw_res_info_.max_scale_down)))));
- } else {
- *rot_scale_y = 1.0f;
- }
- DLOGV_IF(kTagResources, "scale_x = %.0f, scale_y = %.0f, rot_scale_x = %.0f, rot_scale_y = %.0f",
- scale_x, scale_y, *rot_scale_x, *rot_scale_y);
+ DLOGV_IF(kTagResources, "scale_x = %.4f, scale_y = %.4f, rot_scale = %d",
+ scale_x, scale_y, rot_scale_local);
return kErrorNone;
}
@@ -586,125 +583,6 @@
}
}
-// Scalar helper functions
-static void SetPipeInfo(HWPipeInfo* hw_pipe, PipeInfo* pipe) {
- pipe->id = hw_pipe->pipe_id;
- pipe->scale_data = &hw_pipe->scale_data;
- pipe->horz_deci = hw_pipe->horizontal_decimation;
- pipe->vert_deci = hw_pipe->vertical_decimation;
-
- pipe->src_rect.x = UINT32(hw_pipe->src_roi.left);
- pipe->src_rect.y = UINT32(hw_pipe->src_roi.top);
- pipe->src_rect.w = UINT32(hw_pipe->src_roi.right) - pipe->src_rect.x;
- pipe->src_rect.h = UINT32(hw_pipe->src_roi.bottom) - pipe->src_rect.y;
-
- pipe->dst_rect.x = UINT32(hw_pipe->dst_roi.left);
- pipe->dst_rect.y = UINT32(hw_pipe->dst_roi.top);
- pipe->dst_rect.w = UINT32(hw_pipe->dst_roi.right) - pipe->dst_rect.x;
- pipe->dst_rect.h = UINT32(hw_pipe->dst_roi.bottom) - pipe->dst_rect.y;
-}
-
-static void UpdateSrcRoi(PipeInfo* pipe, HWPipeInfo* hw_pipe) {
- hw_pipe->src_roi.left = FLOAT(pipe->src_rect.x);
- hw_pipe->src_roi.top = FLOAT(pipe->src_rect.y);
- hw_pipe->src_roi.right = FLOAT(pipe->src_rect.x + pipe->src_rect.w);
- hw_pipe->src_roi.bottom = FLOAT(pipe->src_rect.y + pipe->src_rect.h);
-}
-
-static uint32_t GetScalarFormat(LayerBufferFormat source) {
- uint32_t format = scalar::UNKNOWN_FORMAT;
-
- switch (source) {
- case kFormatARGB8888: format = scalar::ARGB_8888; break;
- case kFormatRGBA8888: format = scalar::RGBA_8888; break;
- case kFormatBGRA8888: format = scalar::BGRA_8888; break;
- case kFormatXRGB8888: format = scalar::XRGB_8888; break;
- case kFormatRGBX8888: format = scalar::RGBX_8888; break;
- case kFormatBGRX8888: format = scalar::BGRX_8888; break;
- case kFormatRGB888: format = scalar::RGB_888; break;
- case kFormatRGB565: format = scalar::RGB_565; break;
- case kFormatYCbCr420Planar: format = scalar::Y_CB_CR_H2V2; break;
- case kFormatYCrCb420Planar: format = scalar::Y_CR_CB_H2V2; break;
- case kFormatYCbCr420SemiPlanar: format = scalar::Y_CBCR_H2V2; break;
- case kFormatYCrCb420SemiPlanar: format = scalar::Y_CRCB_H2V2; break;
- case kFormatYCbCr422Packed: format = scalar::YCBYCR_H2V1; break;
- case kFormatYCbCr420SemiPlanarVenus: format = scalar::Y_CBCR_H2V2_VENUS; break;
- case kFormatRGBA8888Ubwc: format = scalar::RGBA_8888_UBWC; break;
- case kFormatRGB565Ubwc: format = scalar::RGB_565_UBWC; break;
- case kFormatYCbCr420SPVenusUbwc: format = scalar::Y_CBCR_H2V2_UBWC; break;
- default:
- DLOGE("Unsupported source format: %x", source);
- break;
- }
-
- return format;
-}
-
-bool ResManager::ConfigureScaling(HWLayers *hw_layers) {
- HWLayersInfo &hw_layer_info = hw_layers->info;
-
- for (uint32_t i = 0; i < hw_layer_info.count; i++) {
- Layer &layer = hw_layer_info.stack->layers[hw_layer_info.index[i]];
- LayerBuffer *input_buffer = layer.input_buffer;
- HWPipeInfo* left_pipe = &hw_layers->config[i].left_pipe;
- HWPipeInfo* right_pipe = &hw_layers->config[i].right_pipe;
-
- // Prepare data structure for lib scalar
- uint32_t flags = 0;
- struct LayerInfo layer_info;
-
- if (layer.transform.rotation == 90.0f) {
- // Flips will be taken care by rotator, if layer requires 90 rotation
- flags |= scalar::SCALAR_SOURCE_ROTATED_90;
- } else {
- flags |= layer.transform.flip_vertical ? scalar::SCALAR_FLIP_UD : 0;
- flags |= layer.transform.flip_horizontal ? scalar::SCALAR_FLIP_LR : 0;
- }
-
- for (uint32_t count = 0; count < 2; count++) {
- HWPipeInfo* hw_pipe = (count == 0) ? left_pipe : right_pipe;
- HWRotateInfo* rotate_info = &hw_layers->config[i].rotates[count];
- PipeInfo* scalar_pipe = (count == 0) ? &layer_info.left_pipe : &layer_info.right_pipe;
-
- if (rotate_info->valid)
- input_buffer = &rotate_info->hw_buffer_info.output_buffer;
-
- scalar_pipe->flags = flags;
- hw_pipe->scale_data.src_width = input_buffer->width;
- SetPipeInfo(hw_pipe, scalar_pipe);
- }
- layer_info.src_format = GetScalarFormat(input_buffer->format);
-
- DLOGV_IF(kTagResources, "Scalar Input[%d] flags=%x format=%x", i, flags, layer_info.src_format);
- DLOGV_IF(kTagResources, "Left: id=%d hD=%d vD=%d srcRect=[%d %d %d %d] dstRect=[%d %d %d %d]",
- layer_info.left_pipe.id, layer_info.left_pipe.horz_deci, layer_info.left_pipe.vert_deci,
- layer_info.left_pipe.src_rect.x, layer_info.left_pipe.src_rect.y,
- layer_info.left_pipe.src_rect.w, layer_info.left_pipe.src_rect.h,
- layer_info.left_pipe.dst_rect.x, layer_info.left_pipe.dst_rect.y,
- layer_info.left_pipe.dst_rect.w, layer_info.left_pipe.dst_rect.h);
- DLOGV_IF(kTagResources, "Right: id=%d hD=%d vD=%d srcRect=[%d %d %d %d] dstRect=[%d %d %d %d]",
- layer_info.right_pipe.id, layer_info.right_pipe.horz_deci, layer_info.right_pipe.vert_deci,
- layer_info.right_pipe.src_rect.x, layer_info.right_pipe.src_rect.y,
- layer_info.right_pipe.src_rect.w, layer_info.right_pipe.src_rect.h,
- layer_info.right_pipe.dst_rect.x, layer_info.right_pipe.dst_rect.y,
- layer_info.right_pipe.dst_rect.w, layer_info.right_pipe.dst_rect.h);
-
- // Configure scale data structure
- if (ScalarConfigureScale(&layer_info) < 0) {
- DLOGE("Scalar library failed to configure scale data!");
- return false;
- }
-
- // Update Src Roi in HWPipeInfo
- if (left_pipe->scale_data.enable_pxl_ext)
- UpdateSrcRoi(&layer_info.left_pipe, left_pipe);
- if (right_pipe->scale_data.enable_pxl_ext)
- UpdateSrcRoi(&layer_info.right_pipe, right_pipe);
- }
-
- return true;
-}
-
DisplayError ResManager::AlignPipeConfig(const Layer &layer, const LayerTransform &transform,
HWPipeInfo *left_pipe, HWPipeInfo *right_pipe,
uint32_t align_x, uint32_t align_y) {
@@ -735,13 +613,13 @@
right_pipe->dst_roi.left = left_pipe->dst_roi.right;
}
}
- error = ValidateScaling(layer, left_pipe->src_roi, left_pipe->dst_roi, NULL, NULL);
+ error = ValidateScaling(layer, left_pipe->src_roi, left_pipe->dst_roi, NULL);
if (error != kErrorNone) {
goto PipeConfigExit;
}
if (right_pipe->valid) {
- error = ValidateScaling(layer, right_pipe->src_roi, right_pipe->dst_roi, NULL, NULL);
+ error = ValidateScaling(layer, right_pipe->src_roi, right_pipe->dst_roi, NULL);
}
PipeConfigExit:
if (error != kErrorNone) {
diff --git a/displayengine/libs/core/res_manager.cpp b/displayengine/libs/core/res_manager.cpp
index dfd1e0a..9868ddf 100644
--- a/displayengine/libs/core/res_manager.cpp
+++ b/displayengine/libs/core/res_manager.cpp
@@ -28,9 +28,9 @@
#include <dlfcn.h>
#include "res_manager.h"
+#include "scalar_helper.h"
#define __CLASS__ "ResManager"
-#define SCALAR_LIBRARY_NAME "libscalar.so"
namespace sde {
@@ -98,7 +98,14 @@
if (hw_res_info_.num_rotator > kMaxNumRotator) {
DLOGE("Number of rotator is over the limit! %d", hw_res_info_.num_rotator);
- return kErrorParameters;
+ hw_res_info_.num_rotator = kMaxNumRotator;
+ }
+
+ if (hw_res_info_.max_scale_down < 1 || hw_res_info_.max_scale_up < 1) {
+ DLOGE("Max scaling setting is invalid! max_scale_down = %d, max_scale_up = %d",
+ hw_res_info_.max_scale_down, hw_res_info_.max_scale_up);
+ hw_res_info_.max_scale_down = 1;
+ hw_res_info_.max_scale_up = 1;
}
if (hw_res_info_.num_rotator > 0) {
@@ -114,23 +121,16 @@
rgb_pipes_[0].state = kPipeStateOwnedByKernel;
rgb_pipes_[1].state = kPipeStateOwnedByKernel;
- ScalarConfigureScale = NULL;
- lib_scalar_handle_ = dlopen(SCALAR_LIBRARY_NAME, RTLD_NOW);
- if (lib_scalar_handle_) {
- void **scalar_func = reinterpret_cast<void **>(&ScalarConfigureScale);
- *scalar_func = ::dlsym(lib_scalar_handle_, "configureScale");
- } else {
- DLOGW("Unable to load %s !", SCALAR_LIBRARY_NAME);
- }
-
+#ifdef USES_SCALAR
+ ScalarHelper::GetInstance()->Init();
+#endif
return kErrorNone;
}
DisplayError ResManager::Deinit() {
- if (lib_scalar_handle_) {
- dlclose(lib_scalar_handle_);
- lib_scalar_handle_ = NULL;
- }
+#ifdef USES_SCALAR
+ ScalarHelper::GetInstance()->Deinit();
+#endif
return kErrorNone;
}
@@ -274,6 +274,7 @@
DLOGV_IF(kTagResources, "==== Resource reserving start: hw_block = %d ====", hw_block_id);
if (layer_info.count > num_pipe_ || layer_info.count >= hw_res_info_.num_blending_stages) {
+ DLOGV_IF(kTagResources, "layer count is over the limit: layer count = %d", layer_info.count);
return kErrorResources;
}
@@ -390,12 +391,12 @@
goto CleanupOnError;
}
- if (lib_scalar_handle_ && ScalarConfigureScale) {
- if (!ConfigureScaling(hw_layers)) {
- DLOGV_IF(kTagResources, "Scale data configuration has failed!");
- goto CleanupOnError;
- }
+#ifdef USES_SCALAR
+ if (!ScalarHelper::GetInstance()->ConfigureScale(hw_layers)) {
+ DLOGV_IF(kTagResources, "Scale data configuration has failed!");
+ goto CleanupOnError;
}
+#endif
if (!CheckBandwidth(display_resource_ctx, hw_layers)) {
DLOGV_IF(kTagResources, "Bandwidth check failed!");
@@ -1128,8 +1129,5 @@
return;
}
-void* ResManager::lib_scalar_handle_ = NULL;
-int (*ResManager::ScalarConfigureScale)(struct scalar::LayerInfo* layer) = NULL;
-
} // namespace sde
diff --git a/displayengine/libs/core/res_manager.h b/displayengine/libs/core/res_manager.h
index eae6730..9ff5384 100644
--- a/displayengine/libs/core/res_manager.h
+++ b/displayengine/libs/core/res_manager.h
@@ -171,7 +171,7 @@
const LayerRect &dst_rect, HWLayerConfig *layer_config,
uint32_t align_x);
DisplayError ValidateScaling(const Layer &layer, const LayerRect &crop,
- const LayerRect &dst, float *rot_scale_x, float *rot_scale_y);
+ const LayerRect &dst, float *rot_scale);
DisplayError SrcSplitConfig(DisplayResourceContext *display_resource_ctx,
const LayerTransform &transform, const LayerRect &src_rect,
const LayerRect &dst_rect, HWLayerConfig *layer_config,
@@ -194,9 +194,9 @@
bool IsYuvFormat(LayerBufferFormat format) { return (format >= kFormatYCbCr420Planar); }
bool IsRotationNeeded(float rotation)
{ return (UINT32(rotation) == 90 || UINT32(rotation) == 270); }
- void RotationConfig(const LayerTransform &transform, const float &scale_x,
- const float &scale_y, LayerRect *src_rect,
- struct HWLayerConfig *layer_config, uint32_t *rotate_count);
+ void RotationConfig(const LayerTransform &transform, const float &downscale,
+ LayerRect *src_rect, struct HWLayerConfig *layer_config,
+ uint32_t *rotate_count);
DisplayError AcquireRotator(DisplayResourceContext *display_resource_ctx,
const uint32_t roate_cnt);
void AssignRotator(HWRotateInfo *rotate, uint32_t *rotate_cnt);
@@ -204,7 +204,6 @@
DisplayError AllocRotatorBuffer(Handle display_ctx, HWLayers *hw_layers);
void SetRotatorOutputFormat(const LayerBufferFormat &input_format, bool bwc, bool rot90,
LayerBufferFormat *output_format);
- bool ConfigureScaling(HWLayers *hw_layers);
DisplayError AlignPipeConfig(const Layer &layer, const LayerTransform &transform,
HWPipeInfo *left_pipe, HWPipeInfo *right_pipe,
uint32_t align_x, uint32_t align_y);
@@ -227,8 +226,6 @@
BufferAllocator *buffer_allocator_;
BufferSyncHandler *buffer_sync_handler_; // Pointer to buffer sync handler that was defined by
// the display engine's client
- static void* lib_scalar_handle_; // Scalar library handle
- static int (*ScalarConfigureScale)(struct scalar::LayerInfo* layer);
PropertySetting property_setting_;
};
diff --git a/displayengine/libs/core/scalar_helper.cpp b/displayengine/libs/core/scalar_helper.cpp
new file mode 100755
index 0000000..57c51c0
--- /dev/null
+++ b/displayengine/libs/core/scalar_helper.cpp
@@ -0,0 +1,228 @@
+/*
+* Copyright (c) 2015, 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:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifdef USES_SCALAR
+
+#include <dlfcn.h>
+#include <utils/debug.h>
+#include "scalar_helper.h"
+
+#define __CLASS__ "ScalarHelper"
+
+namespace sde {
+
+ScalarHelper* ScalarHelper::scalar_helper_ = NULL;
+
+ScalarHelper* ScalarHelper::GetInstance() {
+ if (scalar_helper_ == NULL) {
+ scalar_helper_ = new ScalarHelper();
+ }
+ return scalar_helper_;
+}
+
+// Scalar helper functions
+static void SetPipeInfo(HWPipeInfo* hw_pipe, scalar::PipeInfo* pipe) {
+ pipe->id = hw_pipe->pipe_id;
+ pipe->horz_deci = hw_pipe->horizontal_decimation;
+ pipe->vert_deci = hw_pipe->vertical_decimation;
+
+ pipe->src_rect.x = UINT32(hw_pipe->src_roi.left);
+ pipe->src_rect.y = UINT32(hw_pipe->src_roi.top);
+ pipe->src_rect.w = UINT32(hw_pipe->src_roi.right) - pipe->src_rect.x;
+ pipe->src_rect.h = UINT32(hw_pipe->src_roi.bottom) - pipe->src_rect.y;
+
+ pipe->dst_rect.x = UINT32(hw_pipe->dst_roi.left);
+ pipe->dst_rect.y = UINT32(hw_pipe->dst_roi.top);
+ pipe->dst_rect.w = UINT32(hw_pipe->dst_roi.right) - pipe->dst_rect.x;
+ pipe->dst_rect.h = UINT32(hw_pipe->dst_roi.bottom) - pipe->dst_rect.y;
+}
+
+static void UpdateSrcRoi(scalar::PipeInfo* pipe, HWPipeInfo* hw_pipe) {
+ hw_pipe->src_roi.left = FLOAT(pipe->src_rect.x);
+ hw_pipe->src_roi.top = FLOAT(pipe->src_rect.y);
+ hw_pipe->src_roi.right = FLOAT(pipe->src_rect.x + pipe->src_rect.w);
+ hw_pipe->src_roi.bottom = FLOAT(pipe->src_rect.y + pipe->src_rect.h);
+}
+
+static uint32_t GetScalarFormat(LayerBufferFormat source) {
+ uint32_t format = scalar::UNKNOWN_FORMAT;
+
+ switch (source) {
+ case kFormatARGB8888: format = scalar::ARGB_8888; break;
+ case kFormatRGBA8888: format = scalar::RGBA_8888; break;
+ case kFormatBGRA8888: format = scalar::BGRA_8888; break;
+ case kFormatXRGB8888: format = scalar::XRGB_8888; break;
+ case kFormatRGBX8888: format = scalar::RGBX_8888; break;
+ case kFormatBGRX8888: format = scalar::BGRX_8888; break;
+ case kFormatRGB888: format = scalar::RGB_888; break;
+ case kFormatRGB565: format = scalar::RGB_565; break;
+ case kFormatYCbCr420Planar: format = scalar::Y_CB_CR_H2V2; break;
+ case kFormatYCrCb420Planar: format = scalar::Y_CR_CB_H2V2; break;
+ case kFormatYCbCr420SemiPlanar: format = scalar::Y_CBCR_H2V2; break;
+ case kFormatYCrCb420SemiPlanar: format = scalar::Y_CRCB_H2V2; break;
+ case kFormatYCbCr422Packed: format = scalar::YCBYCR_H2V1; break;
+ case kFormatYCbCr420SemiPlanarVenus: format = scalar::Y_CBCR_H2V2_VENUS; break;
+ case kFormatRGBA8888Ubwc: format = scalar::RGBA_8888_UBWC; break;
+ case kFormatRGB565Ubwc: format = scalar::RGB_565_UBWC; break;
+ case kFormatYCbCr420SPVenusUbwc: format = scalar::Y_CBCR_H2V2_UBWC; break;
+ default:
+ DLOGE("Unsupported source format: %x", source);
+ break;
+ }
+ return format;
+}
+
+void ScalarHelper::Init() {
+ lib_scalar_handle_ = NULL;
+ ScalarConfigureScale = NULL;
+
+ lib_scalar_handle_ = dlopen(SCALAR_LIBRARY_NAME, RTLD_NOW);
+ if (lib_scalar_handle_) {
+ void **scalar_func = reinterpret_cast<void **>(&ScalarConfigureScale);
+ *scalar_func = ::dlsym(lib_scalar_handle_, "configureScale");
+ } else {
+ DLOGW("Unable to load %s !", SCALAR_LIBRARY_NAME);
+ }
+}
+
+void ScalarHelper::Deinit() {
+ if (lib_scalar_handle_) {
+ dlclose(lib_scalar_handle_);
+ lib_scalar_handle_ = NULL;
+ }
+}
+
+bool ScalarHelper::ConfigureScale(HWLayers *hw_layers) {
+
+ if (!lib_scalar_handle_ || !ScalarConfigureScale) {
+ // No scalar library
+ return true;
+ }
+
+ // Reset scale data
+ memset(&scale_data_, 0, sizeof(scale_data_));
+ HWLayersInfo &hw_layer_info = hw_layers->info;
+
+ for (uint32_t i = 0; i < hw_layer_info.count; i++) {
+ Layer &layer = hw_layer_info.stack->layers[hw_layer_info.index[i]];
+ LayerBuffer *input_buffer = layer.input_buffer;
+ HWPipeInfo* left_pipe = &hw_layers->config[i].left_pipe;
+ HWPipeInfo* right_pipe = &hw_layers->config[i].right_pipe;
+
+ // Prepare data structure for lib scalar
+ uint32_t flags = 0;
+ struct scalar::LayerInfo layer_info;
+
+ if (layer.transform.rotation == 90.0f) {
+ // Flips will be taken care by rotator, if layer requires 90 rotation
+ flags |= scalar::SCALAR_SOURCE_ROTATED_90;
+ } else {
+ flags |= layer.transform.flip_vertical ? scalar::SCALAR_FLIP_UD : 0;
+ flags |= layer.transform.flip_horizontal ? scalar::SCALAR_FLIP_LR : 0;
+ }
+
+ for (uint32_t count = 0; count < 2; count++) {
+ HWPipeInfo* hw_pipe = (count == 0) ? left_pipe : right_pipe;
+ HWRotateInfo* rotate_info = &hw_layers->config[i].rotates[count];
+ scalar::PipeInfo* pipe = (count == 0) ? &layer_info.left_pipe : &layer_info.right_pipe;
+
+ if (rotate_info->valid)
+ input_buffer = &rotate_info->hw_buffer_info.output_buffer;
+
+ pipe->flags = flags;
+ pipe->scale_data = GetScaleRef(i, !count);
+ pipe->scale_data->src_width = input_buffer->width;
+ SetPipeInfo(hw_pipe, pipe);
+ }
+ layer_info.src_format = GetScalarFormat(input_buffer->format);
+
+ DLOGV_IF(kTagScalar, "Scalar Input[%d] flags=%x format=%x", i, flags, layer_info.src_format);
+ DLOGV_IF(kTagScalar, "Left: id=%d hD=%d vD=%d srcRect=[%d %d %d %d] dstRect=[%d %d %d %d]",
+ layer_info.left_pipe.id, layer_info.left_pipe.horz_deci, layer_info.left_pipe.vert_deci,
+ layer_info.left_pipe.src_rect.x, layer_info.left_pipe.src_rect.y,
+ layer_info.left_pipe.src_rect.w, layer_info.left_pipe.src_rect.h,
+ layer_info.left_pipe.dst_rect.x, layer_info.left_pipe.dst_rect.y,
+ layer_info.left_pipe.dst_rect.w, layer_info.left_pipe.dst_rect.h);
+ DLOGV_IF(kTagScalar, "Right: id=%d hD=%d vD=%d srcRect=[%d %d %d %d] dstRect=[%d %d %d %d]",
+ layer_info.right_pipe.id, layer_info.right_pipe.horz_deci, layer_info.right_pipe.vert_deci,
+ layer_info.right_pipe.src_rect.x, layer_info.right_pipe.src_rect.y,
+ layer_info.right_pipe.src_rect.w, layer_info.right_pipe.src_rect.h,
+ layer_info.right_pipe.dst_rect.x, layer_info.right_pipe.dst_rect.y,
+ layer_info.right_pipe.dst_rect.w, layer_info.right_pipe.dst_rect.h);
+
+ // Configure scale data structure
+ if (ScalarConfigureScale(&layer_info) < 0) {
+ DLOGE("Scalar library failed to configure scale data!");
+ return false;
+ }
+
+ // Update Src Roi in HWPipeInfo
+ if (layer_info.left_pipe.scale_data->enable_pxl_ext)
+ UpdateSrcRoi(&layer_info.left_pipe, left_pipe);
+ if (layer_info.right_pipe.scale_data->enable_pxl_ext)
+ UpdateSrcRoi(&layer_info.right_pipe, right_pipe);
+ }
+ return true;
+}
+
+void ScalarHelper::UpdateSrcWidth(uint32_t index, bool left, uint32_t* width) {
+ *width = GetScaleRef(index, left)->src_width;
+}
+
+void ScalarHelper::SetScaleData(uint32_t index, bool left, mdp_scale_data* mdp_scale) {
+
+ if (!lib_scalar_handle_ || !ScalarConfigureScale)
+ return;
+
+ scalar::Scale* scale = GetScaleRef(index, left);
+ mdp_scale->enable_pxl_ext = scale->enable_pxl_ext;
+
+ for (int i = 0; i < MAX_PLANES; i++) {
+ mdp_scale->init_phase_x[i] = scale->init_phase_x[i];
+ mdp_scale->phase_step_x[i] = scale->phase_step_x[i];
+ mdp_scale->init_phase_y[i] = scale->init_phase_y[i];
+ mdp_scale->phase_step_y[i] = scale->phase_step_y[i];
+
+ mdp_scale->num_ext_pxls_left[i] = scale->left.extension[i];
+ mdp_scale->num_ext_pxls_top[i] = scale->top.extension[i];
+ mdp_scale->num_ext_pxls_right[i] = scale->right.extension[i];
+ mdp_scale->num_ext_pxls_btm[i] = scale->bottom.extension[i];
+
+ mdp_scale->left_ftch[i] = scale->left.overfetch[i];
+ mdp_scale->top_ftch[i] = scale->top.overfetch[i];
+ mdp_scale->right_ftch[i] = scale->right.overfetch[i];
+ mdp_scale->btm_ftch[i] = scale->bottom.overfetch[i];
+
+ mdp_scale->left_rpt[i] = scale->left.repeat[i];
+ mdp_scale->top_rpt[i] = scale->top.repeat[i];
+ mdp_scale->right_rpt[i] = scale->right.repeat[i];
+ mdp_scale->btm_rpt[i] = scale->bottom.repeat[i];
+
+ mdp_scale->roi_w[i] = scale->roi_width[i];
+ }
+}
+
+} // namespace sde
+
+#endif
diff --git a/displayengine/libs/core/scalar_helper.h b/displayengine/libs/core/scalar_helper.h
new file mode 100755
index 0000000..a54cb0c
--- /dev/null
+++ b/displayengine/libs/core/scalar_helper.h
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2015, 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:
+* * Redistributions of source code must retain the above copyright notice, this list of
+* conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright notice, this list of
+* conditions and the following disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
+* endorse or promote products derived from this software without specific prior written
+* permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef __SCALAR_HELPER_H__
+#define __SCALAR_HELPER_H__
+
+#ifdef USES_SCALAR
+
+#include <sys/types.h>
+#include <linux/msm_mdp_ext.h>
+#include <hw_interface.h>
+#include <scalar.h>
+
+#define SCALAR_LIBRARY_NAME "libscalar.so"
+
+namespace sde {
+
+class ScalarHelper {
+
+ public:
+ void Init();
+ void Deinit();
+ bool ConfigureScale(HWLayers *hw_layers);
+ void UpdateSrcWidth(uint32_t index, bool left, uint32_t* src_width);
+ void SetScaleData(uint32_t index, bool left, mdp_scale_data* mdp_scale);
+ static ScalarHelper* GetInstance();
+
+ private:
+ explicit ScalarHelper() { }
+ struct ScaleData {
+ scalar::Scale left_scale;
+ scalar::Scale right_scale;
+ };
+ struct ScaleData scale_data_[kMaxSDELayers];
+ void* lib_scalar_handle_;
+ int (*ScalarConfigureScale)(struct scalar::LayerInfo* layer);
+ scalar::Scale* GetScaleRef(uint32_t index, bool left) {
+ return (left ? &scale_data_[index].left_scale : &scale_data_[index].right_scale);
+ }
+ static ScalarHelper* scalar_helper_; // Singleton Instance
+};
+
+} // namespace sde
+
+#endif
+#endif // __SCALAR_HELPER_H__
diff --git a/displayengine/libs/hwc/hwc_session.cpp b/displayengine/libs/hwc/hwc_session.cpp
index 1b686bf..40eae99 100644
--- a/displayengine/libs/hwc/hwc_session.cpp
+++ b/displayengine/libs/hwc/hwc_session.cpp
@@ -94,7 +94,7 @@
android::defaultServiceManager()->getService(android::String16(qservice_name)));
if (qservice.get()) {
- qservice->connect(this);
+ qservice->connect(android::sp<qClient::IQClient>(this));
} else {
DLOGE("Failed to acquire %s", qservice_name);
return -EINVAL;
diff --git a/hdmi_cec/Android.mk b/hdmi_cec/Android.mk
new file mode 100644
index 0000000..ed06da1
--- /dev/null
+++ b/hdmi_cec/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH := $(call my-dir)
+include $(LOCAL_PATH)/../common.mk
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := hdmi_cec.$(TARGET_BOARD_PLATFORM)
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(common_includes)
+LOCAL_SHARED_LIBRARIES := $(common_libs) libqservice libbinder libqdutils
+
+LOCAL_CFLAGS := $(common_flags) -DLOG_TAG=\"qdhdmi_cec\"
+LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
+LOCAL_SRC_FILES := qhdmi_cec.cpp \
+ QHDMIClient.cpp
+include $(BUILD_SHARED_LIBRARY)
diff --git a/hdmi_cec/QHDMIClient.cpp b/hdmi_cec/QHDMIClient.cpp
new file mode 100644
index 0000000..2b2b1e6
--- /dev/null
+++ b/hdmi_cec/QHDMIClient.cpp
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2014 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:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define DEBUG 0
+#include <QServiceUtils.h>
+#include "QHDMIClient.h"
+
+using namespace android;
+using namespace qhdmicec;
+using namespace qService;
+
+namespace qClient {
+
+void QHDMIClient::binderDied(const wp<IBinder>& who __unused)
+{
+ ALOGW("%s: Display QService died", __FUNCTION__);
+}
+
+void QHDMIClient::onHdmiHotplug(int connected)
+{
+ ALOGD("%s: HDMI connected event connected: %d", __FUNCTION__, connected);
+ cec_hdmi_hotplug(mCtx, connected);
+}
+
+void QHDMIClient::onCECMessageRecieved(char *msg, ssize_t len)
+{
+ ALOGD_IF(DEBUG, "%s: CEC message received len: %zd", __FUNCTION__, len);
+ cec_receive_message(mCtx, msg, len);
+}
+
+void QHDMIClient::registerClient(sp<QHDMIClient>& client)
+{
+ sp<IServiceManager> sm = defaultServiceManager();
+ sp<IBinder> binder = sm->getService(String16("display.qservice"));
+ binder->linkToDeath(client);
+ mQService = interface_cast<IQService>(binder);
+ mQService->connect(interface_cast<IQHDMIClient>(client));
+}
+
+};
diff --git a/hdmi_cec/QHDMIClient.h b/hdmi_cec/QHDMIClient.h
new file mode 100644
index 0000000..9e54f2f
--- /dev/null
+++ b/hdmi_cec/QHDMIClient.h
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2014 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:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "IQHDMIClient.h"
+#include "qhdmi_cec.h"
+#include <IQService.h>
+
+namespace qClient {
+
+class QHDMIClient: public android::IBinder::DeathRecipient,
+ public BnQHDMIClient
+{
+public:
+ QHDMIClient() {}
+
+ virtual void binderDied(const android::wp<android::IBinder>& who);
+
+ virtual void onHdmiHotplug(int connected);
+
+ virtual void onCECMessageRecieved(char *msg, ssize_t len);
+
+ void setCECContext(qhdmicec::cec_context_t* ctx) { mCtx = ctx; }
+
+ void registerClient(android::sp<QHDMIClient>& client);
+
+private:
+ qhdmicec::cec_context_t* mCtx;
+ android::sp<qService::IQService> mQService;
+
+};
+};
diff --git a/hdmi_cec/qhdmi_cec.cpp b/hdmi_cec/qhdmi_cec.cpp
new file mode 100644
index 0000000..6e46254
--- /dev/null
+++ b/hdmi_cec/qhdmi_cec.cpp
@@ -0,0 +1,519 @@
+/*
+* Copyright (c) 2014 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:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#define DEBUG 0
+#define ATRACE_TAG (ATRACE_TAG_GRAPHICS | ATRACE_TAG_HAL)
+#include <cstdlib>
+#include <cutils/log.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <hardware/hdmi_cec.h>
+#include <utils/Trace.h>
+#include "qhdmi_cec.h"
+#include "QHDMIClient.h"
+
+namespace qhdmicec {
+
+const int NUM_HDMI_PORTS = 1;
+const int MAX_SYSFS_DATA = 128;
+const int MAX_CEC_FRAME_SIZE = 20;
+const int MAX_SEND_MESSAGE_RETRIES = 1;
+
+enum {
+ LOGICAL_ADDRESS_SET = 1,
+ LOGICAL_ADDRESS_UNSET = -1,
+};
+
+// Offsets of members of struct hdmi_cec_msg
+// drivers/video/msm/mdss/mdss_hdmi_cec.c
+// XXX: Get this from a driver header
+enum {
+ CEC_OFFSET_SENDER_ID,
+ CEC_OFFSET_RECEIVER_ID,
+ CEC_OFFSET_OPCODE,
+ CEC_OFFSET_OPERAND,
+ CEC_OFFSET_FRAME_LENGTH = 18,
+ CEC_OFFSET_RETRANSMIT,
+};
+
+//Forward declarations
+static void cec_close_context(cec_context_t* ctx __unused);
+static int cec_enable(cec_context_t *ctx, int enable);
+static int cec_is_connected(const struct hdmi_cec_device* dev, int port_id);
+
+static ssize_t read_node(const char *path, char *data)
+{
+ ssize_t err = 0;
+ FILE *fp = NULL;
+ err = access(path, R_OK);
+ if (!err) {
+ fp = fopen(path, "r");
+ if (fp) {
+ err = fread(data, sizeof(char), MAX_SYSFS_DATA ,fp);
+ fclose(fp);
+ }
+ }
+ return err;
+}
+
+static ssize_t write_node(const char *path, const char *data, size_t len)
+{
+ ssize_t err = 0;
+ int fd = -1;
+ err = access(path, W_OK);
+ if (!err) {
+ fd = open(path, O_WRONLY);
+ errno = 0;
+ err = write(fd, data, len);
+ if (err < 0) {
+ err = -errno;
+ }
+ close(fd);
+ } else {
+ ALOGE("%s: Failed to access path: %s error: %s",
+ __FUNCTION__, path, strerror(errno));
+ err = -errno;
+ }
+ return err;
+}
+
+// Helper function to write integer values to the full sysfs path
+static ssize_t write_int_to_node(cec_context_t *ctx,
+ const char *path_postfix,
+ const int value)
+{
+ char sysfs_full_path[MAX_PATH_LENGTH];
+ char sysfs_data[MAX_SYSFS_DATA];
+ snprintf(sysfs_data, sizeof(sysfs_data), "%d",value);
+ snprintf(sysfs_full_path,sizeof(sysfs_full_path), "%s/%s",
+ ctx->fb_sysfs_path, path_postfix);
+ ssize_t err = write_node(sysfs_full_path, sysfs_data, strlen(sysfs_data));
+ return err;
+}
+
+static void hex_to_string(const char *msg, ssize_t len, char *str)
+{
+ //Functions assumes sufficient memory in str
+ char *ptr = str;
+ for(int i=0; i < len ; i++) {
+ ptr += snprintf(ptr, 3, "%02X", msg[i]);
+ // Overwrite null termination of snprintf in all except the last byte
+ if (i < len - 1)
+ *ptr = ':';
+ ptr++;
+ }
+}
+
+static ssize_t cec_get_fb_node_number(cec_context_t *ctx)
+{
+ //XXX: Do this from a common utility library across the display HALs
+ const int MAX_FB_DEVICES = 2;
+ ssize_t len = 0;
+ char fb_type_path[MAX_PATH_LENGTH];
+ char fb_type[MAX_SYSFS_DATA];
+ const char *dtv_panel_str = "dtv panel";
+
+ for(int num = 0; num < MAX_FB_DEVICES; num++) {
+ snprintf(fb_type_path, sizeof(fb_type_path),"%s%d/msm_fb_type",
+ SYSFS_BASE,num);
+ ALOGD_IF(DEBUG, "%s: num: %d fb_type_path: %s", __FUNCTION__, num, fb_type_path);
+ len = read_node(fb_type_path, fb_type);
+ ALOGD_IF(DEBUG, "%s: fb_type:%s", __FUNCTION__, fb_type);
+ if(len > 0 && (strncmp(fb_type, dtv_panel_str, strlen(dtv_panel_str)) == 0)){
+ ALOGD_IF(DEBUG, "%s: Found DTV panel at fb%d", __FUNCTION__, num);
+ ctx->fb_num = num;
+ snprintf(ctx->fb_sysfs_path, sizeof(ctx->fb_sysfs_path),
+ "%s%d", SYSFS_BASE, num);
+ break;
+ }
+ }
+ if (len < 0)
+ return len;
+ else
+ return 0;
+}
+
+static int cec_add_logical_address(const struct hdmi_cec_device* dev,
+ cec_logical_address_t addr)
+{
+ if (addr < CEC_ADDR_TV || addr > CEC_ADDR_BROADCAST) {
+ ALOGE("%s: Received invalid address: %d ", __FUNCTION__, addr);
+ return -EINVAL;
+ }
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ ctx->logical_address[addr] = LOGICAL_ADDRESS_SET;
+
+ //XXX: We can get multiple logical addresses here but we can only send one
+ //to the driver. Store locally for now
+ ssize_t err = write_int_to_node(ctx, "cec/logical_addr", addr);
+ ALOGI("%s: Allocated logical address: %d ", __FUNCTION__, addr);
+ return (int) err;
+}
+
+static void cec_clear_logical_address(const struct hdmi_cec_device* dev)
+{
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ memset(ctx->logical_address, LOGICAL_ADDRESS_UNSET,
+ sizeof(ctx->logical_address));
+ //XXX: Find logical_addr that needs to be reset
+ write_int_to_node(ctx, "cec/logical_addr", 15);
+ ALOGD_IF(DEBUG, "%s: Cleared logical addresses", __FUNCTION__);
+}
+
+static int cec_get_physical_address(const struct hdmi_cec_device* dev,
+ uint16_t* addr)
+{
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ char pa_path[MAX_PATH_LENGTH];
+ char pa_data[MAX_SYSFS_DATA];
+ snprintf (pa_path, sizeof(pa_path),"%s/pa",
+ ctx->fb_sysfs_path);
+ int err = (int) read_node(pa_path, pa_data);
+ *addr = (uint16_t) atoi(pa_data);
+ ALOGD_IF(DEBUG, "%s: Physical Address: 0x%x", __FUNCTION__, *addr);
+ if (err < 0)
+ return err;
+ else
+ return 0;
+}
+
+static int cec_send_message(const struct hdmi_cec_device* dev,
+ const cec_message_t* msg)
+{
+ ATRACE_CALL();
+ if(cec_is_connected(dev, 0) <= 0)
+ return HDMI_RESULT_FAIL;
+
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ ALOGD_IF(DEBUG, "%s: initiator: %d destination: %d length: %u",
+ __FUNCTION__, msg->initiator, msg->destination,
+ (uint32_t) msg->length);
+
+ // Dump message received from framework
+ char dump[128];
+ if(msg->length > 0) {
+ hex_to_string((char*)msg->body, msg->length, dump);
+ ALOGD_IF(DEBUG, "%s: message from framework: %s", __FUNCTION__, dump);
+ }
+
+ char write_msg_path[MAX_PATH_LENGTH];
+ char write_msg[MAX_CEC_FRAME_SIZE];
+ memset(write_msg, 0, sizeof(write_msg));
+ // See definition of struct hdmi_cec_msg in driver code
+ // drivers/video/msm/mdss/mdss_hdmi_cec.c
+ // Write header block
+ // XXX: Include this from header in kernel
+ write_msg[CEC_OFFSET_SENDER_ID] = msg->initiator;
+ write_msg[CEC_OFFSET_RECEIVER_ID] = msg->destination;
+ //Kernel splits opcode/operand, but Android sends it in one byte array
+ write_msg[CEC_OFFSET_OPCODE] = msg->body[0];
+ if(msg->length > 1) {
+ memcpy(&write_msg[CEC_OFFSET_OPERAND], &msg->body[1],
+ sizeof(char)*(msg->length - 1));
+ }
+ //msg length + initiator + destination
+ write_msg[CEC_OFFSET_FRAME_LENGTH] = (unsigned char) (msg->length + 1);
+ hex_to_string(write_msg, sizeof(write_msg), dump);
+ ALOGD_IF(DEBUG, "%s: message to driver: %s", __FUNCTION__, dump);
+ snprintf(write_msg_path, sizeof(write_msg_path), "%s/cec/wr_msg",
+ ctx->fb_sysfs_path);
+ int retry_count = 0;
+ ssize_t err = 0;
+ //HAL spec requires us to retry at least once.
+ while (true) {
+ err = write_node(write_msg_path, write_msg, sizeof(write_msg));
+ retry_count++;
+ if (err == -EAGAIN && retry_count <= MAX_SEND_MESSAGE_RETRIES) {
+ ALOGE("%s: CEC line busy, retrying", __FUNCTION__);
+ } else {
+ break;
+ }
+ }
+
+ if (err < 0) {
+ if (err == -ENXIO) {
+ ALOGI("%s: No device exists with the destination address",
+ __FUNCTION__);
+ return HDMI_RESULT_NACK;
+ } else if (err == -EAGAIN) {
+ ALOGE("%s: CEC line is busy, max retry count exceeded",
+ __FUNCTION__);
+ return HDMI_RESULT_BUSY;
+ } else {
+ return HDMI_RESULT_FAIL;
+ ALOGE("%s: Failed to send CEC message err: %zd - %s",
+ __FUNCTION__, err, strerror(int(-err)));
+ }
+ } else {
+ ALOGD_IF(DEBUG, "%s: Sent CEC message - %zd bytes written",
+ __FUNCTION__, err);
+ return HDMI_RESULT_SUCCESS;
+ }
+}
+
+void cec_receive_message(cec_context_t *ctx, char *msg, ssize_t len)
+{
+ if(!ctx->system_control)
+ return;
+
+ char dump[128];
+ if(len > 0) {
+ hex_to_string(msg, len, dump);
+ ALOGD_IF(DEBUG, "%s: Message from driver: %s", __FUNCTION__, dump);
+ }
+
+ hdmi_event_t event;
+ event.type = HDMI_EVENT_CEC_MESSAGE;
+ event.dev = (hdmi_cec_device *) ctx;
+ // Remove initiator/destination from this calculation
+ event.cec.length = msg[CEC_OFFSET_FRAME_LENGTH] - 1;
+ event.cec.initiator = (cec_logical_address_t) msg[CEC_OFFSET_SENDER_ID];
+ event.cec.destination = (cec_logical_address_t) msg[CEC_OFFSET_RECEIVER_ID];
+ //Copy opcode and operand
+ memcpy(event.cec.body, &msg[CEC_OFFSET_OPCODE], event.cec.length);
+ hex_to_string((char *) event.cec.body, event.cec.length, dump);
+ ALOGD_IF(DEBUG, "%s: Message to framework: %s", __FUNCTION__, dump);
+ ctx->callback.callback_func(&event, ctx->callback.callback_arg);
+}
+
+void cec_hdmi_hotplug(cec_context_t *ctx, int connected)
+{
+ //Ignore unplug events when system control is disabled
+ if(!ctx->system_control && connected == 0)
+ return;
+ hdmi_event_t event;
+ event.type = HDMI_EVENT_HOT_PLUG;
+ event.dev = (hdmi_cec_device *) ctx;
+ event.hotplug.connected = connected ? HDMI_CONNECTED : HDMI_NOT_CONNECTED;
+ ctx->callback.callback_func(&event, ctx->callback.callback_arg);
+}
+
+static void cec_register_event_callback(const struct hdmi_cec_device* dev,
+ event_callback_t callback, void* arg)
+{
+ ALOGD_IF(DEBUG, "%s: Registering callback", __FUNCTION__);
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ ctx->callback.callback_func = callback;
+ ctx->callback.callback_arg = arg;
+}
+
+static void cec_get_version(const struct hdmi_cec_device* dev, int* version)
+{
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ *version = ctx->version;
+ ALOGD_IF(DEBUG, "%s: version: %d", __FUNCTION__, *version);
+}
+
+static void cec_get_vendor_id(const struct hdmi_cec_device* dev,
+ uint32_t* vendor_id)
+{
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ *vendor_id = ctx->vendor_id;
+ ALOGD_IF(DEBUG, "%s: vendor id: %u", __FUNCTION__, *vendor_id);
+}
+
+static void cec_get_port_info(const struct hdmi_cec_device* dev,
+ struct hdmi_port_info* list[], int* total)
+{
+ ALOGD_IF(DEBUG, "%s: Get port info", __FUNCTION__);
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ *total = NUM_HDMI_PORTS;
+ *list = ctx->port_info;
+}
+
+static void cec_set_option(const struct hdmi_cec_device* dev, int flag,
+ int value)
+{
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ switch (flag) {
+ case HDMI_OPTION_WAKEUP:
+ ALOGD_IF(DEBUG, "%s: Wakeup: value: %d", __FUNCTION__, value);
+ //XXX
+ break;
+ case HDMI_OPTION_ENABLE_CEC:
+ ALOGD_IF(DEBUG, "%s: Enable CEC: value: %d", __FUNCTION__, value);
+ cec_enable(ctx, value? 1 : 0);
+ break;
+ case HDMI_OPTION_SYSTEM_CEC_CONTROL:
+ ALOGD_IF(DEBUG, "%s: system_control: value: %d",
+ __FUNCTION__, value);
+ ctx->system_control = !!value;
+ break;
+ }
+}
+
+static void cec_set_audio_return_channel(const struct hdmi_cec_device* dev,
+ int flag)
+{
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ ctx->arc_enabled = flag ? true : false;
+ ALOGD_IF(DEBUG, "%s: ARC flag: %d", __FUNCTION__, flag);
+}
+
+static int cec_is_connected(const struct hdmi_cec_device* dev, int port_id)
+{
+ // Ignore port_id since we have only one port
+ int connected = 0;
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ char connected_path[MAX_PATH_LENGTH];
+ char connected_data[MAX_SYSFS_DATA];
+ snprintf (connected_path, sizeof(connected_path),"%s/connected",
+ ctx->fb_sysfs_path);
+ ssize_t err = read_node(connected_path, connected_data);
+ connected = atoi(connected_data);
+
+ ALOGD_IF(DEBUG, "%s: HDMI at port %d is - %s", __FUNCTION__, port_id,
+ connected ? "connected":"disconnected");
+ if (err < 0)
+ return (int) err;
+ else
+ return connected;
+}
+
+static int cec_device_close(struct hw_device_t *dev)
+{
+ ALOGD_IF(DEBUG, "%s: Close CEC HAL ", __FUNCTION__);
+ if (!dev) {
+ ALOGE("%s: NULL device pointer", __FUNCTION__);
+ return -EINVAL;
+ }
+ cec_context_t* ctx = (cec_context_t*)(dev);
+ cec_close_context(ctx);
+ free(dev);
+ return 0;
+}
+
+static int cec_enable(cec_context_t *ctx, int enable)
+{
+ ssize_t err;
+ // Enable CEC
+ // TODO: Set to 0x3 to enable CEC wakeup once driver has support
+ int value = enable ? 0x1 : 0x0;
+ err = write_int_to_node(ctx, "cec/enable", value);
+ if(err < 0) {
+ ALOGE("%s: Failed to toggle CEC: enable: %d",
+ __FUNCTION__, enable);
+ return (int) err;
+ }
+ ctx->enabled = enable;
+ return 0;
+}
+
+static void cec_init_context(cec_context_t *ctx)
+{
+ ALOGD_IF(DEBUG, "%s: Initializing context", __FUNCTION__);
+ cec_get_fb_node_number(ctx);
+
+ //Initialize ports - We support only one output port
+ ctx->port_info = new hdmi_port_info[NUM_HDMI_PORTS];
+ ctx->port_info[0].type = HDMI_OUTPUT;
+ ctx->port_info[0].port_id = 1;
+ ctx->port_info[0].cec_supported = 1;
+ //XXX: Enable ARC if supported
+ ctx->port_info[0].arc_supported = 0;
+ cec_get_physical_address((hdmi_cec_device *) ctx,
+ &ctx->port_info[0].physical_address );
+
+ ctx->version = 0x4;
+ ctx->vendor_id = 0xA47733;
+ cec_clear_logical_address((hdmi_cec_device_t*)ctx);
+
+ //Set up listener for HDMI events
+ ctx->disp_client = new qClient::QHDMIClient();
+ ctx->disp_client->setCECContext(ctx);
+ ctx->disp_client->registerClient(ctx->disp_client);
+
+ //Enable CEC - framework expects it to be enabled by default
+ cec_enable(ctx, true);
+
+ ALOGD("%s: CEC enabled", __FUNCTION__);
+}
+
+static void cec_close_context(cec_context_t* ctx __unused)
+{
+ ALOGD("%s: Closing context", __FUNCTION__);
+}
+
+static int cec_device_open(const struct hw_module_t* module,
+ const char* name,
+ struct hw_device_t** device)
+{
+ ALOGD_IF(DEBUG, "%s: name: %s", __FUNCTION__, name);
+ int status = -EINVAL;
+ if (!strcmp(name, HDMI_CEC_HARDWARE_INTERFACE )) {
+ struct cec_context_t *dev;
+ dev = (cec_context_t *) calloc (1, sizeof(*dev));
+ if (dev) {
+ cec_init_context(dev);
+
+ //Setup CEC methods
+ dev->device.common.tag = HARDWARE_DEVICE_TAG;
+ dev->device.common.version = HDMI_CEC_DEVICE_API_VERSION_1_0;
+ dev->device.common.module = const_cast<hw_module_t* >(module);
+ dev->device.common.close = cec_device_close;
+ dev->device.add_logical_address = cec_add_logical_address;
+ dev->device.clear_logical_address = cec_clear_logical_address;
+ dev->device.get_physical_address = cec_get_physical_address;
+ dev->device.send_message = cec_send_message;
+ dev->device.register_event_callback = cec_register_event_callback;
+ dev->device.get_version = cec_get_version;
+ dev->device.get_vendor_id = cec_get_vendor_id;
+ dev->device.get_port_info = cec_get_port_info;
+ dev->device.set_option = cec_set_option;
+ dev->device.set_audio_return_channel = cec_set_audio_return_channel;
+ dev->device.is_connected = cec_is_connected;
+
+ *device = &dev->device.common;
+ status = 0;
+ } else {
+ status = -EINVAL;
+ }
+ }
+ return status;
+}
+}; //namespace qhdmicec
+
+// Standard HAL module, should be outside qhdmicec namespace
+static struct hw_module_methods_t cec_module_methods = {
+ .open = qhdmicec::cec_device_open
+};
+
+hdmi_module_t HAL_MODULE_INFO_SYM = {
+ .common = {
+ .tag = HARDWARE_MODULE_TAG,
+ .version_major = 1,
+ .version_minor = 0,
+ .id = HDMI_CEC_HARDWARE_MODULE_ID,
+ .name = "QTI HDMI CEC module",
+ .author = "The Linux Foundation",
+ .methods = &cec_module_methods,
+ }
+};
+
+
diff --git a/hdmi_cec/qhdmi_cec.h b/hdmi_cec/qhdmi_cec.h
new file mode 100644
index 0000000..aa97620
--- /dev/null
+++ b/hdmi_cec/qhdmi_cec.h
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2014 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:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#ifndef QHDMI_CEC_H
+#define QHDMI_CEC_H
+
+#include <hardware/hdmi_cec.h>
+#include <utils/RefBase.h>
+
+namespace qClient {
+ class QHDMIClient;
+};
+
+namespace qhdmicec {
+
+#define SYSFS_BASE "/sys/class/graphics/fb"
+#define MAX_PATH_LENGTH 128
+
+struct cec_callback_t {
+ // Function in HDMI service to call back on CEC messages
+ event_callback_t callback_func;
+ // This stores the object to pass back to the framework
+ void* callback_arg;
+
+};
+
+struct cec_context_t {
+ hdmi_cec_device_t device; // Device for HW module
+ cec_callback_t callback; // Struct storing callback object
+ bool enabled;
+ bool arc_enabled;
+ bool system_control; // If true, HAL/driver handle CEC messages
+ int fb_num; // Framebuffer node for HDMI
+ char fb_sysfs_path[MAX_PATH_LENGTH];
+ hdmi_port_info *port_info; // HDMI port info
+
+ // Logical address is stored in an array, the index of the array is the
+ // logical address and the value in the index shows whether it is set or not
+ int logical_address[CEC_ADDR_BROADCAST];
+ int version;
+ uint32_t vendor_id;
+ android::sp<qClient::QHDMIClient> disp_client;
+};
+
+void cec_receive_message(cec_context_t *ctx, char *msg, ssize_t len);
+void cec_hdmi_hotplug(cec_context_t *ctx, int connected);
+
+}; //namespace
+#endif /* end of include guard: QHDMI_CEC_H */
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index adf48e7..7c69633 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -635,7 +635,11 @@
}
}
- int lSplit = getLeftSplit(ctx, dpy);
+ /* When source split is enabled, right ROI will always be NULL since the
+ * ROI for the whole panel generated in a single coordinate system will
+ * be populuated in left ROI. So leave the right ROI untouched */
+ int lSplit = qdutils::MDPVersion::getInstance().isSrcSplit() ? 0
+ :getLeftSplit(ctx, dpy);
qhwc::ovutils::Dim lRoi = qhwc::ovutils::Dim(
ctx->listStats[dpy].lRoi.left,
ctx->listStats[dpy].lRoi.top,
@@ -889,6 +893,7 @@
dumpsys_log(aBuf, ovDump);
ovDump[0] = '\0';
}
+ dumpsys_log(aBuf, "Copybit::isAbcInUse=%d\n\n",isAbcInUse(ctx) ? 1 : 0);
strlcpy(buff, aBuf.string(), buff_len);
}
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index b45279f..2d6497e 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -217,9 +217,6 @@
mCurrentFrame.reset(numLayers);
ctx->mOverlay->clear(mDpy);
ctx->mLayerRotMap[mDpy]->clear();
- resetROI(ctx, mDpy);
- memset(&mCurrentFrame.drop, 0, sizeof(mCurrentFrame.drop));
- mCurrentFrame.dropCount = 0;
}
void MDPComp::reset() {
diff --git a/libhwcomposer/hwc_uevents.cpp b/libhwcomposer/hwc_uevents.cpp
index c6179e4..4d94647 100644
--- a/libhwcomposer/hwc_uevents.cpp
+++ b/libhwcomposer/hwc_uevents.cpp
@@ -125,6 +125,9 @@
ctx->proc->hotplug(ctx->proc, dpy, EXTERNAL_OFFLINE);
}
+ // Report Hotplug via CEC HAL
+ ctx->mQService->onHdmiHotplug((int)ctx->dpyAttr[dpy].connected);
+
//On 8994, 8992 due to hardware limitations, we disable bwc
//when HDMI intf is active
if((qdutils::MDPVersion::getInstance().is8994() or
@@ -158,7 +161,7 @@
ctx->mDrawLock.lock();
handle_online(ctx, dpy);
ctx->mDrawLock.unlock();
-
+ ctx->mQService->onHdmiHotplug(ctx->dpyAttr[dpy].connected);
ctx->proc->invalidate(ctx->proc);
break;
} else {
@@ -213,6 +216,7 @@
/* External display is HDMI */
ALOGI("%s: Sending EXTERNAL ONLINE event", __FUNCTION__);
ctx->proc->hotplug(ctx->proc, dpy, EXTERNAL_ONLINE);
+ ctx->mQService->onHdmiHotplug(ctx->dpyAttr[dpy].connected);
break;
}
default:
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 05ab503..d176cd3 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -376,14 +376,15 @@
//independent process as well.
QService::init();
sp<IQClient> client = new QClient(ctx);
- android::sp<qService::IQService> qservice_sp = interface_cast<IQService>(
+ sp<IQService> iqs = interface_cast<IQService>(
defaultServiceManager()->getService(
String16("display.qservice")));
- if (qservice_sp.get()) {
- qservice_sp->connect(client);
+ if (iqs.get()) {
+ iqs->connect(client);
+ ctx->mQService = reinterpret_cast<QService* >(iqs.get());
} else {
ALOGE("%s: Failed to acquire service pointer", __FUNCTION__);
- return ;
+ return;
}
// Initialize device orientation to its default orientation
@@ -479,7 +480,10 @@
ctx->mAD = NULL;
}
-
+ if(ctx->mQService) {
+ delete ctx->mQService;
+ ctx->mQService = NULL;
+ }
}
//Helper to roundoff the refreshrates
@@ -2769,7 +2773,13 @@
void resetROI(hwc_context_t *ctx, const int dpy) {
const int fbXRes = (int)ctx->dpyAttr[dpy].xres;
const int fbYRes = (int)ctx->dpyAttr[dpy].yres;
- if(isDisplaySplit(ctx, dpy)) {
+
+ /* When source split is enabled, both the panels are calibrated
+ * in a single coordinate system. So only one ROI is generated
+ * for the whole panel extending equally from the midpoint and
+ * populated for the left side. */
+ if(!qdutils::MDPVersion::getInstance().isSrcSplit() &&
+ isDisplaySplit(ctx, dpy)) {
const int lSplit = getLeftSplit(ctx, dpy);
ctx->listStats[dpy].lRoi = (struct hwc_rect){0, 0, lSplit, fbYRes};
ctx->listStats[dpy].rRoi = (struct hwc_rect){lSplit, 0, fbXRes, fbYRes};
diff --git a/libhwcomposer/hwc_utils.h b/libhwcomposer/hwc_utils.h
index f11eed5..23157d4 100644
--- a/libhwcomposer/hwc_utils.h
+++ b/libhwcomposer/hwc_utils.h
@@ -35,6 +35,7 @@
#include <overlayUtils.h>
#include <overlayRotator.h>
#include <EGL/egl.h>
+#include <QService.h>
#define ALIGN_TO(x, align) (((x) + ((align)-1)) & ~((align)-1))
@@ -687,6 +688,8 @@
bool mHPDEnabled;
//Used to notify that boot has completed
bool mBootAnimCompleted;
+ // Display binder service
+ qService::QService* mQService;
};
namespace qhwc {
diff --git a/libhwcomposer/hwc_vsync.cpp b/libhwcomposer/hwc_vsync.cpp
index 89f8044..1a7a836 100644
--- a/libhwcomposer/hwc_vsync.cpp
+++ b/libhwcomposer/hwc_vsync.cpp
@@ -33,6 +33,7 @@
#include "overlay.h"
#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
+#define DEBUG 0
using namespace qdutils;
namespace qhwc {
@@ -56,7 +57,8 @@
return ret;
}
-static void handle_vsync_event(hwc_context_t* ctx, int dpy, char *data)
+static void handle_vsync_event(hwc_context_t* ctx, int dpy, char *data,
+ ssize_t len __unused)
{
// extract timestamp
uint64_t timestamp = 0;
@@ -69,7 +71,8 @@
ctx->proc->vsync(ctx->proc, dpy, timestamp);
}
-static void handle_blank_event(hwc_context_t* ctx, int dpy, char *data)
+static void handle_blank_event(hwc_context_t* ctx, int dpy, char *data,
+ ssize_t len __unused)
{
if (!strncmp(data, PANEL_ON_STR, strlen(PANEL_ON_STR))) {
unsigned long int poweron = strtoul(data + strlen(PANEL_ON_STR), NULL, 0);
@@ -80,7 +83,8 @@
}
}
-static void handle_thermal_event(hwc_context_t* ctx, int dpy, char *data)
+static void handle_thermal_event(hwc_context_t* ctx, int dpy, char *data,
+ ssize_t len __unused)
{
// extract thermal level
uint64_t thermalLevel = 0;
@@ -95,15 +99,24 @@
ctx->mThermalBurstMode = false;
}
+static void handle_cec_event(hwc_context_t* ctx, int dpy, char *data,
+ ssize_t len)
+{
+ ALOGD_IF(DEBUG, "%s: Got CEC event from driver dpy:%d",
+ __FUNCTION__, dpy);
+ ctx->mQService->onCECMessageReceived(data, len);
+}
+
struct event {
const char* name;
- void (*callback)(hwc_context_t* ctx, int dpy, char *data);
+ void (*callback)(hwc_context_t* ctx, int dpy, char *data, ssize_t len);
};
struct event event_list[] = {
{ "vsync_event", handle_vsync_event },
{ "show_blank_event", handle_blank_event },
{ "msm_fb_thermal_level", handle_thermal_event },
+ { "cec/rd_msg", handle_cec_event },
};
#define num_events ARRAY_LENGTH(event_list)
@@ -185,7 +198,7 @@
continue;
}
vdata[len] = '\0';
- event_list[ev].callback(ctx, dpy, vdata);
+ event_list[ev].callback(ctx, dpy, vdata, len);
}
}
}
diff --git a/liboverlay/overlay.cpp b/liboverlay/overlay.cpp
index a34e599..b7c7fcc 100644
--- a/liboverlay/overlay.cpp
+++ b/liboverlay/overlay.cpp
@@ -151,6 +151,8 @@
return getPipe_8x39(pipeSpecs);
} else if(MDPVersion::getInstance().is8994()) {
return getPipe_8994(pipeSpecs);
+ } else if(MDPVersion::getInstance().is8992()) {
+ return getPipe_8992(pipeSpecs);
}
eDest dest = OV_INVALID;
@@ -251,6 +253,13 @@
//supported since we at least need 1 round in between where the DMA is
//unused
eDest dest = OV_INVALID;
+
+ // Reset format type to FORMAT_NONE to select the pipe irrespective of the
+ // format specifed by the client. This is required for the device where
+ // SMP starvation is unlikely, we need not keep track of formats
+ // programmed in the pipes to avoid potential pipe crunching.
+ resetPipeBookFormat(pipeSpecs.dpy);
+
if(pipeSpecs.formatClass == FORMAT_YUV) {
return nextPipe(OV_MDP_PIPE_VG, pipeSpecs);
} else {
@@ -262,9 +271,14 @@
dest = nextPipe(OV_MDP_PIPE_DMA, pipeSpecs);
}
}
+
return dest;
}
+utils::eDest Overlay::getPipe_8992(const PipeSpecs& pipeSpecs) {
+ return getPipe_8994(pipeSpecs);
+}
+
void Overlay::endAllSessions() {
for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
if(mPipeBook[i].valid() && mPipeBook[i].mSession==PipeBook::START)
diff --git a/liboverlay/overlay.h b/liboverlay/overlay.h
index 45b5e57..49be930 100644
--- a/liboverlay/overlay.h
+++ b/liboverlay/overlay.h
@@ -178,6 +178,9 @@
utils::eDest getPipe_8x16(const PipeSpecs& pipeSpecs);
utils::eDest getPipe_8x39(const PipeSpecs& pipeSpecs);
utils::eDest getPipe_8994(const PipeSpecs& pipeSpecs);
+ utils::eDest getPipe_8992(const PipeSpecs& pipeSpecs);
+
+ void resetPipeBookFormat(const int &dpy);
/* Returns the handle to libscale.so's programScale function */
static int (*getFnProgramScale())(struct mdp_overlay_list *);
@@ -443,6 +446,14 @@
return "Invalid";
}
+inline void Overlay::resetPipeBookFormat(const int &dpy) {
+ for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
+ if (mPipeBook[i].mDisplay == dpy) {
+ mPipeBook[i].mFormatType = FORMAT_NONE;
+ }
+ }
+}
+
}; // overlay
#endif // OVERLAY_H
diff --git a/liboverlay/overlayMdp.cpp b/liboverlay/overlayMdp.cpp
index 1290f32..0c31dd3 100644
--- a/liboverlay/overlayMdp.cpp
+++ b/liboverlay/overlayMdp.cpp
@@ -353,8 +353,31 @@
mdp_overlay* ovArray[count];
memset(&ovArray, 0, sizeof(ovArray));
+ uint8_t max_horz_deci = 0, max_vert_deci = 0;
+
+ // Decimation factor for the left and right pipe differs, when there is a
+ // one pixel difference in the dst width of right pipe and the left pipe.
+ // libscalar returns a failure as it expects decimation on both the pipe
+ // to be same. So compare the decimation factor on both the pipes and assign
+ // the maximum of it.
for(int i = 0; i < count; i++) {
- ovArray[i] = &mdpCtrlArray[i]->mOVInfo;
+ mdp_overlay *ov_current = &mdpCtrlArray[i]->mOVInfo;
+ for(int j = i + 1; j < count; j++) {
+ mdp_overlay *ov_next = &mdpCtrlArray[j]->mOVInfo;
+ if(ov_current->z_order == ov_next->z_order) {
+ max_horz_deci = utils::max(ov_current->horz_deci,
+ ov_next->horz_deci);
+ max_vert_deci = utils::max(ov_current->vert_deci,
+ ov_next->vert_deci);
+
+ ov_current->horz_deci = max_horz_deci;
+ ov_next->horz_deci = max_horz_deci;
+ ov_current->vert_deci = max_vert_deci;
+ ov_next->vert_deci = max_vert_deci;
+ break;
+ }
+ }
+ ovArray[i] = ov_current;
}
struct mdp_overlay_list list;
diff --git a/libqdutils/mdp_version.cpp b/libqdutils/mdp_version.cpp
index 402e129..e045918 100644
--- a/libqdutils/mdp_version.cpp
+++ b/libqdutils/mdp_version.cpp
@@ -501,6 +501,10 @@
mMdpRev < MDSS_MDP_HW_REV_109);
}
+bool MDPVersion::is8992() {
+ return ((mMdpRev >= MDSS_MDP_HW_REV_110 and
+ mMdpRev < MDSS_MDP_HW_REV_200));
+}
}; //namespace qdutils
diff --git a/libqdutils/mdp_version.h b/libqdutils/mdp_version.h
index 3b10010..aeb2218 100644
--- a/libqdutils/mdp_version.h
+++ b/libqdutils/mdp_version.h
@@ -151,6 +151,7 @@
bool is8994();
bool is8x16();
bool is8x39();
+ bool is8992();
private:
bool updateSysFsInfo();
diff --git a/libqservice/Android.mk b/libqservice/Android.mk
index 78b1d77..287e6ce 100644
--- a/libqservice/Android.mk
+++ b/libqservice/Android.mk
@@ -10,7 +10,8 @@
LOCAL_ADDITIONAL_DEPENDENCIES := $(common_deps)
LOCAL_SRC_FILES := QService.cpp \
IQService.cpp \
- IQClient.cpp
+ IQClient.cpp \
+ IQHDMIClient.cpp
LOCAL_COPY_HEADERS_TO := $(common_header_export_path)
LOCAL_COPY_HEADERS := IQService.h \
IQClient.h
diff --git a/libqservice/IQHDMIClient.cpp b/libqservice/IQHDMIClient.cpp
new file mode 100644
index 0000000..9f5044a
--- /dev/null
+++ b/libqservice/IQHDMIClient.cpp
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2014 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:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#include <utils/Log.h>
+#include <binder/Parcel.h>
+#include "IQHDMIClient.h"
+
+using namespace android;
+namespace qClient {
+
+enum {
+ HDMI_CONNECTED = IBinder::FIRST_CALL_TRANSACTION,
+ CEC_MESSAGE_RECEIVED
+};
+
+class BpQHDMIClient : public BpInterface<IQHDMIClient>
+{
+public:
+ BpQHDMIClient(const sp<IBinder>& impl)
+ :BpInterface<IQHDMIClient>(impl)
+ {
+ }
+
+ void onHdmiHotplug(int connected)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IQHDMIClient::getInterfaceDescriptor());
+ data.writeInt32(connected);
+ remote()->transact(HDMI_CONNECTED, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+
+ void onCECMessageRecieved(char *msg, ssize_t len)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IQHDMIClient::getInterfaceDescriptor());
+ data.writeInt32((int32_t)len);
+ void *buf = data.writeInplace(len);
+ if (buf != NULL)
+ memcpy(buf, msg, len);
+ remote()->transact(CEC_MESSAGE_RECEIVED, data, &reply,
+ IBinder::FLAG_ONEWAY);
+ }
+};
+
+IMPLEMENT_META_INTERFACE(QHDMIClient,
+ "android.display.IQHDMIClient");
+
+status_t BnQHDMIClient::onTransact(uint32_t code, const Parcel& data,
+ Parcel* reply, uint32_t flags)
+{
+ switch(code) {
+ case HDMI_CONNECTED: {
+ CHECK_INTERFACE(IQHDMIClient, data, reply);
+ int connected = data.readInt32();
+ onHdmiHotplug(connected);
+ return NO_ERROR;
+ }
+ case CEC_MESSAGE_RECEIVED: {
+ CHECK_INTERFACE(IQHDMIClient, data, reply);
+ ssize_t len = data.readInt32();
+ const void* msg;
+ if(len >= 0 && len <= (ssize_t) data.dataAvail()) {
+ msg = data.readInplace(len);
+ } else {
+ msg = NULL;
+ len = 0;
+ }
+ if (msg != NULL)
+ onCECMessageRecieved((char*) msg, len);
+ return NO_ERROR;
+ }
+ default: {
+ return BBinder::onTransact(code, data, reply, flags);
+ }
+ }
+}
+
+}; //namespace qClient
diff --git a/libqservice/IQHDMIClient.h b/libqservice/IQHDMIClient.h
new file mode 100644
index 0000000..c3d012a
--- /dev/null
+++ b/libqservice/IQHDMIClient.h
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2014 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:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above
+* copyright notice, this list of conditions and the following
+* disclaimer in the documentation and/or other materials provided
+* with the distribution.
+* * Neither the name of The Linux Foundation. nor the names of its
+* contributors may be used to endorse or promote products derived
+* from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef HDMI_EVENTS_LISTENER_H_
+#define HDMI_EVENTS_LISTENER_H_
+
+#include <utils/RefBase.h>
+#include <binder/IInterface.h>
+
+namespace qClient {
+
+class IQHDMIClient : public android::IInterface
+{
+public:
+ DECLARE_META_INTERFACE(QHDMIClient);
+ virtual void onHdmiHotplug(int connected) = 0;
+ virtual void onCECMessageRecieved(char *msg, ssize_t len) = 0;
+};
+
+class BnQHDMIClient : public android::BnInterface<IQHDMIClient>
+{
+public:
+ virtual android::status_t onTransact( uint32_t code,
+ const android::Parcel& data,
+ android::Parcel* reply, uint32_t flags = 0);
+};
+
+}; //namespace qhdmi
+
+#endif // HDMI_EVENTS_LISTENER_H_
+
diff --git a/libqservice/IQService.cpp b/libqservice/IQService.cpp
index eee22f0..5e67b15 100644
--- a/libqservice/IQService.cpp
+++ b/libqservice/IQService.cpp
@@ -45,13 +45,22 @@
: BpInterface<IQService>(impl) {}
virtual void connect(const sp<IQClient>& client) {
- ALOGD_IF(QSERVICE_DEBUG, "%s: connect client", __FUNCTION__);
+ ALOGD_IF(QSERVICE_DEBUG, "%s: connect HWC client", __FUNCTION__);
Parcel data, reply;
data.writeInterfaceToken(IQService::getInterfaceDescriptor());
data.writeStrongBinder(client->asBinder());
- remote()->transact(CONNECT, data, &reply);
+ remote()->transact(CONNECT_HWC_CLIENT, data, &reply);
}
+ virtual void connect(const sp<IQHDMIClient>& client) {
+ ALOGD_IF(QSERVICE_DEBUG, "%s: connect HDMI client", __FUNCTION__);
+ Parcel data, reply;
+ data.writeInterfaceToken(IQService::getInterfaceDescriptor());
+ data.writeStrongBinder(client->asBinder());
+ remote()->transact(CONNECT_HDMI_CLIENT, data, &reply);
+ }
+
+
virtual android::status_t dispatch(uint32_t command, const Parcel* inParcel,
Parcel* outParcel) {
ALOGD_IF(QSERVICE_DEBUG, "%s: dispatch in:%p", __FUNCTION__, inParcel);
@@ -90,10 +99,10 @@
callerUid == AID_ROOT ||
callerUid == AID_SYSTEM);
- if (code == CONNECT) {
+ if (code == CONNECT_HWC_CLIENT) {
CHECK_INTERFACE(IQService, data, reply);
if(callerUid != AID_GRAPHICS) {
- ALOGE("display.qservice CONNECT access denied: \
+ ALOGE("display.qservice CONNECT_HWC_CLIENT access denied: \
pid=%d uid=%d process=%s",
callerPid, callerUid, callingProcName);
return PERMISSION_DENIED;
@@ -102,6 +111,18 @@
interface_cast<IQClient>(data.readStrongBinder());
connect(client);
return NO_ERROR;
+ } else if(code == CONNECT_HDMI_CLIENT) {
+ CHECK_INTERFACE(IQService, data, reply);
+ if(callerUid != AID_SYSTEM && callerUid != AID_ROOT) {
+ ALOGE("display.qservice CONNECT_HDMI_CLIENT access denied: \
+ pid=%d uid=%d process=%s",
+ callerPid, callerUid, callingProcName);
+ return PERMISSION_DENIED;
+ }
+ sp<IQHDMIClient> client =
+ interface_cast<IQHDMIClient>(data.readStrongBinder());
+ connect(client);
+ return NO_ERROR;
} else if (code > COMMAND_LIST_START && code < COMMAND_LIST_END) {
if(!permission) {
ALOGE("display.qservice access denied: command=%d\
diff --git a/libqservice/IQService.h b/libqservice/IQService.h
index 796e506..78cbd2a 100644
--- a/libqservice/IQService.h
+++ b/libqservice/IQService.h
@@ -28,6 +28,7 @@
#include <binder/IInterface.h>
#include <binder/IBinder.h>
#include <IQClient.h>
+#include <IQHDMIClient.h>
namespace qService {
@@ -41,7 +42,7 @@
COMMAND_LIST_START = android::IBinder::FIRST_CALL_TRANSACTION,
SECURING = 2, // Hardware securing start/end notification
UNSECURING = 3, // Hardware unsecuring start/end notification
- CONNECT = 4, // Connect to qservice
+ CONNECT_HWC_CLIENT = 4, // Connect to qservice
SCREEN_REFRESH = 5, // Refresh screen through SF invalidate
EXTERNAL_ORIENTATION = 6,// Set external orientation
BUFFER_MIRRORMODE = 7, // Buffer mirrormode
@@ -61,6 +62,7 @@
TOGGLE_SCREEN_UPDATE = 20, // Provides ability to disable screen updates
SET_FRAME_DUMP_CONFIG = 21, // Provides ability to set the frame dump config
SET_S3D_MODE = 22, // Set the 3D mode as specified in msm_hdmi_modes.h
+ CONNECT_HDMI_CLIENT = 23, // Connect HDMI CEC HAL Client
COMMAND_LIST_END = 400,
};
@@ -85,8 +87,13 @@
DUMP_VIRTUAL_DISPLAY,
};
- // Register a client that can be notified
+ // Register a HWC client that can be notified
+ // This client is generic and is intended to get
+ // dispatches of all events calling into QService
virtual void connect(const android::sp<qClient::IQClient>& client) = 0;
+ // Register an HDMI client. This client gets notification of HDMI events
+ // such as plug/unplug and CEC messages
+ virtual void connect(const android::sp<qClient::IQHDMIClient>& client) = 0;
// Generic function to dispatch binder commands
// The type of command decides how the data is parceled
virtual android::status_t dispatch(uint32_t command,
diff --git a/libqservice/QService.cpp b/libqservice/QService.cpp
index 12dd995..5276695 100644
--- a/libqservice/QService.cpp
+++ b/libqservice/QService.cpp
@@ -50,10 +50,15 @@
}
void QService::connect(const sp<qClient::IQClient>& client) {
- ALOGD_IF(QSERVICE_DEBUG,"client connected");
+ ALOGD_IF(QSERVICE_DEBUG,"HWC client connected");
mClient = client;
}
+void QService::connect(const sp<qClient::IQHDMIClient>& client) {
+ ALOGD_IF(QSERVICE_DEBUG,"HWC client connected");
+ mHDMIClient = client;
+}
+
status_t QService::dispatch(uint32_t command, const Parcel* inParcel,
Parcel* outParcel) {
status_t err = (status_t) FAILED_TRANSACTION;
@@ -68,6 +73,25 @@
return err;
}
+void QService::onHdmiHotplug(int connected) {
+ if(mHDMIClient.get()) {
+ ALOGD_IF(QSERVICE_DEBUG, "%s: HDMI hotplug", __FUNCTION__);
+ mHDMIClient->onHdmiHotplug(connected);
+ } else {
+ ALOGE("%s: Failed to get a valid HDMI client", __FUNCTION__);
+ }
+}
+
+void QService::onCECMessageReceived(char *msg, ssize_t len) {
+ if(mHDMIClient.get()) {
+ ALOGD_IF(QSERVICE_DEBUG, "%s: CEC message received", __FUNCTION__);
+ mHDMIClient->onCECMessageRecieved(msg, len);
+ } else {
+ ALOGE("%s: Failed to get a valid HDMI client", __FUNCTION__);
+ }
+}
+
+
void QService::init()
{
if(!sQService) {
diff --git a/libqservice/QService.h b/libqservice/QService.h
index a8e4cdb..719c9b7 100644
--- a/libqservice/QService.h
+++ b/libqservice/QService.h
@@ -46,13 +46,17 @@
public:
virtual ~QService();
virtual void connect(const android::sp<qClient::IQClient>& client);
+ virtual void connect(const android::sp<qClient::IQHDMIClient>& client);
virtual android::status_t dispatch(uint32_t command,
const android::Parcel* data,
android::Parcel* reply);
+ void onHdmiHotplug(int connected);
+ void onCECMessageReceived(char *msg, ssize_t len);
static void init();
private:
QService();
android::sp<qClient::IQClient> mClient;
+ android::sp<qClient::IQHDMIClient> mHDMIClient;
static QService *sQService;
};
}; // namespace qService