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

Commit 10996c18 authored by Abhinav Kumar's avatar Abhinav Kumar Committed by Gerrit - the friendly Code Review server
Browse files

disp: msm: add support for parsing VDC-m DTSI parameters



Add support for parsing VDC-m DTSI parameters and also
perform basic validation checks on those.

Change-Id: I4b13cf04b1500c3c801c227658cb787bdad6174f
Signed-off-by: default avatarAbhinav Kumar <abhinavk@codeaurora.org>
parent 748372a2
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
 */

#ifndef _DSI_DEFS_H_
@@ -402,7 +402,9 @@ struct dsi_panel_cmd_set {
 *                    panels in microseconds.
 * @dsi_transfer_time_us:   Specifies dsi transfer time for command mode.
 * @dsc_enabled:      DSC compression enabled.
 * @vdc_enabled:      VDC compression enabled.
 * @dsc:              DSC compression configuration.
 * @vdc:              VDC compression configuration.
 * @roi_caps:         Panel ROI capabilities.
 */
struct dsi_mode_info {
@@ -425,7 +427,9 @@ struct dsi_mode_info {
	u32 mdp_transfer_time_us;
	u32 dsi_transfer_time_us;
	bool dsc_enabled;
	bool vdc_enabled;
	struct msm_display_dsc_info *dsc;
	struct msm_display_vdc_info *vdc;
	struct msm_roi_caps roi_caps;
};

@@ -583,7 +587,9 @@ struct dsi_host_config {
 * @min_dsi_clk_hz:       Min dsi clk per lane to transfer frame in vsync time.
 * @topology:             Topology selected for the panel
 * @dsc:                  DSC compression info
 * @vdc:                  VDC compression info
 * @dsc_enabled:          DSC compression enabled
 * @vdc_enabled:          VDC compression enabled
 * @roi_caps:		  Panel ROI capabilities
 */
struct dsi_display_mode_priv_info {
@@ -602,7 +608,9 @@ struct dsi_display_mode_priv_info {

	struct msm_display_topology topology;
	struct msm_display_dsc_info dsc;
	struct msm_display_vdc_info vdc;
	bool dsc_enabled;
	bool vdc_enabled;
	struct msm_roi_caps roi_caps;
};

+191 −0
Original line number Diff line number Diff line
@@ -2317,6 +2317,26 @@ static int dsi_panel_parse_dsc_params(struct dsi_display_mode *mode,
	}
	priv_info->dsc.config.bits_per_pixel = data << 4;

	rc = utils->read_u32(utils->data, "qcom,src-chroma-format",
			&data);
	if (rc) {
		DSI_DEBUG("failed to parse qcom,src-chroma-format\n");
		rc = 0;
		data = MSM_CHROMA_444;
	}

	priv_info->dsc.chroma_format = data;

	rc = utils->read_u32(utils->data, "qcom,src-color-space",
			&data);
	if (rc) {
		DSI_DEBUG("failed to parse qcom,src-color-space\n");
		rc = 0;
		data = MSM_RGB;
	}

	priv_info->dsc.source_color_space = data;

	priv_info->dsc.config.block_pred_enable = utils->read_bool(utils->data,
		"qcom,mdss-dsc-block-prediction-enable");

@@ -2345,6 +2365,171 @@ static int dsi_panel_parse_dsc_params(struct dsi_display_mode *mode,
	return rc;
}

static int dsi_panel_parse_vdc_params(struct dsi_display_mode *mode,
				struct dsi_parser_utils *utils)
{
	u32 data;
	int rc = -EINVAL;
	const char *compression;
	struct dsi_display_mode_priv_info *priv_info;

	if (!mode || !mode->priv_info)
		return -EINVAL;

	priv_info = mode->priv_info;

	priv_info->vdc_enabled = false;
	compression = utils->get_property(utils->data,
			"qcom,compression-mode", NULL);
	if (compression && !strcmp(compression, "vdc"))
		priv_info->vdc_enabled = true;

	if (!priv_info->vdc_enabled) {
		DSI_DEBUG("vdc compression is not enabled for the mode\n");
		return 0;
	}

	rc = utils->read_u32(utils->data, "qcom,vdc-version", &data);
	if (rc) {
		priv_info->vdc.version_major = 0x1;
		priv_info->vdc.version_minor = 0x1;
		priv_info->vdc.version_release = 0x0;
		rc = 0;
	} else {
		/* BITS[0..3] provides minor version and BITS[4..7] provide
		 * major version information
		 */
		priv_info->vdc.version_major = (data >> 4) & 0x0F;
		priv_info->vdc.version_minor = data & 0x0F;
		if ((priv_info->vdc.version_major != 0x1) &&
				((priv_info->vdc.version_minor
				  != 0x1))) {
			DSI_ERR("%s:unsupported major:%d minor:%d version\n",
					__func__,
					priv_info->vdc.version_major,
					priv_info->vdc.version_minor
					);
			rc = -EINVAL;
			goto error;
		}
	}

	rc = utils->read_u32(utils->data, "qcom,vdc-version-release", &data);
	if (rc) {
		priv_info->vdc.version_release = 0x0;
		rc = 0;
	} else {
		priv_info->vdc.version_release = data & 0xff;
		/* only one release version is supported */
		if (priv_info->vdc.version_release != 0x0) {
			DSI_ERR("unsupported vdc release version %d\n",
					priv_info->vdc.version_release);
			rc = -EINVAL;
			goto error;
		}
	}

	DSI_INFO("vdc major: 0x%x minor : 0x%x release : 0x%x\n",
			priv_info->vdc.version_major,
			priv_info->vdc.version_minor,
			priv_info->vdc.version_release);

	rc = utils->read_u32(utils->data, "qcom,vdc-slice-height", &data);
	if (rc) {
		DSI_ERR("failed to parse qcom,vdc-slice-height\n");
		goto error;
	}
	priv_info->vdc.slice_height = data;

	/* slice height should be atleast 16 lines */
	if (priv_info->vdc.slice_height < 16) {
		DSI_ERR("invalid slice height %d\n",
			priv_info->vdc.slice_height);
		rc = -EINVAL;
		goto error;
	}

	rc = utils->read_u32(utils->data, "qcom,vdc-slice-width", &data);
	if (rc) {
		DSI_ERR("failed to parse qcom,vdc-slice-width\n");
		goto error;
	}

	priv_info->vdc.slice_width = data;

	/*
	 * slide-width should be multiple of 8
	 * slice-width should be atlease 64 pixels
	 */
	if ((priv_info->vdc.slice_width & 7) ||
		(priv_info->vdc.slice_width < 64)) {
		DSI_ERR("invalid slice width:%d\n", priv_info->vdc.slice_width);
		rc = -EINVAL;
		goto error;
	}

	rc = utils->read_u32(utils->data, "qcom,vdc-slice-per-pkt", &data);
	if (rc) {
		DSI_ERR("failed to parse qcom,vdc-slice-per-pkt\n");
		goto error;
	} else if (!data || (data > 2)) {
		DSI_ERR("invalid vdc slice-per-pkt:%d\n", data);
		rc = -EINVAL;
		goto error;
	}
	priv_info->vdc.slice_per_pkt = data;

	priv_info->vdc.frame_width = mode->timing.h_active;
	priv_info->vdc.frame_height = mode->timing.v_active;

	rc = utils->read_u32(utils->data, "qcom,vdc-bit-per-component",
		&data);
	if (rc) {
		DSI_ERR("failed to parse qcom,vdc-bit-per-component\n");
		goto error;
	}
	priv_info->vdc.bits_per_component = data;

	rc = utils->read_u32(utils->data, "qcom,mdss-pps-delay-ms", &data);
	if (rc) {
		DSI_DEBUG("pps-delay-ms not specified, defaulting to 0\n");
		data = 0;
	}
	priv_info->vdc.pps_delay_ms = data;

	rc = utils->read_u32(utils->data, "qcom,vdc-bit-per-pixel",
			&data);
	if (rc) {
		DSI_ERR("failed to parse qcom,vdc-bit-per-pixel\n");
		goto error;
	}
	priv_info->vdc.bits_per_pixel = data << 4;

	rc = utils->read_u32(utils->data, "qcom,src-chroma-format",
			&data);
	if (rc) {
		DSI_DEBUG("failed to parse qcom,src-chroma-format\n");
		rc = 0;
		data = MSM_CHROMA_444;
	}
	priv_info->vdc.chroma_format = data;

	rc = utils->read_u32(utils->data, "qcom,src-color-space",
			&data);
	if (rc) {
		DSI_DEBUG("failed to parse qcom,src-color-space\n");
		rc = 0;
		data = MSM_RGB;
	}
	priv_info->vdc.source_color_space = data;

	mode->timing.vdc_enabled = true;
	mode->timing.vdc = &priv_info->vdc;

error:
	return rc;
}

static int dsi_panel_parse_hdr_config(struct dsi_panel *panel)
{
	int rc = 0;
@@ -3423,6 +3608,12 @@ int dsi_panel_get_mode(struct dsi_panel *panel,
			goto parse_fail;
		}

		rc = dsi_panel_parse_vdc_params(mode, utils);
		if (rc) {
			DSI_ERR("failed to parse vdc params, rc=%d\n", rc);
			goto parse_fail;
		}

		rc = dsi_panel_parse_topology(prv_info, utils,
				topology_override);
		if (rc) {
+47 −0
Original line number Diff line number Diff line
@@ -72,6 +72,13 @@ struct msm_gem_vma;
#define MAX_BRIDGES    16
#define MAX_CONNECTORS 16

#define MSM_RGB 0x0
#define MSM_YUV 0x1

#define MSM_CHROMA_444 0x0
#define MSM_CHROMA_422 0x1
#define MSM_CHROMA_420 0x2

#define TEARDOWN_DEADLOCK_RETRY_MAX 5

struct msm_file_private {
@@ -322,6 +329,8 @@ struct msm_roi_caps {
 * @pclk_per_line:           Compressed width.
 * @slice_last_group_size:   Size of last group in pixels.
 * @slice_per_pkt:           Number of slices per packet.
 * @source_color_space:      Source color space of DSC encoder
 * @chroma_format:           Chroma_format of DSC encoder.
 * @det_thresh_flatness:     Flatness threshold.
 * @extra_width:             Extra width required in timing calculations.
 * @pps_delay_ms:            Post PPS command delay in milliseconds.
@@ -338,12 +347,50 @@ struct msm_display_dsc_info {
	int pclk_per_line;
	int slice_last_group_size;
	int slice_per_pkt;
	int source_color_space;
	int chroma_format;
	int det_thresh_flatness;
	u32 extra_width;
	u32 pps_delay_ms;
};


/**
 * struct msm_display_vdc_info - defines vdc configuration
 * @version_major:           major version number of VDC encoder.
 * @version_minor:           minor version number of VDC encoder.
 * @source_color_space:      source color space of VDC encoder
 * @chroma_format:           chroma_format of VDC encoder.
 * @slice_height:            slice height configuration of encoder.
 * @slice_width:             slice width configuration of encoder.
 * @bytes_in_slice:          number of bytes per slice .
 * @slice_per_pkt:           number of slices per packet.
 * @bits_per_component:      number of bits per component.
 * @bits_per_pixel:          number of bits per pixel.
 * @frame_width:             frame width configuration of encoder
 * @frame_height:            frame height configuration of encoder
 * @pps_delay_ms:            Post PPS command delay in milliseconds.
 * @version_release:		 release version of VDC encoder.
 */
struct msm_display_vdc_info {
	u8 version_major;
	u8 version_minor;
	u8 chroma_format;
	u8 source_color_space;

	int slice_height;
	int slice_width;
	int bytes_in_slice;
	int slice_per_pkt;
	int bits_per_component;
	int bits_per_pixel;
	int frame_width;
	int frame_height;

	u32 pps_delay_ms;
	u32 version_release;
};

/**
 * Bits/pixel target >> 4  (removing the fractional bits)
 * returns the integer bpp value from the drm_dsc_config struct