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

Commit 3bed5c69 authored by Abhinav Kumar's avatar Abhinav Kumar
Browse files

drm/msm: refactor Y420CMDB block parsing logic



Y420CMDB block parsing is too complex and incorrect
in handling cases where more than one byte of bitmap
is present.

Fix this logic to make it more simple and capable to
handle all sucn cases.

Change-Id: I7aef80f588ec44def000c9f04e1da4c10020699d
Signed-off-by: default avatarAbhinav Kumar <abhinavk@codeaurora.org>
parent faccd749
Loading
Loading
Loading
Loading
+24 −18
Original line number Diff line number Diff line
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, 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
@@ -252,12 +252,13 @@ static void sde_edid_parse_Y420CMDB(
struct drm_connector *connector, struct sde_edid_ctrl *edid_ctrl,
const u8 *db)
{
	u32 offset = 0;
	u8 cmdb_len = 0;
	u8 svd_len = 0;
	const u8 *svd = NULL;
	u32 i = 0, j = 0;
	u32 i = 0;
	u32 video_format = 0;
	u32 num_cmdb_svd = 0;
	const u32 mult = 8;

	if (!edid_ctrl) {
		DEV_ERR("%s: edid_ctrl is NULL\n", __func__);
@@ -271,8 +272,8 @@ const u8 *db)
	SDE_EDID_DEBUG("%s +\n", __func__);
	cmdb_len = db[0] & 0x1f;

	/* Byte 3 to L+1 contain SVDs */
	offset += 2;
	if (cmdb_len < 1)
		return;

	svd = sde_edid_find_block(edid_ctrl->edid, VIDEO_DATA_BLOCK);

@@ -282,21 +283,26 @@ const u8 *db)
		++svd;
	}

	for (i = 0; i < svd_len; i++, j++) {
	if (cmdb_len == 1)
		num_cmdb_svd = svd_len;
	else {
		num_cmdb_svd = (cmdb_len - 1) * mult;
		if (num_cmdb_svd > svd_len)
			num_cmdb_svd = svd_len;
	}

	for (i = 0; i < num_cmdb_svd; i++) {
		video_format = *(svd + i) & 0x7F;
		if (cmdb_len == 1) {
			/* If cmdb_len is 1, it means all SVDs support YUV */
			sde_edid_set_y420_support(connector, video_format);
		} else if (db[offset] & (1 << j)) {
		/*
		 * If cmdb_len is 1, it means all SVDs support YUV
		 * Else, we check each byte of the cmdb bitmap bitwise
		 * and match those bits with the formats populated
		 * during the parsing of the Video Data Blocks.
		 * Refer to CTA 861-F section 7.5.11 YCBCR 4:2:0 Capability
		 * Map Data Block for more details on this.
		 */
		if (cmdb_len == 1 || (db[2 + i / mult] & (1 << (i % mult))))
			sde_edid_set_y420_support(connector, video_format);

			if (j & 0x80) {
				j = j/8;
				offset++;
				if (offset >= cmdb_len)
					break;
			}
		}
	}

	SDE_EDID_DEBUG("%s -\n", __func__);