[alsa-devel] [PATCH 1/4] ALSA: x86: Don't pass SNDRV_PCM_INFO_BATCH flag

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Mon Feb 6 22:27:28 CET 2017


On 2/6/17 1:01 PM, Takashi Iwai wrote:
> 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.

As I mentioned in the other email, the FIFO can be up to 512 bytes so 
beware. And it makes sense to limit the period size to 1024 bytes minimum.

> 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.'

Both the pseudo-no-period-wakeup and single period should work but I am 
not sure how useful this is.

>
> 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 */
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel at alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>



More information about the Alsa-devel mailing list