alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: alsa-devel@alsa-project.org, Jerome Anand <jerome.anand@intel.com>
Subject: Re: [PATCH 1/4] ALSA: x86: Don't pass SNDRV_PCM_INFO_BATCH flag
Date: Mon, 06 Feb 2017 20:01:40 +0100	[thread overview]
Message-ID: <s5htw87f8iz.wl-tiwai@suse.de> (raw)
In-Reply-To: <s5htw8agzhn.wl-tiwai@suse.de>

On Sat, 04 Feb 2017 08:57:08 +0100,
Takashi Iwai wrote:
> 
> > > In anyway, it'd be appreciated if you can test on your hardware.
> > > I could test only on a single machine.
> > I can test more but only in 10 days from now so if we could delay this
> > patch a bit it'd be better.
> 
> OK, I can postpone this change and keep BATCH and DOUBLE.

I've tested more intensively, and this seems working well, so far.
Hopefully the DMA FIFO or fetch timing doesn't play a big role.

BTW, with the combination of this and the latest my PCM rewrite patch,
a more interesting experiment can be done: extend to (a kind of)
no-period-wakeup mode.  Of course, it doesn't work like HD-audio, as
we can't the ring buffer persistently on LPE audio but have to refresh
the buffer descriptors.  But the refresh of BDs is also done at PCM
pointer callback, so it would work as is.  For supporting the case
period=1, though, another trick is needed: namely, we set up 4 BDs
pointing to the same address, so that it won't go out to underrun.

A totally untested patch is below.


thanks,

Takashi

---
diff --git a/sound/x86/intel_hdmi_audio.c b/sound/x86/intel_hdmi_audio.c
index 0bd77acb9689..be9cabc9f58b 100644
--- a/sound/x86/intel_hdmi_audio.c
+++ b/sound/x86/intel_hdmi_audio.c
@@ -133,7 +133,8 @@ static const struct channel_map_table map_tables[] = {
 static const struct snd_pcm_hardware had_pcm_hardware = {
 	.info =	(SNDRV_PCM_INFO_INTERLEAVED |
 		SNDRV_PCM_INFO_MMAP|
-		SNDRV_PCM_INFO_MMAP_VALID),
+		SNDRV_PCM_INFO_MMAP_VALID|
+		SNDRV_PCM_INFO_NO_PERIOD_WAKEUP),
 	.formats = (SNDRV_PCM_FMTBIT_S24 |
 		SNDRV_PCM_FMTBIT_U24),
 	.rates = SNDRV_PCM_RATE_32000 |
@@ -853,7 +854,9 @@ static void had_prog_bd(struct snd_pcm_substream *substream,
 	int ofs = intelhaddata->pcmbuf_filled * intelhaddata->period_bytes;
 	u32 addr = substream->runtime->dma_addr + ofs;
 
-	addr |= AUD_BUF_VALID | AUD_BUF_INTR_EN;
+	addr |= AUD_BUF_VALID;
+	if (!subsream->runtime->no_period_wakeup)
+		addr |= AUD_BUF_INTR_EN;
 	had_write_register(intelhaddata, AUD_BUF_ADDR(idx), addr);
 	had_write_register(intelhaddata, AUD_BUF_LEN(idx),
 			   intelhaddata->period_bytes);
@@ -881,7 +884,10 @@ static void had_init_ringbuf(struct snd_pcm_substream *substream,
 	int i, num_periods;
 
 	num_periods = runtime->periods;
-	intelhaddata->num_bds = min(num_periods, HAD_NUM_OF_RING_BUFS);
+	if (num_periods == 1)
+		intelhaddata->num_bds = HAD_NUM_OF_RING_BUFS;
+	else
+		intelhaddata->num_bds = min(num_periods, HAD_NUM_OF_RING_BUFS);
 	intelhaddata->period_bytes =
 		frames_to_bytes(runtime, runtime->period_size);
 	WARN_ON(intelhaddata->period_bytes & 0x3f);
@@ -891,7 +897,7 @@ static void had_init_ringbuf(struct snd_pcm_substream *substream,
 	intelhaddata->pcmbuf_filled = 0;
 
 	for (i = 0; i < HAD_NUM_OF_RING_BUFS; i++) {
-		if (i < num_periods)
+		if (i < num_periods || num_periods == 1)
 			had_prog_bd(substream, intelhaddata);
 		else /* invalidate the rest */
 			had_invalidate_bd(intelhaddata, i);
diff --git a/sound/x86/intel_hdmi_lpe_audio.h b/sound/x86/intel_hdmi_lpe_audio.h
index ca4212dca94e..3c2befa721a4 100644
--- a/sound/x86/intel_hdmi_lpe_audio.h
+++ b/sound/x86/intel_hdmi_lpe_audio.h
@@ -32,7 +32,7 @@
 #define HAD_MAX_BUFFER		((1024 * 1024 - 1) & ~0x3f)
 #define HAD_DEFAULT_BUFFER	(600 * 1024) /* default prealloc size */
 #define HAD_MAX_PERIODS		256	/* arbitrary, but should suffice */
-#define HAD_MIN_PERIODS		2
+#define HAD_MIN_PERIODS		1
 #define HAD_MAX_PERIOD_BYTES	((HAD_MAX_BUFFER / HAD_MIN_PERIODS) & ~0x3f)
 #define HAD_MIN_PERIOD_BYTES	1024	/* might be smaller */
 #define HAD_FIFO_SIZE		0 /* fifo not being used */

  reply	other threads:[~2017-02-06 19:01 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-03 16:43 [PATCH 0/4] Yet another patchset for LPE audio refactoring Takashi Iwai
2017-02-03 16:43 ` [PATCH 1/4] ALSA: x86: Don't pass SNDRV_PCM_INFO_BATCH flag Takashi Iwai
2017-02-03 19:39   ` Pierre-Louis Bossart
2017-02-03 20:13     ` Takashi Iwai
2017-02-03 23:13       ` Pierre-Louis Bossart
2017-02-04  7:57         ` Takashi Iwai
2017-02-06 19:01           ` Takashi Iwai [this message]
2017-02-06 21:27             ` Pierre-Louis Bossart
2017-02-06 21:51               ` Takashi Iwai
2017-02-03 16:43 ` [PATCH 2/4] ALSA: x86: Explicit specify 32bit DMA Takashi Iwai
2017-02-03 16:43 ` [PATCH 3/4] ALSA: x86: Don't check connection in lowlevel accessors Takashi Iwai
2017-02-03 16:44 ` [PATCH 4/4] ALSA: x86: Refactor PCM process engine Takashi Iwai
2017-02-03 19:47   ` Pierre-Louis Bossart
2017-02-03 20:11     ` Takashi Iwai
2017-02-03 23:22       ` Pierre-Louis Bossart
2017-02-04  7:51         ` Takashi Iwai
2017-02-06 11:22           ` Takashi Iwai
2017-02-06 15:46             ` Pierre-Louis Bossart
2017-02-06 15:54               ` Takashi Iwai
2017-02-06 16:00                 ` Pierre-Louis Bossart
2017-02-06 19:07 ` [PATCH 0/4] Yet another patchset for LPE audio refactoring Takashi Iwai
2017-02-06 21:16   ` Pierre-Louis Bossart
2017-02-06 21:45     ` Takashi Iwai
2017-02-06 23:56       ` Pierre-Louis Bossart
2017-02-07  1:22         ` Pierre-Louis Bossart
2017-02-07  6:39         ` 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=s5htw87f8iz.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=jerome.anand@intel.com \
    --cc=pierre-louis.bossart@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).