Commit 2057b7e1 authored by Wenjing Liu's avatar Wenjing Liu Committed by Alex Deucher

drm/amd/display: add color space option when sending link test pattern

[why]
In the TEST_MSIC dpcd register field definition, the test equipment
has the option to choose between YCbCr601 or YCbCr709.
We will apply corresponding YCbCr coefficient based on this test
request.

[how]
Add a new input parameter in dc_link_dp_set_test_pattern to allow the
selection between different color space.
Signed-off-by: default avatarWenjing Liu <Wenjing.Liu@amd.com>
Reviewed-by: default avatarNikola Cornij <Nikola.Cornij@amd.com>
Acked-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent d9e32672
...@@ -657,6 +657,7 @@ static ssize_t dp_phy_test_pattern_debugfs_write(struct file *f, const char __us ...@@ -657,6 +657,7 @@ static ssize_t dp_phy_test_pattern_debugfs_write(struct file *f, const char __us
dc_link_set_test_pattern( dc_link_set_test_pattern(
link, link,
test_pattern, test_pattern,
DP_TEST_PATTERN_COLOR_SPACE_RGB,
&link_training_settings, &link_training_settings,
custom_pattern, custom_pattern,
10); 10);
......
...@@ -3319,6 +3319,7 @@ void dc_link_disable_hpd(const struct dc_link *link) ...@@ -3319,6 +3319,7 @@ void dc_link_disable_hpd(const struct dc_link *link)
void dc_link_set_test_pattern(struct dc_link *link, void dc_link_set_test_pattern(struct dc_link *link,
enum dp_test_pattern test_pattern, enum dp_test_pattern test_pattern,
enum dp_test_pattern_color_space test_pattern_color_space,
const struct link_training_settings *p_link_settings, const struct link_training_settings *p_link_settings,
const unsigned char *p_custom_pattern, const unsigned char *p_custom_pattern,
unsigned int cust_pattern_size) unsigned int cust_pattern_size)
...@@ -3327,6 +3328,7 @@ void dc_link_set_test_pattern(struct dc_link *link, ...@@ -3327,6 +3328,7 @@ void dc_link_set_test_pattern(struct dc_link *link,
dc_link_dp_set_test_pattern( dc_link_dp_set_test_pattern(
link, link,
test_pattern, test_pattern,
test_pattern_color_space,
p_link_settings, p_link_settings,
p_custom_pattern, p_custom_pattern,
cust_pattern_size); cust_pattern_size);
......
...@@ -2493,6 +2493,7 @@ static void dp_test_send_phy_test_pattern(struct dc_link *link) ...@@ -2493,6 +2493,7 @@ static void dp_test_send_phy_test_pattern(struct dc_link *link)
dc_link_dp_set_test_pattern( dc_link_dp_set_test_pattern(
link, link,
test_pattern, test_pattern,
DP_TEST_PATTERN_COLOR_SPACE_UNDEFINED,
&link_training_settings, &link_training_settings,
test_80_bit_pattern, test_80_bit_pattern,
(DP_TEST_80BIT_CUSTOM_PATTERN_79_72 - (DP_TEST_80BIT_CUSTOM_PATTERN_79_72 -
...@@ -2504,6 +2505,8 @@ static void dp_test_send_link_test_pattern(struct dc_link *link) ...@@ -2504,6 +2505,8 @@ static void dp_test_send_link_test_pattern(struct dc_link *link)
union link_test_pattern dpcd_test_pattern; union link_test_pattern dpcd_test_pattern;
union test_misc dpcd_test_params; union test_misc dpcd_test_params;
enum dp_test_pattern test_pattern; enum dp_test_pattern test_pattern;
enum dp_test_pattern_color_space test_pattern_color_space =
DP_TEST_PATTERN_COLOR_SPACE_UNDEFINED;
memset(&dpcd_test_pattern, 0, sizeof(dpcd_test_pattern)); memset(&dpcd_test_pattern, 0, sizeof(dpcd_test_pattern));
memset(&dpcd_test_params, 0, sizeof(dpcd_test_params)); memset(&dpcd_test_params, 0, sizeof(dpcd_test_params));
...@@ -2538,9 +2541,14 @@ static void dp_test_send_link_test_pattern(struct dc_link *link) ...@@ -2538,9 +2541,14 @@ static void dp_test_send_link_test_pattern(struct dc_link *link)
break; break;
} }
test_pattern_color_space = dpcd_test_params.bits.YCBCR_COEFS ?
DP_TEST_PATTERN_COLOR_SPACE_YCBCR709 :
DP_TEST_PATTERN_COLOR_SPACE_YCBCR601;
dc_link_dp_set_test_pattern( dc_link_dp_set_test_pattern(
link, link,
test_pattern, test_pattern,
test_pattern_color_space,
NULL, NULL,
NULL, NULL,
0); 0);
...@@ -3426,7 +3434,8 @@ static bool is_dp_phy_pattern(enum dp_test_pattern test_pattern) ...@@ -3426,7 +3434,8 @@ static bool is_dp_phy_pattern(enum dp_test_pattern test_pattern)
static void set_crtc_test_pattern(struct dc_link *link, static void set_crtc_test_pattern(struct dc_link *link,
struct pipe_ctx *pipe_ctx, struct pipe_ctx *pipe_ctx,
enum dp_test_pattern test_pattern) enum dp_test_pattern test_pattern,
enum dp_test_pattern_color_space test_pattern_color_space)
{ {
enum controller_dp_test_pattern controller_test_pattern; enum controller_dp_test_pattern controller_test_pattern;
enum dc_color_depth color_depth = pipe_ctx-> enum dc_color_depth color_depth = pipe_ctx->
...@@ -3484,8 +3493,27 @@ static void set_crtc_test_pattern(struct dc_link *link, ...@@ -3484,8 +3493,27 @@ static void set_crtc_test_pattern(struct dc_link *link,
controller_test_pattern, color_depth); controller_test_pattern, color_depth);
else if (opp->funcs->opp_set_disp_pattern_generator) { else if (opp->funcs->opp_set_disp_pattern_generator) {
struct pipe_ctx *odm_pipe; struct pipe_ctx *odm_pipe;
enum controller_dp_color_space controller_color_space;
int opp_cnt = 1; int opp_cnt = 1;
switch (test_pattern_color_space) {
case DP_TEST_PATTERN_COLOR_SPACE_RGB:
controller_color_space = CONTROLLER_DP_COLOR_SPACE_RGB;
break;
case DP_TEST_PATTERN_COLOR_SPACE_YCBCR601:
controller_color_space = CONTROLLER_DP_COLOR_SPACE_YCBCR601;
break;
case DP_TEST_PATTERN_COLOR_SPACE_YCBCR709:
controller_color_space = CONTROLLER_DP_COLOR_SPACE_YCBCR709;
break;
case DP_TEST_PATTERN_COLOR_SPACE_UNDEFINED:
default:
controller_color_space = CONTROLLER_DP_COLOR_SPACE_UDEFINED;
DC_LOG_ERROR("%s: Color space must be defined for test pattern", __func__);
ASSERT(0);
break;
}
for (odm_pipe = pipe_ctx->next_odm_pipe; odm_pipe; odm_pipe = odm_pipe->next_odm_pipe) for (odm_pipe = pipe_ctx->next_odm_pipe; odm_pipe; odm_pipe = odm_pipe->next_odm_pipe)
opp_cnt++; opp_cnt++;
...@@ -3497,6 +3525,7 @@ static void set_crtc_test_pattern(struct dc_link *link, ...@@ -3497,6 +3525,7 @@ static void set_crtc_test_pattern(struct dc_link *link,
odm_opp->funcs->opp_program_bit_depth_reduction(odm_opp, &params); odm_opp->funcs->opp_program_bit_depth_reduction(odm_opp, &params);
odm_opp->funcs->opp_set_disp_pattern_generator(odm_opp, odm_opp->funcs->opp_set_disp_pattern_generator(odm_opp,
controller_test_pattern, controller_test_pattern,
controller_color_space,
color_depth, color_depth,
NULL, NULL,
width, width,
...@@ -3504,6 +3533,7 @@ static void set_crtc_test_pattern(struct dc_link *link, ...@@ -3504,6 +3533,7 @@ static void set_crtc_test_pattern(struct dc_link *link,
} }
opp->funcs->opp_set_disp_pattern_generator(opp, opp->funcs->opp_set_disp_pattern_generator(opp,
controller_test_pattern, controller_test_pattern,
controller_color_space,
color_depth, color_depth,
NULL, NULL,
width, width,
...@@ -3535,6 +3565,7 @@ static void set_crtc_test_pattern(struct dc_link *link, ...@@ -3535,6 +3565,7 @@ static void set_crtc_test_pattern(struct dc_link *link,
odm_opp->funcs->opp_program_bit_depth_reduction(odm_opp, &params); odm_opp->funcs->opp_program_bit_depth_reduction(odm_opp, &params);
odm_opp->funcs->opp_set_disp_pattern_generator(odm_opp, odm_opp->funcs->opp_set_disp_pattern_generator(odm_opp,
CONTROLLER_DP_TEST_PATTERN_VIDEOMODE, CONTROLLER_DP_TEST_PATTERN_VIDEOMODE,
CONTROLLER_DP_COLOR_SPACE_UDEFINED,
color_depth, color_depth,
NULL, NULL,
width, width,
...@@ -3542,6 +3573,7 @@ static void set_crtc_test_pattern(struct dc_link *link, ...@@ -3542,6 +3573,7 @@ static void set_crtc_test_pattern(struct dc_link *link,
} }
opp->funcs->opp_set_disp_pattern_generator(opp, opp->funcs->opp_set_disp_pattern_generator(opp,
CONTROLLER_DP_TEST_PATTERN_VIDEOMODE, CONTROLLER_DP_TEST_PATTERN_VIDEOMODE,
CONTROLLER_DP_COLOR_SPACE_UDEFINED,
color_depth, color_depth,
NULL, NULL,
width, width,
...@@ -3558,6 +3590,7 @@ static void set_crtc_test_pattern(struct dc_link *link, ...@@ -3558,6 +3590,7 @@ static void set_crtc_test_pattern(struct dc_link *link,
bool dc_link_dp_set_test_pattern( bool dc_link_dp_set_test_pattern(
struct dc_link *link, struct dc_link *link,
enum dp_test_pattern test_pattern, enum dp_test_pattern test_pattern,
enum dp_test_pattern_color_space test_pattern_color_space,
const struct link_training_settings *p_link_settings, const struct link_training_settings *p_link_settings,
const unsigned char *p_custom_pattern, const unsigned char *p_custom_pattern,
unsigned int cust_pattern_size) unsigned int cust_pattern_size)
...@@ -3586,7 +3619,7 @@ bool dc_link_dp_set_test_pattern( ...@@ -3586,7 +3619,7 @@ bool dc_link_dp_set_test_pattern(
if (link->test_pattern_enabled && test_pattern == if (link->test_pattern_enabled && test_pattern ==
DP_TEST_PATTERN_VIDEO_MODE) { DP_TEST_PATTERN_VIDEO_MODE) {
/* Set CRTC Test Pattern */ /* Set CRTC Test Pattern */
set_crtc_test_pattern(link, pipe_ctx, test_pattern); set_crtc_test_pattern(link, pipe_ctx, test_pattern, test_pattern_color_space);
dp_set_hw_test_pattern(link, test_pattern, dp_set_hw_test_pattern(link, test_pattern,
(uint8_t *)p_custom_pattern, (uint8_t *)p_custom_pattern,
(uint32_t)cust_pattern_size); (uint32_t)cust_pattern_size);
...@@ -3701,7 +3734,7 @@ bool dc_link_dp_set_test_pattern( ...@@ -3701,7 +3734,7 @@ bool dc_link_dp_set_test_pattern(
} }
} else { } else {
/* CRTC Patterns */ /* CRTC Patterns */
set_crtc_test_pattern(link, pipe_ctx, test_pattern); set_crtc_test_pattern(link, pipe_ctx, test_pattern, test_pattern_color_space);
/* Set Test Pattern state */ /* Set Test Pattern state */
link->test_pattern_enabled = true; link->test_pattern_enabled = true;
} }
......
...@@ -522,14 +522,14 @@ union link_test_pattern { ...@@ -522,14 +522,14 @@ union link_test_pattern {
union test_misc { union test_misc {
struct dpcd_test_misc_bits { struct dpcd_test_misc_bits {
unsigned char SYNC_CLOCK :1; unsigned char SYNC_CLOCK :1;
/* dpcd_test_color_format */ /* dpcd_test_color_format */
unsigned char CLR_FORMAT :2; unsigned char CLR_FORMAT :2;
/* dpcd_test_dyn_range */ /* dpcd_test_dyn_range */
unsigned char DYN_RANGE :1; unsigned char DYN_RANGE :1;
unsigned char YCBCR :1; unsigned char YCBCR_COEFS :1;
/* dpcd_test_bit_depth */ /* dpcd_test_bit_depth */
unsigned char BPC :3; unsigned char BPC :3;
} bits; } bits;
unsigned char raw; unsigned char raw;
}; };
......
...@@ -257,6 +257,7 @@ void dc_link_dp_disable_hpd(const struct dc_link *link); ...@@ -257,6 +257,7 @@ void dc_link_dp_disable_hpd(const struct dc_link *link);
bool dc_link_dp_set_test_pattern( bool dc_link_dp_set_test_pattern(
struct dc_link *link, struct dc_link *link,
enum dp_test_pattern test_pattern, enum dp_test_pattern test_pattern,
enum dp_test_pattern_color_space test_pattern_color_space,
const struct link_training_settings *p_link_settings, const struct link_training_settings *p_link_settings,
const unsigned char *p_custom_pattern, const unsigned char *p_custom_pattern,
unsigned int cust_pattern_size); unsigned int cust_pattern_size);
...@@ -288,6 +289,7 @@ void dc_link_enable_hpd(const struct dc_link *link); ...@@ -288,6 +289,7 @@ void dc_link_enable_hpd(const struct dc_link *link);
void dc_link_disable_hpd(const struct dc_link *link); void dc_link_disable_hpd(const struct dc_link *link);
void dc_link_set_test_pattern(struct dc_link *link, void dc_link_set_test_pattern(struct dc_link *link,
enum dp_test_pattern test_pattern, enum dp_test_pattern test_pattern,
enum dp_test_pattern_color_space test_pattern_color_space,
const struct link_training_settings *p_link_settings, const struct link_training_settings *p_link_settings,
const unsigned char *p_custom_pattern, const unsigned char *p_custom_pattern,
unsigned int cust_pattern_size); unsigned int cust_pattern_size);
......
...@@ -223,6 +223,7 @@ void dcn20_init_blank( ...@@ -223,6 +223,7 @@ void dcn20_init_blank(
opp->funcs->opp_set_disp_pattern_generator( opp->funcs->opp_set_disp_pattern_generator(
opp, opp,
CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR, CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR,
CONTROLLER_DP_COLOR_SPACE_UDEFINED,
COLOR_DEPTH_UNDEFINED, COLOR_DEPTH_UNDEFINED,
&black_color, &black_color,
otg_active_width, otg_active_width,
...@@ -232,6 +233,7 @@ void dcn20_init_blank( ...@@ -232,6 +233,7 @@ void dcn20_init_blank(
bottom_opp->funcs->opp_set_disp_pattern_generator( bottom_opp->funcs->opp_set_disp_pattern_generator(
bottom_opp, bottom_opp,
CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR, CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR,
CONTROLLER_DP_COLOR_SPACE_UDEFINED,
COLOR_DEPTH_UNDEFINED, COLOR_DEPTH_UNDEFINED,
&black_color, &black_color,
otg_active_width, otg_active_width,
...@@ -851,6 +853,7 @@ void dcn20_blank_pixel_data( ...@@ -851,6 +853,7 @@ void dcn20_blank_pixel_data(
struct dc_stream_state *stream = pipe_ctx->stream; struct dc_stream_state *stream = pipe_ctx->stream;
enum dc_color_space color_space = stream->output_color_space; enum dc_color_space color_space = stream->output_color_space;
enum controller_dp_test_pattern test_pattern = CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR; enum controller_dp_test_pattern test_pattern = CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR;
enum controller_dp_color_space test_pattern_color_space = CONTROLLER_DP_COLOR_SPACE_UDEFINED;
struct pipe_ctx *odm_pipe; struct pipe_ctx *odm_pipe;
int odm_cnt = 1; int odm_cnt = 1;
...@@ -869,8 +872,10 @@ void dcn20_blank_pixel_data( ...@@ -869,8 +872,10 @@ void dcn20_blank_pixel_data(
if (stream_res->abm) if (stream_res->abm)
stream_res->abm->funcs->set_abm_immediate_disable(stream_res->abm); stream_res->abm->funcs->set_abm_immediate_disable(stream_res->abm);
if (dc->debug.visual_confirm != VISUAL_CONFIRM_DISABLE) if (dc->debug.visual_confirm != VISUAL_CONFIRM_DISABLE) {
test_pattern = CONTROLLER_DP_TEST_PATTERN_COLORSQUARES; test_pattern = CONTROLLER_DP_TEST_PATTERN_COLORSQUARES;
test_pattern_color_space = CONTROLLER_DP_COLOR_SPACE_RGB;
}
} else { } else {
test_pattern = CONTROLLER_DP_TEST_PATTERN_VIDEOMODE; test_pattern = CONTROLLER_DP_TEST_PATTERN_VIDEOMODE;
} }
...@@ -878,6 +883,7 @@ void dcn20_blank_pixel_data( ...@@ -878,6 +883,7 @@ void dcn20_blank_pixel_data(
stream_res->opp->funcs->opp_set_disp_pattern_generator( stream_res->opp->funcs->opp_set_disp_pattern_generator(
stream_res->opp, stream_res->opp,
test_pattern, test_pattern,
test_pattern_color_space,
stream->timing.display_color_depth, stream->timing.display_color_depth,
&black_color, &black_color,
width, width,
...@@ -888,6 +894,7 @@ void dcn20_blank_pixel_data( ...@@ -888,6 +894,7 @@ void dcn20_blank_pixel_data(
odm_pipe->stream_res.opp, odm_pipe->stream_res.opp,
dc->debug.visual_confirm != VISUAL_CONFIRM_DISABLE && blank ? dc->debug.visual_confirm != VISUAL_CONFIRM_DISABLE && blank ?
CONTROLLER_DP_TEST_PATTERN_COLORRAMP : test_pattern, CONTROLLER_DP_TEST_PATTERN_COLORRAMP : test_pattern,
test_pattern_color_space,
stream->timing.display_color_depth, stream->timing.display_color_depth,
&black_color, &black_color,
width, width,
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
void opp2_set_disp_pattern_generator( void opp2_set_disp_pattern_generator(
struct output_pixel_processor *opp, struct output_pixel_processor *opp,
enum controller_dp_test_pattern test_pattern, enum controller_dp_test_pattern test_pattern,
enum controller_dp_color_space color_space,
enum dc_color_depth color_depth, enum dc_color_depth color_depth,
const struct tg_color *solid_color, const struct tg_color *solid_color,
int width, int width,
...@@ -100,9 +101,22 @@ void opp2_set_disp_pattern_generator( ...@@ -100,9 +101,22 @@ void opp2_set_disp_pattern_generator(
TEST_PATTERN_DYN_RANGE_CEA : TEST_PATTERN_DYN_RANGE_CEA :
TEST_PATTERN_DYN_RANGE_VESA); TEST_PATTERN_DYN_RANGE_VESA);
switch (color_space) {
case CONTROLLER_DP_COLOR_SPACE_YCBCR601:
mode = TEST_PATTERN_MODE_COLORSQUARES_YCBCR601;
break;
case CONTROLLER_DP_COLOR_SPACE_YCBCR709:
mode = TEST_PATTERN_MODE_COLORSQUARES_YCBCR709;
break;
case CONTROLLER_DP_COLOR_SPACE_RGB:
default:
mode = TEST_PATTERN_MODE_COLORSQUARES_RGB;
break;
}
REG_UPDATE_6(DPG_CONTROL, REG_UPDATE_6(DPG_CONTROL,
DPG_EN, 1, DPG_EN, 1,
DPG_MODE, TEST_PATTERN_MODE_COLORSQUARES_RGB, DPG_MODE, mode,
DPG_DYNAMIC_RANGE, dyn_range, DPG_DYNAMIC_RANGE, dyn_range,
DPG_BIT_DEPTH, bit_depth, DPG_BIT_DEPTH, bit_depth,
DPG_VRES, 6, DPG_VRES, 6,
......
...@@ -140,6 +140,7 @@ void dcn20_opp_construct(struct dcn20_opp *oppn20, ...@@ -140,6 +140,7 @@ void dcn20_opp_construct(struct dcn20_opp *oppn20,
void opp2_set_disp_pattern_generator( void opp2_set_disp_pattern_generator(
struct output_pixel_processor *opp, struct output_pixel_processor *opp,
enum controller_dp_test_pattern test_pattern, enum controller_dp_test_pattern test_pattern,
enum controller_dp_color_space color_space,
enum dc_color_depth color_depth, enum dc_color_depth color_depth,
const struct tg_color *solid_color, const struct tg_color *solid_color,
int width, int width,
......
...@@ -245,6 +245,13 @@ enum controller_dp_test_pattern { ...@@ -245,6 +245,13 @@ enum controller_dp_test_pattern {
CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR
}; };
enum controller_dp_color_space {
CONTROLLER_DP_COLOR_SPACE_RGB,
CONTROLLER_DP_COLOR_SPACE_YCBCR601,
CONTROLLER_DP_COLOR_SPACE_YCBCR709,
CONTROLLER_DP_COLOR_SPACE_UDEFINED
};
enum dc_lut_mode { enum dc_lut_mode {
LUT_BYPASS, LUT_BYPASS,
LUT_RAM_A, LUT_RAM_A,
......
...@@ -306,6 +306,7 @@ struct opp_funcs { ...@@ -306,6 +306,7 @@ struct opp_funcs {
void (*opp_set_disp_pattern_generator)( void (*opp_set_disp_pattern_generator)(
struct output_pixel_processor *opp, struct output_pixel_processor *opp,
enum controller_dp_test_pattern test_pattern, enum controller_dp_test_pattern test_pattern,
enum controller_dp_color_space color_space,
enum dc_color_depth color_depth, enum dc_color_depth color_depth,
const struct tg_color *solid_color, const struct tg_color *solid_color,
int width, int width,
......
...@@ -123,6 +123,13 @@ enum dp_test_pattern { ...@@ -123,6 +123,13 @@ enum dp_test_pattern {
DP_TEST_PATTERN_UNSUPPORTED DP_TEST_PATTERN_UNSUPPORTED
}; };
enum dp_test_pattern_color_space {
DP_TEST_PATTERN_COLOR_SPACE_RGB,
DP_TEST_PATTERN_COLOR_SPACE_YCBCR601,
DP_TEST_PATTERN_COLOR_SPACE_YCBCR709,
DP_TEST_PATTERN_COLOR_SPACE_UNDEFINED
};
enum dp_panel_mode { enum dp_panel_mode {
/* not required */ /* not required */
DP_PANEL_MODE_DEFAULT, DP_PANEL_MODE_DEFAULT,
......
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