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

Commit c2dfeec8 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: mdss: hdmi: edid: fix proper adb size"

parents 216ade0b 52ace91b
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
 * descriptors with each SAD being 3 bytes long.
 * Thus, the maximum length of the audio data block would be 30 bytes
 */
#define MAX_NUMBER_ADB                  5
#define MAX_AUDIO_DATA_BLOCK_SIZE	30
#define MAX_SPKR_ALLOC_DATA_BLOCK_SIZE	3

@@ -79,7 +80,7 @@ struct hdmi_edid_ctrl {
	u16 audio_latency;
	u16 video_latency;
	u32 present_3d;
	u8 audio_data_block[MAX_AUDIO_DATA_BLOCK_SIZE];
	u8 audio_data_block[MAX_NUMBER_ADB * MAX_AUDIO_DATA_BLOCK_SIZE];
	int adb_size;
	u8 spkr_alloc_data_block[MAX_SPKR_ALLOC_DATA_BLOCK_SIZE];
	int sadb_size;
@@ -593,7 +594,8 @@ static void hdmi_edid_extract_3d_present(struct hdmi_edid_ctrl *edid_ctrl,
static void hdmi_edid_extract_audio_data_blocks(
	struct hdmi_edid_ctrl *edid_ctrl, const u8 *in_buf)
{
	u8 len;
	u8 len = 0;
	u8 adb_max = 0;
	const u8 *adb = NULL;
	u32 offset = DBC_START_OFFSET;

@@ -604,16 +606,24 @@ static void hdmi_edid_extract_audio_data_blocks(

	edid_ctrl->adb_size = 0;

	memset(edid_ctrl->audio_data_block, 0,
		sizeof(edid_ctrl->audio_data_block));

	do {
		len = 0;
		adb = hdmi_edid_find_block(in_buf, offset, AUDIO_DATA_BLOCK,
			&len);
		if ((adb == NULL) || (len > MAX_AUDIO_DATA_BLOCK_SIZE)) {
			if (!edid_ctrl->adb_size)

		if ((adb == NULL) || (len > MAX_AUDIO_DATA_BLOCK_SIZE ||
			adb_max >= MAX_NUMBER_ADB)) {
			if (!edid_ctrl->adb_size) {
				DEV_DBG("%s: No/Invalid Audio Data Block\n",
					__func__);
			else
				return;
			} else {
				DEV_DBG("%s: No more valid ADB found\n",
					__func__);
			}

			continue;
		}
@@ -623,6 +633,7 @@ static void hdmi_edid_extract_audio_data_blocks(
		offset = (adb - in_buf) + 1 + len;

		edid_ctrl->adb_size += len;
		adb_max++;
	} while (adb);

} /* hdmi_edid_extract_audio_data_blocks */