From 9355cfcaeb2d61d83fab2890508b1d81f6d4419e Mon Sep 17 00:00:00 2001 From: Vinu Deokaran Date: Sun, 12 Oct 2014 11:32:59 -0400 Subject: [PATCH] msm: mdss: add csc tables for mdp5 for various color spaces Add csc tables for 601 full, 601 limited and 709 limited to support different csc matrices. HAL provides color space request to driver, consider it to choose appropriate matrix for conversion. This will help in solving artifacts during GPU/MDP switches so that both GPU and MDP choose same matrix for conversion. Change-Id: Idd73e0695ea64d0c0bd778dba07199e209ca6f3d Signed-off-by: Vinu Deokaran Signed-off-by: Kalyan Thota Signed-off-by: Ping Li --- drivers/video/fbdev/msm/mdss_mdp.c | 4 + drivers/video/fbdev/msm/mdss_mdp.h | 24 ++++- drivers/video/fbdev/msm/mdss_mdp_cdm.c | 2 +- drivers/video/fbdev/msm/mdss_mdp_intf_video.c | 2 +- .../video/fbdev/msm/mdss_mdp_intf_writeback.c | 4 +- drivers/video/fbdev/msm/mdss_mdp_overlay.c | 5 + drivers/video/fbdev/msm/mdss_mdp_pp.c | 102 +++++++++++++----- 7 files changed, 109 insertions(+), 34 deletions(-) diff --git a/drivers/video/fbdev/msm/mdss_mdp.c b/drivers/video/fbdev/msm/mdss_mdp.c index 86d71d8a8674..4aa6fc689005 100644 --- a/drivers/video/fbdev/msm/mdss_mdp.c +++ b/drivers/video/fbdev/msm/mdss_mdp.c @@ -1175,6 +1175,10 @@ void mdss_hw_init(struct mdss_data_type *mdata) writel_relaxed(1, offset + 16); } + /* initialize csc matrix default value */ + for (i = 0; i < mdata->nvig_pipes; i++) + vig[i].csc_coeff_set = MDSS_MDP_CSC_YUV2RGB_709L; + mdata->nmax_concurrent_ad_hw = (mdata->mdp_rev < MDSS_MDP_HW_REV_103) ? 1 : 2; diff --git a/drivers/video/fbdev/msm/mdss_mdp.h b/drivers/video/fbdev/msm/mdss_mdp.h index e0f4e04df47e..a97e339bc4f3 100644 --- a/drivers/video/fbdev/msm/mdss_mdp.h +++ b/drivers/video/fbdev/msm/mdss_mdp.h @@ -128,10 +128,14 @@ enum mdss_mdp_block_type { }; enum mdss_mdp_csc_type { - MDSS_MDP_CSC_RGB2RGB, - MDSS_MDP_CSC_YUV2RGB, - MDSS_MDP_CSC_RGB2YUV, + MDSS_MDP_CSC_YUV2RGB_601L, + MDSS_MDP_CSC_YUV2RGB_601FR, + MDSS_MDP_CSC_YUV2RGB_709L, + MDSS_MDP_CSC_RGB2YUV_601L, + MDSS_MDP_CSC_RGB2YUV_601FR, + MDSS_MDP_CSC_RGB2YUV_709L, MDSS_MDP_CSC_YUV2YUV, + MDSS_MDP_CSC_RGB2RGB, MDSS_MDP_MAX_CSC }; @@ -568,6 +572,7 @@ struct mdss_mdp_pipe { u8 chroma_sample_v; u32 frame_rate; + u8 csc_coeff_set; }; struct mdss_mdp_writeback_arg { @@ -944,6 +949,19 @@ static inline u32 mdss_mdp_get_cursor_frame_size(struct mdss_data_type *mdata) return mdata->max_cursor_size * mdata->max_cursor_size * 4; } +static inline uint8_t pp_vig_csc_pipe_val(struct mdss_mdp_pipe *pipe) +{ + switch (pipe->csc_coeff_set) { + case MDP_CSC_ITU_R_601: + return MDSS_MDP_CSC_YUV2RGB_601L; + case MDP_CSC_ITU_R_601_FR: + return MDSS_MDP_CSC_YUV2RGB_601FR; + case MDP_CSC_ITU_R_709: + default: + return MDSS_MDP_CSC_YUV2RGB_709L; + } +} + irqreturn_t mdss_mdp_isr(int irq, void *ptr); void mdss_mdp_irq_clear(struct mdss_data_type *mdata, u32 intr_type, u32 intf_num); diff --git a/drivers/video/fbdev/msm/mdss_mdp_cdm.c b/drivers/video/fbdev/msm/mdss_mdp_cdm.c index 7c3ca6125589..5905e6607775 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_cdm.c +++ b/drivers/video/fbdev/msm/mdss_mdp_cdm.c @@ -129,7 +129,7 @@ static int mdss_mdp_cdm_csc_setup(struct mdss_mdp_cdm *cdm, int rc = 0; u32 op_mode = 0; - if (data->csc_type == MDSS_MDP_CSC_RGB2YUV) { + if (data->csc_type == MDSS_MDP_CSC_RGB2YUV_601L) { op_mode |= BIT(2); /* DST_DATA_FORMAT = YUV */ op_mode &= ~BIT(1); /* SRC_DATA_FORMAT = RGB */ op_mode |= BIT(0); /* EN = 1 */ diff --git a/drivers/video/fbdev/msm/mdss_mdp_intf_video.c b/drivers/video/fbdev/msm/mdss_mdp_intf_video.c index 0bc74742aa0c..fc43626ee3b9 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_intf_video.c +++ b/drivers/video/fbdev/msm/mdss_mdp_intf_video.c @@ -1252,7 +1252,7 @@ static int mdss_mdp_video_cdm_setup(struct mdss_mdp_cdm *cdm, } setup.out_format = pinfo->out_format; if (fmt->is_yuv) - setup.csc_type = MDSS_MDP_CSC_RGB2YUV; + setup.csc_type = MDSS_MDP_CSC_RGB2YUV_601L; else setup.csc_type = MDSS_MDP_CSC_RGB2RGB; diff --git a/drivers/video/fbdev/msm/mdss_mdp_intf_writeback.c b/drivers/video/fbdev/msm/mdss_mdp_intf_writeback.c index 87f30349f345..543c3cb3eb33 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_intf_writeback.c +++ b/drivers/video/fbdev/msm/mdss_mdp_intf_writeback.c @@ -161,7 +161,7 @@ static int mdss_mdp_writeback_cdm_setup(struct mdss_mdp_writeback_ctx *ctx, } if (fmt->is_yuv) - setup.csc_type = MDSS_MDP_CSC_RGB2YUV; + setup.csc_type = MDSS_MDP_CSC_RGB2YUV_601L; else setup.csc_type = MDSS_MDP_CSC_RGB2RGB; @@ -258,7 +258,7 @@ static int mdss_mdp_writeback_format_setup(struct mdss_mdp_writeback_ctx *ctx, if (ctx->type != MDSS_MDP_WRITEBACK_TYPE_ROTATOR && fmt->is_yuv && !ctl->cdm) { mdss_mdp_csc_setup(MDSS_MDP_BLOCK_WB, ctx->wb_num, - MDSS_MDP_CSC_RGB2YUV); + MDSS_MDP_CSC_RGB2YUV_601L); opmode |= (1 << 8) | /* CSC_EN */ (0 << 9) | /* SRC_DATA=RGB */ (1 << 10); /* DST_DATA=YCBCR */ diff --git a/drivers/video/fbdev/msm/mdss_mdp_overlay.c b/drivers/video/fbdev/msm/mdss_mdp_overlay.c index 7456485a8dd7..8ca902851b18 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_overlay.c +++ b/drivers/video/fbdev/msm/mdss_mdp_overlay.c @@ -915,6 +915,11 @@ int mdss_mdp_overlay_pipe_setup(struct msm_fb_data_type *mfd, } } + /* + * Populate Color Space. + */ + if (pipe->src_fmt->is_yuv && (pipe->type == MDSS_MDP_PIPE_TYPE_VIG)) + pipe->csc_coeff_set = req->color_space; /* * When scaling is enabled src crop and image * width and height is modified by user diff --git a/drivers/video/fbdev/msm/mdss_mdp_pp.c b/drivers/video/fbdev/msm/mdss_mdp_pp.c index 40f0d2959efe..4d2dac0ecdcc 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_pp.c +++ b/drivers/video/fbdev/msm/mdss_mdp_pp.c @@ -25,7 +25,79 @@ #include "mdss_mdp_pp_cache_config.h" struct mdp_csc_cfg mdp_csc_convert[MDSS_MDP_MAX_CSC] = { - [MDSS_MDP_CSC_RGB2RGB] = { + [MDSS_MDP_CSC_YUV2RGB_601L] = { + 0, + { + 0x0254, 0x0000, 0x0331, + 0x0254, 0xff37, 0xfe60, + 0x0254, 0x0409, 0x0000, + }, + { 0xfff0, 0xff80, 0xff80,}, + { 0x0, 0x0, 0x0,}, + { 0x10, 0xeb, 0x10, 0xf0, 0x10, 0xf0,}, + { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, + }, + [MDSS_MDP_CSC_YUV2RGB_601FR] = { + 0, + { + 0x0200, 0x0000, 0x02ce, + 0x0200, 0xff50, 0xfe92, + 0x0200, 0x038b, 0x0000, + }, + { 0x0000, 0xff80, 0xff80,}, + { 0x0, 0x0, 0x0,}, + { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, + { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, + }, + [MDSS_MDP_CSC_YUV2RGB_709L] = { + 0, + { + 0x0254, 0x0000, 0x0396, + 0x0254, 0xff93, 0xfeef, + 0x0254, 0x043e, 0x0000, + }, + { 0xfff0, 0xff80, 0xff80,}, + { 0x0, 0x0, 0x0,}, + { 0x10, 0xeb, 0x10, 0xf0, 0x10, 0xf0,}, + { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, + }, + [MDSS_MDP_CSC_RGB2YUV_601L] = { + 0, + { + 0x0083, 0x0102, 0x0032, + 0xffb4, 0xff6b, 0x00e1, + 0x00e1, 0xff44, 0xffdb + }, + { 0x0, 0x0, 0x0,}, + { 0x0010, 0x0080, 0x0080,}, + { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, + { 0x0010, 0x00eb, 0x0010, 0x00f0, 0x0010, 0x00f0,}, + }, + [MDSS_MDP_CSC_RGB2YUV_601FR] = { + 0, + { + 0x0099, 0x012d, 0x003a, + 0xffaa, 0xff56, 0x0100, + 0x0100, 0xff2a, 0xffd6 + }, + { 0x0, 0x0, 0x0,}, + { 0x0000, 0x0080, 0x0080,}, + { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, + { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, + }, + [MDSS_MDP_CSC_RGB2YUV_709L] = { + 0, + { + 0x005d, 0x013a, 0x0020, + 0xffcc, 0xff53, 0x00e1, + 0x00e1, 0xff34, 0xffeb + }, + { 0x0, 0x0, 0x0,}, + { 0x0010, 0x0080, 0x0080,}, + { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, + { 0x0010, 0x00eb, 0x0010, 0x00f0, 0x0010, 0x00f0,}, + }, + [MDSS_MDP_CSC_YUV2YUV] = { 0, { 0x0200, 0x0000, 0x0000, @@ -37,31 +109,7 @@ struct mdp_csc_cfg mdp_csc_convert[MDSS_MDP_MAX_CSC] = { { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, }, - [MDSS_MDP_CSC_YUV2RGB] = { - 0, - { - 0x0254, 0x0000, 0x0331, - 0x0254, 0xff37, 0xfe60, - 0x0254, 0x0409, 0x0000, - }, - { 0xfff0, 0xff80, 0xff80,}, - { 0x0, 0x0, 0x0,}, - { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, - { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, - }, - [MDSS_MDP_CSC_RGB2YUV] = { - 0, - { - 0x0083, 0x0102, 0x0032, - 0x1fb5, 0x1f6c, 0x00e1, - 0x00e1, 0x1f45, 0x1fdc - }, - { 0x0, 0x0, 0x0,}, - { 0x0010, 0x0080, 0x0080,}, - { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,}, - { 0x0010, 0x00eb, 0x0010, 0x00f0, 0x0010, 0x00f0,}, - }, - [MDSS_MDP_CSC_YUV2YUV] = { + [MDSS_MDP_CSC_RGB2RGB] = { 0, { 0x0200, 0x0000, 0x0000, @@ -812,7 +860,7 @@ static int pp_vig_pipe_setup(struct mdss_mdp_pipe *pipe, u32 *op) * CSC matrix */ mdss_mdp_csc_setup(MDSS_MDP_BLOCK_SSPP, pipe->num, - MDSS_MDP_CSC_YUV2RGB); + pp_vig_csc_pipe_val(pipe)); } /* Update CSC state only if tuning mode is enable */