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

Commit fc6d1fe6 authored by Santosh Mardi's avatar Santosh Mardi Committed by Aviral Gupta
Browse files

ASoC: msm: qdsp6v2: update platform driver for new SSR design.



Update PCM platform driver to handle the reset events during
SSR and also unblock the write wait according to
the new SSR design.

CRs-Fixed: 661491
Change-Id: Id0b4950ffc0eb130dbfdce36375629a683752044
Signed-off-by: default avatarSantosh Mardi <gsantosh@codeaurora.org>
parent bedce767
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <sound/initval.h>
#include <sound/control.h>
#include <sound/q6audio-v2.h>
#include <sound/timer.h>
#include <asm/dma.h>
#include <linux/dma-mapping.h>
#include <linux/msm_audio_ion.h>
@@ -244,6 +245,17 @@ static void event_handler(uint32_t opcode,
		}
	}
	break;
	case RESET_EVENTS:
		pr_debug("%s RESET_EVENTS\n", __func__);
		prtd->pcm_irq_pos += prtd->pcm_count;
		atomic_inc(&prtd->out_count);
		prtd->reset_event = true;
		if (atomic_read(&prtd->start))
			snd_pcm_period_elapsed(substream);
		wake_up(&the_locks.eos_wait);
		wake_up(&the_locks.write_wait);
		wake_up(&the_locks.read_wait);
		break;
	default:
		pr_debug("Not Supported Event opcode[0x%x]\n", opcode);
		break;
@@ -524,6 +536,7 @@ static int msm_pcm_open(struct snd_pcm_substream *substream)

	prtd->dsp_cnt = 0;
	prtd->set_channel_map = false;
	prtd->reset_event = false;
	runtime->private_data = prtd;

	return 0;
@@ -546,6 +559,12 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
	fbytes = frames_to_bytes(runtime, frames);
	pr_debug("%s: prtd->out_count = %d\n",
				__func__, atomic_read(&prtd->out_count));

	if (prtd->reset_event) {
		pr_err("%s: In SSR return ENETRESET before wait\n", __func__);
		return -ENETRESET;
	}

	ret = wait_event_timeout(the_locks.write_wait,
			(atomic_read(&prtd->out_count)), 5 * HZ);
	if (!ret) {
@@ -553,6 +572,11 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
		goto fail;
	}

	if (prtd->reset_event) {
		pr_err("%s: In SSR return ENETRESET after wait\n", __func__);
		return -ENETRESET;
	}

	if (!atomic_read(&prtd->out_count)) {
		pr_err("%s: pcm stopped out_count 0\n", __func__);
		return 0;
@@ -658,12 +682,20 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
	pr_debug("hw_ptr %d\n", (int)runtime->status->hw_ptr);
	pr_debug("avail_min %d\n", (int)runtime->control->avail_min);

	if (prtd->reset_event) {
		pr_err("%s: In SSR return ENETRESET before wait\n", __func__);
		return -ENETRESET;
	}
	ret = wait_event_timeout(the_locks.read_wait,
			(atomic_read(&prtd->in_count)), 5 * HZ);
	if (!ret) {
		pr_debug("%s: wait_event_timeout failed\n", __func__);
		goto fail;
	}
	if (prtd->reset_event) {
		pr_err("%s: In SSR return ENETRESET after wait\n", __func__);
		return -ENETRESET;
	}
	if (!atomic_read(&prtd->in_count)) {
		pr_debug("%s: pcm stopped in_count 0\n", __func__);
		return 0;
+3 −0
Original line number Diff line number Diff line
@@ -1385,6 +1385,9 @@ static int32_t q6asm_callback(struct apr_client_data *data, void *priv)
				ac->cb(data->opcode, data->token,
					(uint32_t *)data->payload, ac->priv);
		apr_reset(ac->apr);
		if (ac->cb)
			ac->cb(data->opcode, data->token,
				data->payload, ac->priv);
		ac->apr = NULL;
		return 0;
	}
+8 −1
Original line number Diff line number Diff line
@@ -33,6 +33,13 @@ struct meta_info_t {
	uint8_t *nBuffer;
};

/*
 * AVS bring up in the modem is optimitized for the new
 * Sub System Restart design and 100 milliseconds timeout
 * is sufficient to make sure the Q6 will be ready.
 */
#define Q6_READY_TIMEOUT_MS 100

struct q6core_str {
	struct apr_svc *core_handle_q;
	wait_queue_head_t bus_bw_req_wait;
@@ -405,7 +412,7 @@ bool q6core_is_adsp_ready(void)

	rc = wait_event_timeout(q6core_lcl.bus_bw_req_wait,
				(q6core_lcl.bus_bw_resp_received == 1),
				msecs_to_jiffies(TIMEOUT_MS));
				msecs_to_jiffies(Q6_READY_TIMEOUT_MS));
	if (rc > 0 && q6core_lcl.bus_bw_resp_received) {
		/* ensure to read updated param by callback thread */
		rmb();