All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerome Anand <jerome.anand@intel.com>
To: intel-gfx@lists.freedesktop.org, alsa-devel@alsa-project.org
Cc: tiwai@suse.de, pierre-louis.bossart@linux.intel.com,
	broonie@kernel.org, rakesh.a.ughreja@intel.com,
	jerome.anand@intel.com, ville.syrjala@linux.intel.com
Subject: [PATCH v4 5/5] ALSA: x86: hdmi: continue playback even when display resolution changes
Date: Sat, 21 Jan 2017 03:52:32 +0530	[thread overview]
Message-ID: <20170120222232.27791-6-jerome.anand@intel.com> (raw)
In-Reply-To: <20170120222232.27791-1-jerome.anand@intel.com>

When the display resolution changes, the drm disables the
display pipes due to which audio rendering stops. At this
time, we need to ensure the existing audio pointers and
buffers are cleared out so that the playback can restarted
once the display pipe is enabled with a different N/CTS values

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jerome Anand <jerome.anand@intel.com>
---
 sound/x86/intel_hdmi_audio.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index b69521a..f301554 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -43,6 +43,7 @@ static DEFINE_MUTEX(had_mutex);
 static int hdmi_card_index = SNDRV_DEFAULT_IDX1;
 static char *hdmi_card_id = SNDRV_DEFAULT_STR1;
 static struct snd_intelhad *had_data;
+static int underrun_count;
 
 module_param_named(index, hdmi_card_index, int, 0444);
 MODULE_PARM_DESC(index,
@@ -1052,6 +1053,7 @@ static int snd_intelhad_open(struct snd_pcm_substream *substream)
 	intelhaddata = snd_pcm_substream_chip(substream);
 	had_stream = intelhaddata->private_data;
 	runtime = substream->runtime;
+	underrun_count = 0;
 
 	pm_runtime_get(intelhaddata->dev);
 
@@ -1445,10 +1447,23 @@ static snd_pcm_uframes_t snd_intelhad_pcm_pointer(
 
 	buf_id = intelhaddata->curr_buf % 4;
 	had_read_register(AUD_BUF_A_LENGTH + (buf_id * HAD_REG_WIDTH), &t);
-	if (t == 0) {
-		pr_debug("discovered buffer done for buf %d\n", buf_id);
-		/* had_process_buffer_done(intelhaddata); */
+
+	if ((t == 0) || (t == ((u32)-1L))) {
+		underrun_count++;
+		pr_debug("discovered buffer done for buf %d, count = %d\n",
+			buf_id, underrun_count);
+
+		if (underrun_count > (HAD_MIN_PERIODS/2)) {
+			pr_debug("assume audio_codec_reset, underrun = %d - do xrun\n",
+				underrun_count);
+			underrun_count = 0;
+			return SNDRV_PCM_POS_XRUN;
+		}
+	} else {
+		/* Reset Counter */
+		underrun_count = 0;
 	}
+
 	t = intelhaddata->buf_info[buf_id].buf_size - t;
 
 	if (intelhaddata->stream_info.buffer_rendered)
-- 
2.9.3

  parent reply	other threads:[~2017-01-20 10:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20 22:22 [PATCH v4 0/5] Add support for Legacy HDMI audio drivers Jerome Anand
2017-01-20 11:54 ` ✗ Fi.CI.BAT: failure for Add support for Legacy HDMI audio drivers (rev5) Patchwork
2017-01-20 22:22 ` [PATCH v4 1/5] drm/i915: setup bridge for HDMI LPE audio driver Jerome Anand
2017-01-23 10:54   ` Jani Nikula
2017-01-24  8:21     ` Anand, Jerome
2017-01-20 22:22 ` [PATCH v4 2/5] drm/i915: Add support for audio driver notifications Jerome Anand
2017-01-23 10:57   ` Jani Nikula
2017-01-23 16:32     ` Pierre-Louis Bossart
2017-01-24  7:00       ` Jani Nikula
2017-01-24  8:42         ` Anand, Jerome
2017-01-20 22:22 ` [PATCH v4 3/5] ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T Jerome Anand
2017-01-20 22:22 ` [PATCH v4 4/5] ALSA: x86: hdmi: Add audio support for BYT and CHT Jerome Anand
2017-01-20 11:15   ` Takashi Iwai
2017-01-20 16:45     ` [alsa-devel] " Pierre-Louis Bossart
2017-01-20 19:09       ` Takashi Iwai
2017-01-20 22:22 ` Jerome Anand [this message]
2017-01-23 10:18 ` [PATCH v4 0/5] Add support for Legacy HDMI audio drivers Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170120222232.27791-6-jerome.anand@intel.com \
    --to=jerome.anand@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rakesh.a.ughreja@intel.com \
    --cc=tiwai@suse.de \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.