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 0/4] Yet another patchset for LPE audio refactoring
Date: Tue, 07 Feb 2017 07:39:13 +0100	[thread overview]
Message-ID: <s5hd1eufqsu.wl-tiwai@suse.de> (raw)
In-Reply-To: <149fad5a-898d-ea49-625c-6be1bba350bf@linux.intel.com>

On Tue, 07 Feb 2017 00:56:54 +0100,
Pierre-Louis Bossart wrote:
> 
> On 2/6/17 3:45 PM, Takashi Iwai wrote:
> > On Mon, 06 Feb 2017 22:16:22 +0100,
> > Pierre-Louis Bossart wrote:
> >>
> >> On 2/6/17 1:07 PM, Takashi Iwai wrote:
> >>> On Fri, 03 Feb 2017 17:43:56 +0100,
> >>> Takashi Iwai wrote:
> >>>>
> >>>> Hi,
> >>>>
> >>>> this is the final part of my cleanup / refactoring patchsets for Intel
> >>>> LPE audio.  Now the PCM stream engine has been rewritten.  It supports
> >>>> more flexible configuration, not only fixed 4 periods, for example,
> >>>> yet with a lot of code reduction.
> >>>>
> >>>> As usual, the patches are found in topic/intel-lpe-audio-cleanup
> >>>> branch.
> >>>
> >>> So far, from my side, now most of changes have been submitted /
> >>> merged.  But I still have some unclear things in the code.
> >>>
> >>> - The PCM format: the code contains the handling of S16_LE, but it
> >>>   doesn't seem work when I enabled the info bit.  What's missing?
> >>>   Also U24_LE format is ever supported...?  How?
> >>
> >> In the initial version the samples were assumed to be using the 24 lsb
> >> of a 32-bit word. 16-bit data can be supported as long as it was
> >> left-shifted before being written to the ring buffer.
> >>
> >> For stereo the channels are assumed to be interleaved in Layout 0
> >> (left, right). For more than 2ch, all channels for the same sample are
> >> inserted consecutively (ie. no blocks of channels). In the initial
> >> version the number of channels is assumed to be even and one bogus
> >> channel had to be inserted for odd number of channels.
> >>
> >> in more recent versions the samples could also be represented as using
> >> the 24 msb and the requirement for the bogus channel was removed but I
> >> never worked on this personally and the documentation is far from
> >> clear.
> >
> > OK, that's interesting.  So we may support even  S32_LE format, too.
> 
> well, yes but the 8 LSBs would be ignored, you can only transmit 24
> bits with HDMI (it's 28 bits total per sample with 4 status bits).

Yes, S32_LE indicates only the format, and the effective bits are
specified in hwparam.msbits field additionally.


> > The odd channel restriction isn't seen in the current code, indeed.
> > It's worth to try 3 channels tomorrow :)
> >
> >> At any rate, here's what I see in the description of the
> >> STREAM_X_LPE_AUD_CONFIG registers for CHT:
> >>
> >> Bit 15:
> >> 1: DP mode
> >> 0: HDMI (default)
> >>
> >> Bit14:
> >> 1: no bogus sample for odd channels
> >> 0: bogus sample for off channels (default)
> >>
> >> Bit13:
> >> 1: MSB is bit 31 of 32-bit container
> >> 0: MSB is bit 23 of 32-bit container (default)
> >>
> >> Bit 12:
> >> 1: 16-bit container
> >> 0: 32-bit container (default)
> >>
> >> Bit 11:
> >> 1: send silence stream
> >> 0: send null packets (default)
> >
> > So this corresponds to the hw_silence stuff you mentioned?
> 
> yes. I am still trying to figure out how it's supposed to be used (you
> need a valid configuration first).

Judging from the field name, this influences on the underrun behavior.
If so, just setting all BDs to invalid (and set AUD_CONFIG enable bit)
should suffice?


> >> Note that the hardware can swap channels, I don't remember if this is
> >> currently enabled.
> >
> > We have the following code:
> >
> > #define SWAP_LFE_CENTER		0x00fac4c8
> >
> > 	/*
> > 	 * Program channel mapping in following order:
> > 	 * FL, FR, C, LFE, RL, RR
> > 	 */
> >
> > 	had_write_register(intelhaddata, AUD_BUF_CH_SWAP, SWAP_LFE_CENTER);
> >
> > 0x00fac4c8 is octal 74543210, so it's jus a plain order.
> 
> Yes, the 24 LBSs (23:0) in this register are split in 8 3-bit
> subfields, e.g if you program 7 (111b) in bits 2:0 and 0 in bits 23:21
> you would swap first and last channels.
> This only works for multichannel (layout 1), no support for l/r swap.

OK, if such a restriction is present, maybe it's no good idea to allow
the flexible mapping via chmap API.  Safer to keep the chmap as
read-only.


> >> There are two possible interrupt sources in the
> >> STREAM_X_LPE_AUD_HDMI_STATUS (65064h)
> >> Bit 31: sample buffer underrun. HDMI audio unit did not have enough
> >> samples to insert in video frame (cleared by writing a one)
> >> Bit 29: buffer done status, write 1 to clear
> >> Bit 15: sample buffer underrun interrupt enable
> >
> > OK, then the current code seems naming the function wrongly.
> > It names had_enable_audio_int() but actually this should be named as
> > had_clear_interrupts() or such.
> 
> I think enable and clear are two separate steps, you only clear what
> you've enabled, no?

Not really.  In the original code, it corresponds to
hdmi_audio_set_caps():

int hdmi_audio_set_caps(enum had_caps_list set_element,
			void *capabilties)
{
.....
	switch (set_element) {

	case HAD_SET_ENABLE_AUDIO_INT:
		{
			u32 status_reg;

			hdmi_audio_read(AUD_HDMI_STATUS_v2 +
				ctx->had_config_offset, &status_reg);
			status_reg |=
				HDMI_AUDIO_BUFFER_DONE | HDMI_AUDIO_UNDERRUN;
			hdmi_audio_write(AUD_HDMI_STATUS_v2 +
				ctx->had_config_offset, status_reg);
			hdmi_audio_read(AUD_HDMI_STATUS_v2 +
				ctx->had_config_offset, &status_reg);

		}

And there is no counterpart, HAD_SET_DISABLE_AUDIO_INT.
I wasn't sure about the code above, but now I understand that these
are simply ACKing both BUFFER_DONE and UNDERRUN bits unconditionally,
and do a pre- and a post-read.  Effectively, it forcibly clears the
interrupts.


thanks,

Takashi

      parent reply	other threads:[~2017-02-07  6:39 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
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 [this message]

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=s5hd1eufqsu.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).