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

Commit 5a25914d authored by RAJAT GUPTA's avatar RAJAT GUPTA Committed by Gerrit - the friendly Code Review server
Browse files

disp: msm: dp: add session check for audio register programming



Add a check to ensure that audio registers are programmed only
when the DP timing engine (audio session) is enabled. This will
reduce the likelihood of un-clocked register access for audio
related operations.

Change-Id: I6fe59cf53dc721b5470ad4cf7d84e8606800a246
Signed-off-by: default avatarRAJAT GUPTA <rajatgu@codeaurora.org>
parent 3cdd49af
Loading
Loading
Loading
Loading
+21 −7
Original line number Diff line number Diff line
/*
 * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 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
@@ -31,7 +31,7 @@ struct dp_audio_private {
	struct dp_panel *panel;

	bool ack_enabled;
	bool session_on;
	atomic_t session_on;
	bool engine_on;

	u32 channels;
@@ -302,6 +302,11 @@ static void dp_audio_isrc_sdp(struct dp_audio_private *audio)

static void dp_audio_setup_sdp(struct dp_audio_private *audio)
{
	if (!atomic_read(&audio->session_on)) {
		pr_warn("session inactive\n");
		return;
	}

	/* always program stream 0 first before actual stream cfg */
	audio->catalog->stream_id = DP_STREAM_0;
	audio->catalog->config_sdp(audio->catalog);
@@ -323,6 +328,11 @@ static void dp_audio_setup_acr(struct dp_audio_private *audio)
	u32 select = 0;
	struct dp_catalog_audio *catalog = audio->catalog;

	if (!atomic_read(&audio->session_on)) {
		pr_warn("session inactive\n");
		return;
	}

	switch (audio->dp_audio.bw_code) {
	case DP_LINK_BW_1_62:
		select = 0;
@@ -350,10 +360,14 @@ static void dp_audio_enable(struct dp_audio_private *audio, bool enable)
{
	struct dp_catalog_audio *catalog = audio->catalog;

	audio->engine_on = enable;
	if (!atomic_read(&audio->session_on)) {
		pr_warn("session inactive. enable=%d\n", enable);
		return;
	}

	catalog->data = enable;
	catalog->enable(catalog);

	audio->engine_on = enable;
}

static struct dp_audio_private *dp_audio_get_data(struct platform_device *pdev)
@@ -453,7 +467,7 @@ static int dp_audio_get_cable_status(struct platform_device *pdev, u32 vote)
		goto end;
	}

	return audio->session_on;
	return atomic_read(&audio->session_on);
end:
	return rc;
}
@@ -715,7 +729,7 @@ static int dp_audio_on(struct dp_audio *dp_audio)

	ext = &audio->ext_audio_data;

	audio->session_on = true;
	atomic_set(&audio->session_on, 1);

	rc = dp_audio_config(audio, EXT_DISPLAY_CABLE_CONNECT);
	if (rc)
@@ -757,7 +771,7 @@ static int dp_audio_off(struct dp_audio *dp_audio)
end:
	dp_audio_config(audio, EXT_DISPLAY_CABLE_DISCONNECT);

	audio->session_on = false;
	atomic_set(&audio->session_on, 0);
	audio->engine_on  = false;

	dp_audio_deregister_ext_disp(audio);