sdm: Add support for IGC.

- Add support for sRGB IGC.
- Program IGC PP parameters for sRGB contents.

Change-Id: I41b4b0bd8ef60fc7f869c742d084f4c3a3db6635
This commit is contained in:
Dileep Marchya
2015-09-25 19:11:57 -07:00
committed by Gerrit - the friendly Code Review server
parent 2bc7d99f5f
commit 1a7e1f193e
10 changed files with 132 additions and 23 deletions

6
libgralloc/gralloc_priv.h Executable file → Normal file
View File

@@ -86,6 +86,8 @@
#define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8
#define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9
#define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10
#define GRALLOC_MODULE_PERFORM_GET_IGC 11
#define GRALLOC_MODULE_PERFORM_SET_IGC 12
/* OEM specific HAL formats */
@@ -148,6 +150,10 @@
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
/* possible values for inverse gamma correction */
#define HAL_IGC_NOT_SPECIFIED 0
#define HAL_IGC_s_RGB 1
/* possible formats for 3D content*/
enum {
HAL_NO_3D = 0x0,

View File

@@ -453,6 +453,33 @@ int gralloc_perform(struct gralloc_module_t const* module,
}
} break;
case GRALLOC_MODULE_PERFORM_GET_IGC:
{
private_handle_t* hnd = va_arg(args, private_handle_t*);
uint32_t *igc = va_arg(args, uint32_t *);
if (!private_handle_t::validate(hnd) && igc) {
MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
if (metadata && (metadata->operation & SET_IGC)) {
*igc = metadata->igc;
res = 0;
}
}
} break;
case GRALLOC_MODULE_PERFORM_SET_IGC:
{
private_handle_t* hnd = va_arg(args, private_handle_t*);
uint32_t igc = va_arg(args, uint32_t);
if (!private_handle_t::validate(hnd)) {
MetaData_t *metadata = (MetaData_t *)hnd->base_metadata;
if (metadata) {
metadata->igc = (IGC_t) igc;
metadata->operation |= SET_IGC;
res = 0;
}
}
} break;
default:
break;
}

View File

@@ -99,6 +99,9 @@ int setMetaData(private_handle_t *handle, DispParamType paramType,
case LINEAR_FORMAT:
data->linearFormat = *((uint32_t *)param);
break;
case SET_IGC:
data->igc = *((IGC_t *)param);
break;
default:
ALOGE("Unknown paramType %d", paramType);
break;

View File

@@ -42,6 +42,11 @@ enum ColorSpace_t{
ITU_R_709,
};
enum IGC_t {
IGC_NotSpecified,
IGC_sRGB,
};
struct HSICData_t {
int32_t hue;
float saturation;
@@ -79,6 +84,7 @@ struct MetaData_t {
int64_t timestamp;
uint32_t refreshrate;
enum ColorSpace_t colorSpace;
enum IGC_t igc;
/* Gralloc sets PRIV_SECURE_BUFFER flag to inform that the buffers are from
* ION_SECURE. which should not be mapped. However, for GPU post proc
* feature, GFX needs to map this buffer, in the client context and in SF
@@ -107,6 +113,7 @@ enum DispParamType {
MAP_SECURE_BUFFER = 0x400,
S3D_FORMAT = 0x800,
LINEAR_FORMAT = 0x1000,
SET_IGC = 0x2000,
};
struct private_handle_t;

View File

@@ -93,10 +93,23 @@ enum LayerComposition {
//!< Blit target layers shall be after GPU target layer in layer stack.
};
enum LayerColorSpace {
kLimitedRange601, //!< 601 limited range color space
kFullRange601, //!< 601 full range color space
kLimitedRange709, //!< 709 limited range color space
/*! @brief This enum represents display layer color space conversion (CSC) matrix types.
@sa Layer
*/
enum LayerCSC {
kCSCLimitedRange601, //!< 601 limited range color space.
kCSCFullRange601, //!< 601 full range color space.
kCSCLimitedRange709, //!< 709 limited range color space.
};
/*! @brief This enum represents display layer inverse gamma correction (IGC) types.
@sa Layer
*/
enum LayerIGC {
kIGCNotSpecified, //!< IGC is not specified.
kIGCsRGB, //!< sRGB IGC type.
};
/*! @brief This structure defines rotation and flip values for a display layer.
@@ -260,15 +273,17 @@ struct Layer {
//!< }
//!< pixel.a = pixel.a * planeAlpha
LayerFlags flags; //!< Flags associated with this layer.
uint32_t frame_rate = 0; //!< Rate at which frames are being updated for
//!< this layer.
LayerColorSpace color_space = kLimitedRange601; //!< Color Space of the layer
LayerCSC csc = kCSCLimitedRange601; //!< Color Space of the layer.
LayerIGC igc = kIGCNotSpecified; //!< IGC that will be applied on this layer.
uint32_t solid_fill_color = 0; //!< Solid color used to fill the layer when
//!< no content is associated with the layer.
LayerFlags flags; //!< Flags associated with this layer.
};
/*! @brief This structure defines a layer stack that contains layers which need to be composed and

View File

@@ -228,14 +228,14 @@ struct HWPipeInfo {
uint8_t horizontal_decimation = 0;
uint8_t vertical_decimation = 0;
ScaleData scale_data;
bool valid = false;
uint32_t z_order = 0;
bool set_igc = false;
bool valid = false;
void Reset() { *this = HWPipeInfo(); }
};
struct HWLayerConfig {
bool use_non_dma_pipe = false; // set by client
HWPipeInfo left_pipe; // pipe for left side of output
HWPipeInfo right_pipe; // pipe for right side of output
HWRotatorSession hw_rotator_session;

View File

@@ -224,7 +224,10 @@ DisplayError HWDevice::Validate(HWLayers *hw_layers) {
SetRect(pipe_info->src_roi, &mdp_layer.src_rect);
SetRect(pipe_info->dst_roi, &mdp_layer.dst_rect);
SetMDPFlags(layer, is_rotator_used, is_cursor_pipe_used, &mdp_layer.flags);
SetColorSpace(layer.color_space, &mdp_layer.color_space);
SetCSC(layer.csc, &mdp_layer.color_space);
if (pipe_info->set_igc) {
SetIGC(layer, mdp_layer_count);
}
mdp_layer.bg_color = layer.solid_fill_color;
if (pipe_info->scale_data.enable_pixel_ext) {
@@ -874,6 +877,8 @@ void HWDevice::ResetDisplayParams() {
memset(&mdp_in_layers_, 0, sizeof(mdp_in_layers_));
memset(&mdp_out_layer_, 0, sizeof(mdp_out_layer_));
memset(&scale_data_, 0, sizeof(scale_data_));
memset(&pp_params_, 0, sizeof(pp_params_));
memset(&igc_lut_data_, 0, sizeof(igc_lut_data_));
for (uint32_t i = 0; i < kMaxSDELayers * 2; i++) {
mdp_in_layers_[i].buffer.fence = -1;
@@ -917,14 +922,38 @@ void HWDevice::SetHWScaleData(const ScaleData &scale, uint32_t index) {
}
}
void HWDevice::SetColorSpace(LayerColorSpace source, mdp_color_space *color_space) {
void HWDevice::SetCSC(LayerCSC source, mdp_color_space *color_space) {
switch (source) {
case kLimitedRange601: *color_space = MDP_CSC_ITU_R_601; break;
case kFullRange601: *color_space = MDP_CSC_ITU_R_601_FR; break;
case kLimitedRange709: *color_space = MDP_CSC_ITU_R_709; break;
case kCSCLimitedRange601: *color_space = MDP_CSC_ITU_R_601; break;
case kCSCFullRange601: *color_space = MDP_CSC_ITU_R_601_FR; break;
case kCSCLimitedRange709: *color_space = MDP_CSC_ITU_R_709; break;
}
}
void HWDevice::SetIGC(const Layer &layer, uint32_t index) {
mdp_input_layer &mdp_layer = mdp_in_layers_[index];
mdp_overlay_pp_params &pp_params = pp_params_[index];
mdp_igc_lut_data_v1_7 &igc_lut_data = igc_lut_data_[index];
switch (layer.igc) {
case kIGCsRGB:
igc_lut_data.table_fmt = mdp_igc_srgb;
pp_params.igc_cfg.ops = MDP_PP_OPS_WRITE | MDP_PP_OPS_ENABLE;
break;
default:
pp_params.igc_cfg.ops = MDP_PP_OPS_DISABLE;
break;
}
pp_params.config_ops = MDP_OVERLAY_PP_IGC_CFG;
pp_params.igc_cfg.version = mdp_igc_v1_7;
pp_params.igc_cfg.cfg_payload = &igc_lut_data;
mdp_layer.pp_info = &pp_params;
mdp_layer.flags |= MDP_LAYER_PP;
}
DisplayError HWDevice::SetCursorPosition(HWLayers *hw_layers, int x, int y) {
DTRACE_SCOPED();

View File

@@ -108,7 +108,8 @@ class HWDevice : public HWInterface {
mdp_scale_data* GetScaleDataRef(uint32_t index) { return &scale_data_[index]; }
void SetHWScaleData(const ScaleData &scale, uint32_t index);
void ResetDisplayParams();
void SetColorSpace(LayerColorSpace source, mdp_color_space *color_space);
void SetCSC(LayerCSC source, mdp_color_space *color_space);
void SetIGC(const Layer &layer, uint32_t index);
bool EnableHotPlugDetection(int enable);
ssize_t SysFsWrite(char* file_node, char* value, ssize_t length);
@@ -127,6 +128,8 @@ class HWDevice : public HWInterface {
mdp_layer_commit mdp_disp_commit_;
mdp_input_layer mdp_in_layers_[kMaxSDELayers * 2]; // split panel (left + right)
mdp_scale_data scale_data_[kMaxSDELayers * 2];
mdp_overlay_pp_params pp_params_[kMaxSDELayers * 2];
mdp_igc_lut_data_v1_7 igc_lut_data_[kMaxSDELayers * 2];
mdp_output_layer mdp_out_layer_;
const char *device_name_;
bool synchronous_commit_;

View File

@@ -892,7 +892,7 @@ DisplayError HWCDisplay::SetMaxMixerStages(uint32_t max_mixer_stages) {
return error;
}
DisplayError HWCDisplay:: ControlPartialUpdate(bool enable, uint32_t *pending) {
DisplayError HWCDisplay::ControlPartialUpdate(bool enable, uint32_t *pending) {
DisplayError error = kErrorNone;
if (display_intf_) {
@@ -1253,13 +1253,25 @@ uint32_t HWCDisplay::RoundToStandardFPS(uint32_t fps) {
void HWCDisplay::ApplyScanAdjustment(hwc_rect_t *display_frame) {
}
DisplayError HWCDisplay::SetColorSpace(const ColorSpace_t source, LayerColorSpace *target) {
DisplayError HWCDisplay::SetCSC(ColorSpace_t source, LayerCSC *target) {
switch (source) {
case ITU_R_601: *target = kLimitedRange601; break;
case ITU_R_601_FR: *target = kFullRange601; break;
case ITU_R_709: *target = kLimitedRange709; break;
case ITU_R_601: *target = kCSCLimitedRange601; break;
case ITU_R_601_FR: *target = kCSCFullRange601; break;
case ITU_R_709: *target = kCSCLimitedRange709; break;
default:
DLOGE("Unsupported Color Space: %d", source);
DLOGE("Unsupported CSC: %d", source);
return kErrorNotSupported;
}
return kErrorNone;
}
DisplayError HWCDisplay::SetIGC(IGC_t source, LayerIGC *target) {
switch (source) {
case IGC_NotSpecified: *target = kIGCNotSpecified; break;
case IGC_sRGB: *target = kIGCsRGB; break;
default:
DLOGE("Unsupported IGC: %d", source);
return kErrorNotSupported;
}
@@ -1275,7 +1287,13 @@ DisplayError HWCDisplay::SetMetaData(const private_handle_t *pvt_handle, Layer *
}
if (meta_data->operation & UPDATE_COLOR_SPACE) {
if (SetColorSpace(meta_data->colorSpace, &layer->color_space) != kErrorNone) {
if (SetCSC(meta_data->colorSpace, &layer->csc) != kErrorNone) {
return kErrorNotSupported;
}
}
if (meta_data->operation & SET_IGC) {
if (SetIGC(meta_data->igc, &layer->igc) != kErrorNone) {
return kErrorNotSupported;
}
}

View File

@@ -144,7 +144,8 @@ class HWCDisplay : public DisplayEventHandler {
void CloseAcquireFences(hwc_display_contents_1_t *content_list);
uint32_t RoundToStandardFPS(uint32_t fps);
virtual void ApplyScanAdjustment(hwc_rect_t *display_frame);
DisplayError SetColorSpace(const ColorSpace_t source, LayerColorSpace *target);
DisplayError SetCSC(ColorSpace_t source, LayerCSC *target);
DisplayError SetIGC(IGC_t source, LayerIGC *target);
DisplayError SetMetaData(const private_handle_t *pvt_handle, Layer *layer);
bool NeedsFrameBufferRefresh(hwc_display_contents_1_t *content_list);
void CacheLayerStackInfo(hwc_display_contents_1_t *content_list);