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

Commit b7e59246 authored by Jerry (Fangzhi) Zuo's avatar Jerry (Fangzhi) Zuo Committed by Alistair Delva
Browse files

ANDROID: drm: Add support for DP 1.4 Compliance edid corruption test



Unlike DP 1.2 edid corruption test, DP 1.4 requires to calculate
real CRC value of the last edid data block, and write it back.
Current edid CRC calculates routine adds the last CRC byte,
and check if non-zero.

This behavior is not accurate; actually, we need to return
the actual CRC value when corruption is detected.
This commit changes this issue by returning the calculated CRC,
and initiate the required sequence.

Change since v7
- Fix for CI.CHECKPATCH

Change since v6
- Add return check

Change since v5
- Obtain real CRC value before dumping bad edid

Change since v4
- Fix for CI.CHECKPATCH

Change since v3
- Fix a minor typo.

Change since v2
- Rewrite checksum computation routine to avoid duplicated code.
- Rename to avoid confusion.

Change since v1
- Have separate routine for returning real CRC.

Change-Id: I6a67007357e5176994f54c4f30c07f42a2d57bd7
Signed-off-by: default avatarJerry (Fangzhi) Zuo <Jerry.Zuo@amd.com>
Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
Reviewed-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
[abhinavk: resolved conflict with android-5.4's drm_dp_helper.h]
Bug: 139653858
Link: https://patchwork.kernel.org/patch/11375865/


Signed-off-by: default avatarAbhinav Kumar <abhinavk@codeaurora.org>
parent 4e5eb362
Loading
Loading
Loading
Loading
+59 −0
Original line number Diff line number Diff line
@@ -336,6 +336,65 @@ int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,
}
EXPORT_SYMBOL(drm_dp_dpcd_read_link_status);

/**
 * drm_dp_send_real_edid_checksum() - send back real edid checksum value
 * @aux: DisplayPort AUX channel
 * @real_edid_checksum: real edid checksum for the last block
 *
 * Returns:
 * True on success
 */
bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux,
				    u8 real_edid_checksum)
{
	u8 link_edid_read = 0, auto_test_req = 0, test_resp = 0;

	if (drm_dp_dpcd_read(aux, DP_DEVICE_SERVICE_IRQ_VECTOR,
			     &auto_test_req, 1) < 1) {
		DRM_ERROR("DPCD failed read at register 0x%x\n",
			  DP_DEVICE_SERVICE_IRQ_VECTOR);
		return false;
	}
	auto_test_req &= DP_AUTOMATED_TEST_REQUEST;

	if (drm_dp_dpcd_read(aux, DP_TEST_REQUEST, &link_edid_read, 1) < 1) {
		DRM_ERROR("DPCD failed read at register 0x%x\n",
			  DP_TEST_REQUEST);
		return false;
	}
	link_edid_read &= DP_TEST_LINK_EDID_READ;

	if (!auto_test_req || !link_edid_read) {
		DRM_DEBUG_KMS("Source DUT does not support TEST_EDID_READ\n");
		return false;
	}

	if (drm_dp_dpcd_write(aux, DP_DEVICE_SERVICE_IRQ_VECTOR,
			      &auto_test_req, 1) < 1) {
		DRM_ERROR("DPCD failed write at register 0x%x\n",
			  DP_DEVICE_SERVICE_IRQ_VECTOR);
		return false;
	}

	/* send back checksum for the last edid extension block data */
	if (drm_dp_dpcd_write(aux, DP_TEST_EDID_CHECKSUM,
			      &real_edid_checksum, 1) < 1) {
		DRM_ERROR("DPCD failed write at register 0x%x\n",
			  DP_TEST_EDID_CHECKSUM);
		return false;
	}

	test_resp |= DP_TEST_EDID_CHECKSUM_WRITE;
	if (drm_dp_dpcd_write(aux, DP_TEST_RESPONSE, &test_resp, 1) < 1) {
		DRM_ERROR("DPCD failed write at register 0x%x\n",
			  DP_TEST_RESPONSE);
		return false;
	}

	return true;
}
EXPORT_SYMBOL(drm_dp_send_real_edid_checksum);

/**
 * drm_dp_link_probe() - probe a DisplayPort link for capabilities
 * @aux: DisplayPort AUX channel
+20 −4
Original line number Diff line number Diff line
@@ -1358,11 +1358,22 @@ static int validate_displayid(u8 *displayid, int length, int idx);
static int drm_edid_block_checksum(const u8 *raw_edid)
{
	int i;
	u8 csum = 0;
	for (i = 0; i < EDID_LENGTH; i++)
	u8 csum = 0, crc = 0;

	for (i = 0; i < EDID_LENGTH - 1; i++)
		csum += raw_edid[i];

	return csum;
	crc = 0x100 - csum;

	return crc;
}

static bool drm_edid_block_checksum_diff(const u8 *raw_edid, u8 real_checksum)
{
	if (raw_edid[EDID_LENGTH - 1] != real_checksum)
		return true;
	else
		return false;
}

static bool drm_edid_is_zero(const u8 *in_edid, int length)
@@ -1420,7 +1431,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
	}

	csum = drm_edid_block_checksum(raw_edid);
	if (csum) {
	if (drm_edid_block_checksum_diff(raw_edid, csum)) {
		if (edid_corrupt)
			*edid_corrupt = true;

@@ -1561,6 +1572,11 @@ static void connector_bad_edid(struct drm_connector *connector,
			       u8 *edid, int num_blocks)
{
	int i;
	u8 num_of_ext = edid[0x7e];

	/* Calculate real checksum for the last edid extension block data */
	connector->real_edid_checksum =
		drm_edid_block_checksum(edid + num_of_ext * EDID_LENGTH);

	if (connector->bad_edid_counter++ && !(drm_debug & DRM_UT_KMS))
		return;
+6 −0
Original line number Diff line number Diff line
@@ -1401,6 +1401,12 @@ struct drm_connector {
	 * rev1.1 4.2.2.6
	 */
	bool edid_corrupt;
	/**
	 * @real_edid_checksum: real edid checksum for corrupted edid block.
	 * Required in Displayport 1.4 compliance testing
	 * rev1.1 4.2.2.6
	 */
	u8 real_edid_checksum;

	/** @debugfs_entry: debugfs directory for this connector */
	struct dentry *debugfs_entry;
+2 −0
Original line number Diff line number Diff line
@@ -1361,6 +1361,8 @@ static inline ssize_t drm_dp_dpcd_writeb(struct drm_dp_aux *aux,
int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,
				 u8 status[DP_LINK_STATUS_SIZE]);

bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux,
		u8 real_edid_checksum);
/*
 * DisplayPort link
 */