From: Matthias Reichl <hias@horus.com>
To: Matt Flax <flatmax@flatmax.org>
Cc: alsa-devel@alsa-project.org, Lee Jones <lee@kernel.org>,
Mark Brown <broonie@kernel.org>,
Florian Meier <florian.meier@koalo.de>,
linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] ASoC: bcm2835: Add 8 channel (multitrack) capability
Date: Thu, 9 Feb 2017 10:29:11 +0100 [thread overview]
Message-ID: <20170209092910.GA2985@delle.lan> (raw)
In-Reply-To: <16046371-915e-6faa-0829-b0a9a07756a2@flatmax.org>
On Thu, Feb 09, 2017 at 09:48:04AM +1100, Matt Flax wrote:
>
> On 09/02/17 08:13, Matt Flax wrote:
> >
> >
> >On 09/02/17 05:54, Matthias Reichl wrote:
> >>On Wed, Feb 08, 2017 at 06:28:35PM +0000, Mark Brown wrote:
> >>>On Tue, Feb 07, 2017 at 10:09:36AM +1100, Matt Flax wrote:
> >>>
> >>>> case SND_SOC_DAIFMT_CBS_CFM:
> >>>> clk_set_rate(dev->clk, sampling_rate * bclk_ratio);
> >>>>+ case SND_SOC_DAIFMT_CBM_CFS:
> >>>Is this fall through deliberate?
> >>>
> >>>>+ /* Default data delay to 1 bit.
> >>>>+ In I2S mode, we must have 2 channels */
> >>>> switch (dev->fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
> >>>> case SND_SOC_DAIFMT_I2S:
> >>>>+ if (params_channels(params) != 2)
> >>>>+ return -EINVAL;
> >>>>+ case SND_SOC_DAIFMT_DSP_A:
> >>>>+ case SND_SOC_DAIFMT_DSP_B:
> >>>> data_delay = 1;
> >>>> break;
> >>>> default:
> >>Matt, could you please include linux-rpi-kernel@lists.infradead.org
> >>in your emails?
> >I have joined that list now. It was included originally, but wasn't
> >accepting my posts.
> >>I fail to see the part where DSP modes are actually set up in
> >>the hardware. bcm2835 still seems to be operating in 2-channel
> >>stereo I2S mode, i.e. no real frame sync information at the
> >>hardware level.
> >From the SoC's perspective I agree with you. There is frame
> >synchronisation at the hardware level, implemented in an master FPGA. This
> >starts to hit at a lack of functionality in ALSA ... I will discuss more
> >below.
> >>If all you do is adding code to pretend the bcm2835 could do
> >>multichannel modes wouldn't it be easier to implement that as
> >>a userspace alsa plugin?
> >>
> >>
> >I am not familiar with how to implement all of this with a plugin ? Could
> >you give me a little hand in describing that further ? That would mean
> >that an asoundrc needs to be used to defined to make the system usable ?
> >Is it something which does the unpacking for us in user space ? If this
> >happens in user space is there extra cost/latency ?
I haven't written a plugin myself, but there are plenty of examples out
there. Maybe there's already one that does what you need.
Have a look at the code in alsa-lib
http://git.alsa-project.org/?p=alsa-lib.git;a=tree;f=src/pcm
Also have a look at how iec958 is handled in most setups (pcm_iec958
plugin, integration via /usr/share/alsa/cards/*.conf
Plugins don't necessarily add a latency overhead, I've got the impression
all you need to do is to hook into hw_params and setup the slave hw
to 2 channels and 4 times the requested samplerate.
eg when 8-channel 48kHz is requested configure the hardware to
2-channel 192kHz.
You can pass additional information to the machine driver via controls,
eg to signal that you are transmitting 8-channel PCM encapsulated in
a 2-channel stream. Again a good example is iec958, the AES channel
status bits are transferred to the card via the IEC958 Playback Default
control in the card .conf via a hook plug.
> You know, I am genuinely interested in your concept and still invite an
> example of your creativity, however ...
> The more I think about this approach, the concept of pushing the support of
> hardware into user space the more I disagree with it. My understanding is
> that the Linux Kernel is there to support hardware. The concept of pushing
> hardware support into user space doesn't seem right.
>
> As I have pointed out below, there are missing things in ALSA and as Mark
> previously pointed out "this is a thing". What I understand is that this
> hardware is a thing and has been thought of before - this happens to be a
> hardware implementation of this "thing" which ALSA doesn't currently have
> the capacity to support (e.g. an ASIC/FPGA which is mater, not the SoC nor
> the Codec).
>From what you describe it looks to me the FPGA is just acting as a codec,
converting between 2-channel I2S and 8-channel (DSP?) at 1/4 of the I2S rate.
So you have bcm2835 I2S <-> FPGA <-> codec - IOW a standard codec<->codec
link.
What you seem to be missing is just a method to transfer your 8-channel
data via a 2-channel link - userspace want's to see an 8-channel PCM,
but the hardware link (bcm2835-i2s) is only 2-channel.
And that's where IMO as userspace plugin looks like a very good solution.
It's basically the counterpart of your FPGA and contains the code that's
neccessary to encapsulate/pack/whatever the 8-channel data into a 2-channel
stream so it can then be unpacked to 8-channel by the FPGA.
If you go this route your hardware and machine driver will work with
other I2S codecs as well, and IMO that's a far better solution than
adding very ugly hacks to a single I2S driver.
so long,
Hias
>
> I remember back in the '90s when ALSA was started - I witnessed its birth.
> ALSA was started because of inadequacies of OSS. I truly don't believe that
> we need a new sound system for Linux as of yet. I also don't believe that
> because ALSA has these inadequacies (which I mention below) that we need to
> start afresh. I would personally put effort into this part of ALSA if I had
> the money to support myself whilst I did it - but I don't. So for now, I am
> trying to make do with ALSA as best I can. I am trying to put the necessary
> support for existing hardware into ALSA in its current state and form - in
> the best possible manner. So please lets continue with support for this
> hardware in the kernel.
>
> >I would like to bring up another topic here.
> >
> >In my opinion some of these changes we are making in this general thread
> >are only really window dressing.
> >
> >We have 4 ways of setting up master, however all of them assume that
> >either the codec or the SoC is master. None of them allow for intermediate
> >digital logic between the two.
> >
> >In this case there is a FPGA which is matching the system differences
> >between the Codec and the SoC. In actual fact, the FPGA needs to be master
> >- a fifth mode.
> >
> >A similar problem exists when you are using a sample rate converter chip.
> >For example, the DAC and ADC are running at different sample rates. In
> >this case ALSA can't represent both of the sample rates. For that reason,
> >the ADCs and the DACs have to be hard coded - it is nasty.
> >
> >The only solution for me is to use snd_soc_dai_set_fmt in the machine
> >driver to instruct both to enter slave mode. For what it is worth, I can
> >also
> >
> >In my opinion there is nothing wrong with making hardware level
> >introductions, such as an ASIC/FPGA to implement the hardware. I accept
> >the inflexibility of ALSA w.r.t. this type of situation, however the real
> >fix is to adjust the core of ALSA. Hardware ASICS and FPGAs which are
> >intermediatries between codecs and SoCs exist and are used in industry.
> >
> >This happens to be one of those cases.
> >
> >thanks
> >Matt
> >
> >_______________________________________________
> >Alsa-devel mailing list
> >Alsa-devel@alsa-project.org
> >http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
WARNING: multiple messages have this Message-ID (diff)
From: hias@horus.com (Matthias Reichl)
To: linux-arm-kernel@lists.infradead.org
Subject: [alsa-devel] [PATCH] ASoC: bcm2835: Add 8 channel (multitrack) capability
Date: Thu, 9 Feb 2017 10:29:11 +0100 [thread overview]
Message-ID: <20170209092910.GA2985@delle.lan> (raw)
In-Reply-To: <16046371-915e-6faa-0829-b0a9a07756a2@flatmax.org>
On Thu, Feb 09, 2017 at 09:48:04AM +1100, Matt Flax wrote:
>
> On 09/02/17 08:13, Matt Flax wrote:
> >
> >
> >On 09/02/17 05:54, Matthias Reichl wrote:
> >>On Wed, Feb 08, 2017 at 06:28:35PM +0000, Mark Brown wrote:
> >>>On Tue, Feb 07, 2017 at 10:09:36AM +1100, Matt Flax wrote:
> >>>
> >>>> case SND_SOC_DAIFMT_CBS_CFM:
> >>>> clk_set_rate(dev->clk, sampling_rate * bclk_ratio);
> >>>>+ case SND_SOC_DAIFMT_CBM_CFS:
> >>>Is this fall through deliberate?
> >>>
> >>>>+ /* Default data delay to 1 bit.
> >>>>+ In I2S mode, we must have 2 channels */
> >>>> switch (dev->fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
> >>>> case SND_SOC_DAIFMT_I2S:
> >>>>+ if (params_channels(params) != 2)
> >>>>+ return -EINVAL;
> >>>>+ case SND_SOC_DAIFMT_DSP_A:
> >>>>+ case SND_SOC_DAIFMT_DSP_B:
> >>>> data_delay = 1;
> >>>> break;
> >>>> default:
> >>Matt, could you please include linux-rpi-kernel at lists.infradead.org
> >>in your emails?
> >I have joined that list now. It was included originally, but wasn't
> >accepting my posts.
> >>I fail to see the part where DSP modes are actually set up in
> >>the hardware. bcm2835 still seems to be operating in 2-channel
> >>stereo I2S mode, i.e. no real frame sync information at the
> >>hardware level.
> >From the SoC's perspective I agree with you. There is frame
> >synchronisation at the hardware level, implemented in an master FPGA. This
> >starts to hit at a lack of functionality in ALSA ... I will discuss more
> >below.
> >>If all you do is adding code to pretend the bcm2835 could do
> >>multichannel modes wouldn't it be easier to implement that as
> >>a userspace alsa plugin?
> >>
> >>
> >I am not familiar with how to implement all of this with a plugin ? Could
> >you give me a little hand in describing that further ? That would mean
> >that an asoundrc needs to be used to defined to make the system usable ?
> >Is it something which does the unpacking for us in user space ? If this
> >happens in user space is there extra cost/latency ?
I haven't written a plugin myself, but there are plenty of examples out
there. Maybe there's already one that does what you need.
Have a look at the code in alsa-lib
http://git.alsa-project.org/?p=alsa-lib.git;a=tree;f=src/pcm
Also have a look at how iec958 is handled in most setups (pcm_iec958
plugin, integration via /usr/share/alsa/cards/*.conf
Plugins don't necessarily add a latency overhead, I've got the impression
all you need to do is to hook into hw_params and setup the slave hw
to 2 channels and 4 times the requested samplerate.
eg when 8-channel 48kHz is requested configure the hardware to
2-channel 192kHz.
You can pass additional information to the machine driver via controls,
eg to signal that you are transmitting 8-channel PCM encapsulated in
a 2-channel stream. Again a good example is iec958, the AES channel
status bits are transferred to the card via the IEC958 Playback Default
control in the card .conf via a hook plug.
> You know, I am genuinely interested in your concept and still invite an
> example of your creativity, however ...
> The more I think about this approach, the concept of pushing the support of
> hardware into user space the more I disagree with it. My understanding is
> that the Linux Kernel is there to support hardware. The concept of pushing
> hardware support into user space doesn't seem right.
>
> As I have pointed out below, there are missing things in ALSA and as Mark
> previously pointed out "this is a thing". What I understand is that this
> hardware is a thing and has been thought of before - this happens to be a
> hardware implementation of this "thing" which ALSA doesn't currently have
> the capacity to support (e.g. an ASIC/FPGA which is mater, not the SoC nor
> the Codec).
>From what you describe it looks to me the FPGA is just acting as a codec,
converting between 2-channel I2S and 8-channel (DSP?) at 1/4 of the I2S rate.
So you have bcm2835 I2S <-> FPGA <-> codec - IOW a standard codec<->codec
link.
What you seem to be missing is just a method to transfer your 8-channel
data via a 2-channel link - userspace want's to see an 8-channel PCM,
but the hardware link (bcm2835-i2s) is only 2-channel.
And that's where IMO as userspace plugin looks like a very good solution.
It's basically the counterpart of your FPGA and contains the code that's
neccessary to encapsulate/pack/whatever the 8-channel data into a 2-channel
stream so it can then be unpacked to 8-channel by the FPGA.
If you go this route your hardware and machine driver will work with
other I2S codecs as well, and IMO that's a far better solution than
adding very ugly hacks to a single I2S driver.
so long,
Hias
>
> I remember back in the '90s when ALSA was started - I witnessed its birth.
> ALSA was started because of inadequacies of OSS. I truly don't believe that
> we need a new sound system for Linux as of yet. I also don't believe that
> because ALSA has these inadequacies (which I mention below) that we need to
> start afresh. I would personally put effort into this part of ALSA if I had
> the money to support myself whilst I did it - but I don't. So for now, I am
> trying to make do with ALSA as best I can. I am trying to put the necessary
> support for existing hardware into ALSA in its current state and form - in
> the best possible manner. So please lets continue with support for this
> hardware in the kernel.
>
> >I would like to bring up another topic here.
> >
> >In my opinion some of these changes we are making in this general thread
> >are only really window dressing.
> >
> >We have 4 ways of setting up master, however all of them assume that
> >either the codec or the SoC is master. None of them allow for intermediate
> >digital logic between the two.
> >
> >In this case there is a FPGA which is matching the system differences
> >between the Codec and the SoC. In actual fact, the FPGA needs to be master
> >- a fifth mode.
> >
> >A similar problem exists when you are using a sample rate converter chip.
> >For example, the DAC and ADC are running at different sample rates. In
> >this case ALSA can't represent both of the sample rates. For that reason,
> >the ADCs and the DACs have to be hard coded - it is nasty.
> >
> >The only solution for me is to use snd_soc_dai_set_fmt in the machine
> >driver to instruct both to enter slave mode. For what it is worth, I can
> >also
> >
> >In my opinion there is nothing wrong with making hardware level
> >introductions, such as an ASIC/FPGA to implement the hardware. I accept
> >the inflexibility of ALSA w.r.t. this type of situation, however the real
> >fix is to adjust the core of ALSA. Hardware ASICS and FPGAs which are
> >intermediatries between codecs and SoCs exist and are used in industry.
> >
> >This happens to be one of those cases.
> >
> >thanks
> >Matt
> >
> >_______________________________________________
> >Alsa-devel mailing list
> >Alsa-devel at alsa-project.org
> >http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
next prev parent reply other threads:[~2017-02-09 9:29 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-06 23:09 [PATCH] ASoC: bcm2835: Add 8 channel (multitrack) capability Matt Flax
2017-02-06 23:09 ` Matt Flax
2017-02-08 18:28 ` Mark Brown
2017-02-08 18:28 ` Mark Brown
2017-02-08 18:54 ` Matthias Reichl
2017-02-08 18:54 ` Matthias Reichl
2017-02-08 21:13 ` Matt Flax
2017-02-08 21:13 ` [alsa-devel] " Matt Flax
2017-02-08 22:48 ` Matt Flax
2017-02-08 22:48 ` [alsa-devel] " Matt Flax
2017-02-09 9:29 ` Matthias Reichl [this message]
2017-02-09 9:29 ` Matthias Reichl
2017-02-08 20:41 ` Matt Flax
2017-02-08 20:41 ` [alsa-devel] " Matt Flax
2017-02-08 21:14 ` Matt Flax
2017-02-08 21:14 ` [alsa-devel] " Matt Flax
2017-02-12 23:27 ` [PATCH v2] " Matt Flax
2017-02-12 23:27 ` Matt Flax
2017-02-13 20:51 ` Eric Anholt
2017-02-13 20:51 ` Eric Anholt
2017-02-14 9:32 ` Charles Keepax
2017-02-14 9:32 ` [alsa-devel] " Charles Keepax
2017-02-14 20:36 ` Matt Flax
2017-02-14 20:36 ` [alsa-devel] " Matt Flax
2017-02-14 20:52 ` [PATCH v3] " Matt Flax
2017-02-14 20:52 ` Matt Flax
2017-02-14 21:00 ` Matt Flax
2017-02-14 21:00 ` [alsa-devel] " Matt Flax
2017-02-14 21:04 ` [PATCH v4] " Matt Flax
2017-02-14 21:04 ` Matt Flax
2017-02-15 8:30 ` Arnaud Mouiche
2017-02-22 5:15 ` Matt Flax
2017-02-15 9:24 ` Charles Keepax
2017-02-15 9:24 ` Charles Keepax
2017-02-15 12:37 ` Florian Kauer
2017-02-15 12:37 ` Florian Kauer
2017-02-15 19:26 ` Eric Anholt
2017-02-15 19:26 ` Eric Anholt
2017-02-22 5:18 ` [PATCH v5] " Matt Flax
2017-02-22 5:18 ` Matt Flax
2017-02-22 5:20 ` Matt Flax
2017-02-22 5:20 ` Matt Flax
2017-02-22 5:22 ` [PATCH v6] " Matt Flax
2017-02-22 5:22 ` Matt Flax
2017-02-22 6:49 ` [alsa-devel] " kbuild test robot
2017-02-22 6:49 ` kbuild test robot
2017-02-22 18:28 ` Mark Brown
2017-02-22 18:28 ` Mark Brown
2017-02-22 22:45 ` Matt Flax
2017-02-22 22:45 ` [alsa-devel] " Matt Flax
2017-02-23 17:28 ` Mark Brown
2017-02-23 17:28 ` [alsa-devel] " Mark Brown
2017-02-22 6:56 ` [PATCH v8] " Matt Flax
2017-02-22 6:56 ` Matt Flax
2017-02-24 12:18 ` Matthias Reichl
2017-02-24 12:18 ` [alsa-devel] " Matthias Reichl
2017-02-24 13:50 ` Matt Flax
2017-02-24 13:50 ` [alsa-devel] " Matt Flax
2017-02-24 20:25 ` Matthias Reichl
2017-02-24 20:25 ` [alsa-devel] " Matthias Reichl
2017-02-24 21:30 ` Matt Flax
2017-02-24 21:30 ` [alsa-devel] " Matt Flax
2017-02-24 23:02 ` Matthias Reichl
2017-02-24 23:02 ` [alsa-devel] " Matthias Reichl
2017-02-25 0:08 ` Emmanuel Fusté
2017-02-25 0:08 ` [alsa-devel] " Emmanuel Fusté
2017-02-25 2:38 ` Matt Flax
2017-02-25 2:38 ` [alsa-devel] " Matt Flax
2017-02-25 5:04 ` Matt Flax
2017-02-25 5:04 ` [alsa-devel] " Matt Flax
2017-02-26 20:28 ` Matt Flax
2017-02-26 20:28 ` [alsa-devel] " Matt Flax
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=20170209092910.GA2985@delle.lan \
--to=hias@horus.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=flatmax@flatmax.org \
--cc=florian.meier@koalo.de \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-rpi-kernel@lists.infradead.org \
/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.