Commit d66cf5f5 authored by Anthony Koo's avatar Anthony Koo Committed by Alex Deucher

drm/amd/display: implement DXGI Gamma Ramps

Support for gamma correction ramp in Floating Point format
Signed-off-by: default avatarAnthony Koo <anthony.koo@amd.com>
Reviewed-by: default avatarTony Cheng <Tony.Cheng@amd.com>
Acked-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 665da60f
...@@ -1874,15 +1874,14 @@ static int fill_plane_attributes_from_fb( ...@@ -1874,15 +1874,14 @@ static int fill_plane_attributes_from_fb(
} }
#define NUM_OF_RAW_GAMMA_RAMP_RGB_256 256
static void fill_gamma_from_crtc_state( static void fill_gamma_from_crtc_state(
const struct drm_crtc_state *crtc_state, const struct drm_crtc_state *crtc_state,
struct dc_plane_state *plane_state) struct dc_plane_state *plane_state)
{ {
int i; int i;
struct dc_gamma *gamma; struct dc_gamma *gamma;
struct drm_color_lut *lut = (struct drm_color_lut *) crtc_state->gamma_lut->data; struct drm_color_lut *lut =
(struct drm_color_lut *) crtc_state->gamma_lut->data;
gamma = dc_create_gamma(); gamma = dc_create_gamma();
...@@ -1891,10 +1890,11 @@ static void fill_gamma_from_crtc_state( ...@@ -1891,10 +1890,11 @@ static void fill_gamma_from_crtc_state(
return; return;
} }
for (i = 0; i < NUM_OF_RAW_GAMMA_RAMP_RGB_256; i++) { gamma->type = GAMMA_RGB_256_ENTRIES;
gamma->red[i] = lut[i].red; for (i = 0; i < GAMMA_RGB_256_ENTRIES; i++) {
gamma->green[i] = lut[i].green; gamma->entries.red[i] = dal_fixed31_32_from_int(lut[i].red);
gamma->blue[i] = lut[i].blue; gamma->entries.green[i] = dal_fixed31_32_from_int(lut[i].green);
gamma->entries.blue[i] = dal_fixed31_32_from_int(lut[i].blue);
} }
plane_state->gamma_correction = gamma; plane_state->gamma_correction = gamma;
......
...@@ -409,20 +409,31 @@ struct dc_cursor_mi_param { ...@@ -409,20 +409,31 @@ struct dc_cursor_mi_param {
/* IPP related types */ /* IPP related types */
enum { enum {
INPUT_LUT_ENTRIES = 256 GAMMA_RGB_256_ENTRIES = 256,
GAMMA_RGB_FLOAT_1024_ENTRIES = 1024,
GAMMA_MAX_ENTRIES = 1024
};
enum dc_gamma_type {
GAMMA_RGB_256 = 1,
GAMMA_RGB_FLOAT_1024 = 2
}; };
struct dc_gamma { struct dc_gamma {
uint16_t red[INPUT_LUT_ENTRIES]; enum dc_gamma_type type;
uint16_t green[INPUT_LUT_ENTRIES]; unsigned int num_entries;
uint16_t blue[INPUT_LUT_ENTRIES];
struct dc_gamma_entries {
struct fixed31_32 red[GAMMA_MAX_ENTRIES];
struct fixed31_32 green[GAMMA_MAX_ENTRIES];
struct fixed31_32 blue[GAMMA_MAX_ENTRIES];
} entries;
/* private to DC core */ /* private to DC core */
struct dc_context *ctx; struct dc_context *ctx;
/* private to dc_surface.c */ /* private to dc_surface.c */
int ref_count; int ref_count;
}; };
/* Used by both ipp amd opp functions*/ /* Used by both ipp amd opp functions*/
......
...@@ -193,10 +193,16 @@ static void dce_ipp_program_input_lut( ...@@ -193,10 +193,16 @@ static void dce_ipp_program_input_lut(
REG_SET(DC_LUT_RW_INDEX, 0, REG_SET(DC_LUT_RW_INDEX, 0,
DC_LUT_RW_INDEX, 0); DC_LUT_RW_INDEX, 0);
for (i = 0; i < INPUT_LUT_ENTRIES; i++) { for (i = 0; i < gamma->num_entries; i++) {
REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, gamma->red[i]); REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR,
REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, gamma->green[i]); dal_fixed31_32_round(
REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR, gamma->blue[i]); gamma->entries.red[i]));
REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR,
dal_fixed31_32_round(
gamma->entries.green[i]));
REG_SET(DC_LUT_SEQ_COLOR, 0, DC_LUT_SEQ_COLOR,
dal_fixed31_32_round(
gamma->entries.blue[i]));
} }
/* power off LUT memory */ /* power off LUT memory */
......
...@@ -910,13 +910,16 @@ static void ippn10_program_input_lut( ...@@ -910,13 +910,16 @@ static void ippn10_program_input_lut(
CM_IGAM_LUT_FORMAT_B, 3); CM_IGAM_LUT_FORMAT_B, 3);
// Start at index 0 of IGAM LUT // Start at index 0 of IGAM LUT
REG_UPDATE(CM_IGAM_LUT_RW_INDEX, CM_IGAM_LUT_RW_INDEX, 0); REG_UPDATE(CM_IGAM_LUT_RW_INDEX, CM_IGAM_LUT_RW_INDEX, 0);
for (i = 0; i < INPUT_LUT_ENTRIES; i++) { for (i = 0; i < gamma->num_entries; i++) {
REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR,
gamma->red[i]); dal_fixed31_32_round(
gamma->entries.red[i]));
REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR,
gamma->green[i]); dal_fixed31_32_round(
gamma->entries.green[i]));
REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR, REG_SET(CM_IGAM_LUT_SEQ_COLOR, 0, CM_IGAM_LUT_SEQ_COLOR,
gamma->blue[i]); dal_fixed31_32_round(
gamma->entries.blue[i]));
} }
// Power off LUT memory // Power off LUT memory
REG_SET(CM_MEM_PWR_CTRL, 0, SHARED_MEM_PWR_DIS, 0); REG_SET(CM_MEM_PWR_CTRL, 0, SHARED_MEM_PWR_DIS, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment