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

Commit 2fc72b50 authored by Ashish Jain's avatar Ashish Jain
Browse files

ASoC: bg: Fix incorrect num_session update



For SVA_usecase codec_prepare is not invoked which results in a
incorrect count of num_sessions. Update num_session in _bg_codec_start
instead, this ensures correct count of num_session.

Change-Id: I4ee5b15f969c02d3943b282203f569253a0b6499
Signed-off-by: default avatarAshish Jain <ashishj@codeaurora.org>
parent eff4eda6
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -326,6 +326,20 @@ static int _bg_codec_start(struct bg_cdc_priv *bg_cdc, int dai_id)
		pr_err("%s:Invalid dai id %d", __func__, dai_id);
		return -EINVAL;
	}

	mutex_lock(&bg_cdc->bg_cdc_lock);
	if (bg_cdc->num_sessions == 0) {
		/* set regulator to normal mode */
		ret = regulator_set_optimum_mode(bg_cdc->spkr_vreg, 100000);
		if (ret < 0) {
			pr_err("Fail to set spkr_vreg mode%d\n", ret);
			mutex_unlock(&bg_cdc->bg_cdc_lock);
			return ret;
		}
	}
	bg_cdc->num_sessions++;
	mutex_unlock(&bg_cdc->bg_cdc_lock);

	codec_start.route_to_bg = bg_cdc->src[dai_id];
	pr_debug("%s active_session %x route_to_bg %d\n",
		__func__, codec_start.active_session, codec_start.route_to_bg);
@@ -631,18 +645,6 @@ static int bg_cdc_prepare(struct snd_pcm_substream *substream,
		return -EINVAL;
	}

	mutex_lock(&bg_cdc->bg_cdc_lock);
	if (bg_cdc->num_sessions == 0) {
		/* set regulator to normal mode */
		ret = regulator_set_optimum_mode(bg_cdc->spkr_vreg, 100000);
		if (ret < 0) {
			pr_err("Fail to set spkr_vreg mode%d\n", ret);
			mutex_unlock(&bg_cdc->bg_cdc_lock);
			return ret;
		}
	}
	bg_cdc->num_sessions++;
	mutex_unlock(&bg_cdc->bg_cdc_lock);
	/* Send command to BG to start session */
	ret = _bg_codec_start(bg_cdc, dai->id);
	if (ret < 0)