Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a20c3443 authored by Narender Ankam's avatar Narender Ankam
Browse files

msm: mdss: mdp: configure CSC_10 to set correct quantization range



For external HDMI display, as per CEA-861 spec, any CE video format
shall be encoded either in RGB or YCbCr using Limited Range levels.
And any IT video format shall be encoded in RGB using Full Range
levels.
Add 8bit and 10bit CSC config parameters for missing YCbCr_709_FR and
RGB_L colorspaces and use MDP_CDM_0 module to set RGB or YCbCr
quantization range levels for a CE or IT video format accordingly.

Change-Id: Icecfdf0d1d49e17672df2360933d33a48d485892
Signed-off-by: default avatarNarender Ankam <nankam@codeaurora.org>
parent 0313ebc7
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -271,10 +271,12 @@ enum mdss_mdp_csc_type {
	MDSS_MDP_CSC_RGB2YUV_601L,
	MDSS_MDP_CSC_RGB2YUV_601FR,
	MDSS_MDP_CSC_RGB2YUV_709L,
	MDSS_MDP_CSC_RGB2YUV_709FR,
	MDSS_MDP_CSC_RGB2YUV_2020L,
	MDSS_MDP_CSC_RGB2YUV_2020FR,
	MDSS_MDP_CSC_YUV2YUV,
	MDSS_MDP_CSC_RGB2RGB,
	MDSS_MDP_CSC_RGB2RGB_L,
	MDSS_MDP_MAX_CSC
};

+16 −3
Original line number Diff line number Diff line
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2017, 2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -116,6 +116,7 @@ struct mdss_mdp_cdm *mdss_mdp_cdm_init(struct mdss_mdp_ctl *ctl, u32 intf_type)

	cdm->out_intf = intf_type;
	cdm->is_bypassed = true;
	cdm->is_only_clamped = false;
	memset(&cdm->setup, 0x0, sizeof(struct mdp_cdm_cfg));

	return cdm;
@@ -137,11 +138,20 @@ static int mdss_mdp_cdm_csc_setup(struct mdss_mdp_cdm *cdm,

	if ((data->csc_type == MDSS_MDP_CSC_RGB2YUV_601L) ||
		(data->csc_type == MDSS_MDP_CSC_RGB2YUV_601FR) ||
		(data->csc_type == MDSS_MDP_CSC_RGB2YUV_709L)) {
		(data->csc_type == MDSS_MDP_CSC_RGB2YUV_709L) ||
		(data->csc_type == MDSS_MDP_CSC_RGB2YUV_709FR)) {
		op_mode |= BIT(2);  /* DST_DATA_FORMAT = YUV */
		op_mode &= ~BIT(1); /* SRC_DATA_FORMAT = RGB */
		op_mode |= BIT(0);  /* EN = 1 */
		cdm->is_bypassed = false;
	} else if ((cdm->out_intf == MDP_CDM_CDWN_OUTPUT_HDMI) &&
			((data->csc_type == MDSS_MDP_CSC_RGB2RGB_L) ||
			(data->csc_type == MDSS_MDP_CSC_RGB2RGB))) {
		op_mode &= ~BIT(2); /* DST_DATA_FORMAT = RGB */
		op_mode &= ~BIT(1); /* SRC_DATA_FORMAT = RGB */
		op_mode |= BIT(0);  /* EN = 1 */
		cdm->is_bypassed = false;
		cdm->is_only_clamped = true;
	} else {
		op_mode = 0;
		cdm->is_bypassed = true;
@@ -299,8 +309,11 @@ static int mdss_mdp_cdm_out_packer_setup(struct mdss_mdp_cdm *cdm,
		}
		opmode &= ~0x6;
		opmode |= (fmt->chroma_sample << 1);
		if (!cdm->is_bypassed)
		if (!cdm->is_bypassed) {
			cdm_enable |= BIT(19);
			if (cdm->is_only_clamped)
				opmode = 0;
		}

	} else {
		/* Disable HDMI pacler for WB */
+2 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014,2016, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014,2016, 2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -60,6 +60,7 @@ struct mdss_mdp_cdm {
	bool is_bypassed;
	struct mdp_cdm_cfg setup;
	struct completion free_comp;
	bool is_only_clamped;
};

struct mdss_mdp_cdm *mdss_mdp_cdm_init(struct mdss_mdp_ctl *ctl,
+25 −6
Original line number Diff line number Diff line
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1955,10 +1955,24 @@ static int mdss_mdp_video_cdm_setup(struct mdss_mdp_cdm *cdm,
{
	struct mdp_cdm_cfg setup;

	if (fmt->is_yuv)
	if (fmt->is_yuv) {
		if (pinfo->is_ce_mode) {
			if (pinfo->yres < 720)
				setup.csc_type = MDSS_MDP_CSC_RGB2YUV_601L;
			else
				setup.csc_type = MDSS_MDP_CSC_RGB2YUV_709L;
		} else {
			if (pinfo->yres < 720)
				setup.csc_type = MDSS_MDP_CSC_RGB2YUV_601FR;
			else
				setup.csc_type = MDSS_MDP_CSC_RGB2YUV_709FR;
		}
	} else {
		if (pinfo->is_ce_mode)
			setup.csc_type = MDSS_MDP_CSC_RGB2RGB_L;
		else
			setup.csc_type = MDSS_MDP_CSC_RGB2RGB;
	}

	switch (fmt->chroma_sample) {
	case MDSS_MDP_CHROMA_RGB:
@@ -2120,6 +2134,7 @@ static int mdss_mdp_video_ctx_setup(struct mdss_mdp_ctl *ctl,
	}

	if (mdss_mdp_is_cdm_supported(mdata, ctl->intf_type, 0)) {
		bool needs_qr_conversion = false;

		fmt = mdss_mdp_get_format_params(pinfo->out_format);
		if (!fmt) {
@@ -2127,7 +2142,11 @@ static int mdss_mdp_video_ctx_setup(struct mdss_mdp_ctl *ctl,
			       pinfo->out_format);
			return -EINVAL;
		}
		if (fmt->is_yuv) {

		if (ctl->intf_type == MDSS_INTF_HDMI && pinfo->is_ce_mode)
			needs_qr_conversion = true;

		if (fmt->is_yuv || needs_qr_conversion) {
			ctl->cdm =
			mdss_mdp_cdm_init(ctl, MDP_CDM_CDWN_OUTPUT_HDMI);
			if (!IS_ERR_OR_NULL(ctl->cdm)) {
+49 −1
Original line number Diff line number Diff line
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -120,6 +120,18 @@ struct mdp_csc_cfg mdp_csc_8bit_convert[MDSS_MDP_MAX_CSC] = {
		{ 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,},
		{ 0x0010, 0x00eb, 0x0010, 0x00f0, 0x0010, 0x00f0,},
	},
	[MDSS_MDP_CSC_RGB2YUV_709FR] = {
		0,
		{
			0x006d, 0x016e, 0x0025,
			0xffc5, 0xff3b, 0x0100,
			0x0100, 0xff17, 0xffe9
		},
		{ 0x0, 0x0, 0x0,},
		{ 0x0, 0x0080, 0x0080,},
		{ 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,},
		{ 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,},
	},
	[MDSS_MDP_CSC_RGB2YUV_2020L] = {
		0,
		{
@@ -168,6 +180,18 @@ struct mdp_csc_cfg mdp_csc_8bit_convert[MDSS_MDP_MAX_CSC] = {
		{ 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,},
		{ 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,},
	},
	[MDSS_MDP_CSC_RGB2RGB_L] = {
		0,
		{
			0x01b7, 0x0000, 0x0000,
			0x0000, 0x01b7, 0x0000,
			0x0000, 0x0000, 0x01b7,
		},
		{ 0x0, 0x0, 0x0,},
		{ 0x10, 0x10, 0x10,},
		{ 0x0, 0xff, 0x0, 0xff, 0x0, 0xff,},
		{ 0x10, 0xeb, 0x10, 0xeb, 0x10, 0xeb,},
	},
};

struct mdp_csc_cfg mdp_csc_10bit_convert[MDSS_MDP_MAX_CSC] = {
@@ -267,6 +291,18 @@ struct mdp_csc_cfg mdp_csc_10bit_convert[MDSS_MDP_MAX_CSC] = {
		{ 0x0, 0x3ff, 0x0, 0x3ff, 0x0, 0x3ff,},
		{ 0x0040, 0x03ac, 0x0040, 0x03c0, 0x0040, 0x03c0,},
	},
	[MDSS_MDP_CSC_RGB2YUV_709FR] = {
		0,
		{
			0x006d, 0x016e, 0x0025,
			0xffc5, 0xff3b, 0x0100,
			0x0100, 0xff17, 0xffe9
		},
		{ 0x0, 0x0, 0x0,},
		{ 0x0, 0x0200, 0x0200,},
		{ 0x0, 0x3ff, 0x0, 0x3ff, 0x0, 0x3ff,},
		{ 0x0, 0x3ff, 0x0, 0x3ff, 0x0, 0x3ff,},
	},
	[MDSS_MDP_CSC_RGB2YUV_2020L] = {
		0,
		{
@@ -315,6 +351,18 @@ struct mdp_csc_cfg mdp_csc_10bit_convert[MDSS_MDP_MAX_CSC] = {
		{ 0x0, 0x3ff, 0x0, 0x3ff, 0x0, 0x3ff,},
		{ 0x0, 0x3ff, 0x0, 0x3ff, 0x0, 0x3ff,},
	},
	[MDSS_MDP_CSC_RGB2RGB_L] = {
		0,
		{
			0x01b7, 0x0000, 0x0000,
			0x0000, 0x01b7, 0x0000,
			0x0000, 0x0000, 0x01b7,
		},
		{ 0x0, 0x0, 0x0,},
		{ 0x40, 0x40, 0x40,},
		{ 0x0, 0x3ff, 0x0, 0x3ff, 0x0, 0x3ff,},
		{ 0x40, 0x3ac, 0x40, 0x3ac, 0x40, 0x3ac,},
	},
};

static struct mdss_mdp_format_params dest_scaler_fmt = {