diff mbox

[RESEND] conf/cards: add VC4-HDMI card

Message ID 1488451773-22010-1-git-send-email-boris.brezillon@free-electrons.com (mailing list archive)
State New, archived
Headers show

Commit Message

Boris BREZILLON March 2, 2017, 10:49 a.m. UTC
Add a conf file for the VC4-HDMI sound card.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
Hi,

Sorry for the noise, but I didn't send this patch to the alsa-lib
maintainer on my first attempt.

This patch is adding a card config file for the audio sound card whose
driver has been submitted here [1] (not accepted yet).

Since I am a total newbie to the alsa world, I'd like to get some
feedback on this patch.

Also, the card only supports 2 to 8 channels, and I wonder if we should
add a plug element to support mono streams, and where this element
should be added (after or before the iec958 element).

Regards,

Boris

[1]https://www.spinics.net/lists/arm-kernel/msg565182.html

 src/conf/cards/Makefile.am   |  1 +
 src/conf/cards/aliases.conf  |  1 +
 src/conf/cards/vc4-hdmi.conf | 64 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+)
 create mode 100644 src/conf/cards/vc4-hdmi.conf

Comments

Eric Anholt March 16, 2017, 5:28 p.m. UTC | #1
Boris Brezillon <boris.brezillon@free-electrons.com> writes:

> Add a conf file for the VC4-HDMI sound card.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> Hi,
>
> Sorry for the noise, but I didn't send this patch to the alsa-lib
> maintainer on my first attempt.
>
> This patch is adding a card config file for the audio sound card whose
> driver has been submitted here [1] (not accepted yet).
>
> Since I am a total newbie to the alsa world, I'd like to get some
> feedback on this patch.
>
> Also, the card only supports 2 to 8 channels, and I wonder if we should
> add a plug element to support mono streams, and where this element
> should be added (after or before the iec958 element).
>
> Regards,
>
> Boris
>
> [1]https://www.spinics.net/lists/arm-kernel/msg565182.html

The kernel driver is getting merged now.

Tested-by: Eric Anholt <eric@anholt.net>

PulseAudio on the desktop seems to work fine.  aplay at the console
fails:

aplay -v  ~/LRMonoPhase4.wav
Playing WAVE '/home/anholt/LRMonoPhase4.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
aplay: set_params:1297: Sample format non available
Available formats:
- IEC958_SUBFRAME_LE

but if you specify iec958 it works:

aplay -v -D iec958  ~/LRMonoPhase4.wav 
Playing WAVE '/home/anholt/LRMonoPhase4.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
IEC958 subframe conversion PCM (IEC958_SUBFRAME_LE)
Its setup is:
  stream       : PLAYBACK
...

but if you specify a mono file it doesn't:

anholt@rpi-open:/home/anholt% aplay -v -D iec958  /usr/share/sounds/alsa/Front_Left.wav 
Playing WAVE '/usr/share/sounds/alsa/Front_Left.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
aplay: set_params:1361: Unable to install hw params:
ACCESS:  RW_INTERLEAVED
FORMAT:  S16_LE
SUBFORMAT:  STD
SAMPLE_BITS: 16
FRAME_BITS: 16
CHANNELS: 1
...
Takashi Iwai March 20, 2017, 11:06 a.m. UTC | #2
On Thu, 02 Mar 2017 11:49:33 +0100,
Boris Brezillon wrote:
> 
> Add a conf file for the VC4-HDMI sound card.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> Hi,
> 
> Sorry for the noise, but I didn't send this patch to the alsa-lib
> maintainer on my first attempt.
> 
> This patch is adding a card config file for the audio sound card whose
> driver has been submitted here [1] (not accepted yet).
> 
> Since I am a total newbie to the alsa world, I'd like to get some
> feedback on this patch.
> 
> Also, the card only supports 2 to 8 channels, and I wonder if we should
> add a plug element to support mono streams, and where this element
> should be added (after or before the iec958 element).

Applied, thanks.


Takashi


> 
> Regards,
> 
> Boris
> 
> [1]https://www.spinics.net/lists/arm-kernel/msg565182.html
> 
>  src/conf/cards/Makefile.am   |  1 +
>  src/conf/cards/aliases.conf  |  1 +
>  src/conf/cards/vc4-hdmi.conf | 64 ++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 66 insertions(+)
>  create mode 100644 src/conf/cards/vc4-hdmi.conf
> 
> diff --git a/src/conf/cards/Makefile.am b/src/conf/cards/Makefile.am
> index e8b530e80a8f..00999f0186d6 100644
> --- a/src/conf/cards/Makefile.am
> +++ b/src/conf/cards/Makefile.am
> @@ -51,6 +51,7 @@ cfg_files = aliases.conf \
>  	TRID4DWAVENX.conf \
>  	USB-Audio.conf \
>  	YMF744.conf \
> +	vc4-hdmi.conf \
>  	VIA686A.conf \
>  	VIA8233.conf \
>  	VIA8233A.conf \
> diff --git a/src/conf/cards/aliases.conf b/src/conf/cards/aliases.conf
> index 60f9d26974fd..18a920f41e46 100644
> --- a/src/conf/cards/aliases.conf
> +++ b/src/conf/cards/aliases.conf
> @@ -56,6 +56,7 @@ AV200 cards.CMI8788
>  CMI8786 cards.CMI8788
>  CMI8787 cards.CMI8788
>  pistachio cards.pistachio-card
> +VC4-HDMI cards.vc4-hdmi
>  
>  <confdir:pcm/default.conf>
>  <confdir:pcm/dmix.conf>
> diff --git a/src/conf/cards/vc4-hdmi.conf b/src/conf/cards/vc4-hdmi.conf
> new file mode 100644
> index 000000000000..027804a145d1
> --- /dev/null
> +++ b/src/conf/cards/vc4-hdmi.conf
> @@ -0,0 +1,64 @@
> +#
> +# Configuration for the VC4-HDMI sound card using software IEC958
> +# subframe conversion
> +#
> +
> +<confdir:pcm/front.conf>
> +
> +vc4-hdmi.pcm.front.0 {
> +	@args [ CARD ]
> +	@args.CARD {
> +		type string
> +	}
> +	type hw
> +	card $CARD
> +}
> +
> +# default with dmix
> +vc4-hdmi.pcm.default {
> +	@args [ CARD ]
> +	@args.CARD {
> +		type string
> +	}
> +	type asym
> +	playback.pcm {
> +		type plug
> +		slave.pcm {
> +			@func concat
> +			strings [ "dmix:" $CARD ]
> +		}
> +	}
> +}
> +
> +<confdir:pcm/iec958.conf>
> +
> +vc4-hdmi.pcm.iec958.0 {
> +	@args [ CARD AES0 AES1 AES2 AES3 ]
> +	@args.CARD {
> +		type string
> +	}
> +	@args.AES0 {
> +		type integer
> +	}
> +	@args.AES1 {
> +		type integer
> +	}
> +	@args.AES2 {
> +		type integer
> +	}
> +	@args.AES3 {
> +		type integer
> +	}
> +	type iec958
> +	slave {
> +		format IEC958_SUBFRAME_LE
> +		pcm {
> +			type plug
> +			slave.pcm {
> +				type hw
> +				card $CARD
> +			}
> +		}
> +	}
> +	status [ $AES0 $AES1 $AES2 $AES3 ]
> +}
> -- 
> 2.7.4
>
Eric Anholt April 6, 2017, 7:46 p.m. UTC | #3
Takashi Iwai <tiwai@suse.de> writes:

> On Thu, 02 Mar 2017 11:49:33 +0100,
> Boris Brezillon wrote:
>> 
>> Add a conf file for the VC4-HDMI sound card.
>> 
>> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
>> ---
>> Hi,
>> 
>> Sorry for the noise, but I didn't send this patch to the alsa-lib
>> maintainer on my first attempt.
>> 
>> This patch is adding a card config file for the audio sound card whose
>> driver has been submitted here [1] (not accepted yet).
>> 
>> Since I am a total newbie to the alsa world, I'd like to get some
>> feedback on this patch.
>> 
>> Also, the card only supports 2 to 8 channels, and I wonder if we should
>> add a plug element to support mono streams, and where this element
>> should be added (after or before the iec958 element).
>
> Applied, thanks.

Thanks!

Any recommendations on how to restructure this so that things like
'aplay' from the console also work by default?
Takashi Iwai April 7, 2017, 8:21 a.m. UTC | #4
On Thu, 06 Apr 2017 21:46:29 +0200,
Eric Anholt wrote:
> 
> Takashi Iwai <tiwai@suse.de> writes:
> 
> > On Thu, 02 Mar 2017 11:49:33 +0100,
> > Boris Brezillon wrote:
> >> 
> >> Add a conf file for the VC4-HDMI sound card.
> >> 
> >> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> >> ---
> >> Hi,
> >> 
> >> Sorry for the noise, but I didn't send this patch to the alsa-lib
> >> maintainer on my first attempt.
> >> 
> >> This patch is adding a card config file for the audio sound card whose
> >> driver has been submitted here [1] (not accepted yet).
> >> 
> >> Since I am a total newbie to the alsa world, I'd like to get some
> >> feedback on this patch.
> >> 
> >> Also, the card only supports 2 to 8 channels, and I wonder if we should
> >> add a plug element to support mono streams, and where this element
> >> should be added (after or before the iec958 element).
> >
> > Applied, thanks.
> 
> Thanks!
> 
> Any recommendations on how to restructure this so that things like
> 'aplay' from the console also work by default?

Well, once after you have your card config in
/usr/share/alsa/cards/vc4-hdmi.conf, aplay should work as is.

If not, check /proc/asounds output.  The entry looks like
 0 [ID            ]: DRIVER - SHORTNAME
                     LONGNAME

and in your case, "DRIVER" must be "vc4-hdmi", as same as the config
file name.


Takashi
Eric Anholt April 7, 2017, 5:20 p.m. UTC | #5
Takashi Iwai <tiwai@suse.de> writes:

> On Thu, 06 Apr 2017 21:46:29 +0200,
> Eric Anholt wrote:
>> 
>> Takashi Iwai <tiwai@suse.de> writes:
>> 
>> > On Thu, 02 Mar 2017 11:49:33 +0100,
>> > Boris Brezillon wrote:
>> >> 
>> >> Add a conf file for the VC4-HDMI sound card.
>> >> 
>> >> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
>> >> ---
>> >> Hi,
>> >> 
>> >> Sorry for the noise, but I didn't send this patch to the alsa-lib
>> >> maintainer on my first attempt.
>> >> 
>> >> This patch is adding a card config file for the audio sound card whose
>> >> driver has been submitted here [1] (not accepted yet).
>> >> 
>> >> Since I am a total newbie to the alsa world, I'd like to get some
>> >> feedback on this patch.
>> >> 
>> >> Also, the card only supports 2 to 8 channels, and I wonder if we should
>> >> add a plug element to support mono streams, and where this element
>> >> should be added (after or before the iec958 element).
>> >
>> > Applied, thanks.
>> 
>> Thanks!
>> 
>> Any recommendations on how to restructure this so that things like
>> 'aplay' from the console also work by default?
>
> Well, once after you have your card config in
> /usr/share/alsa/cards/vc4-hdmi.conf, aplay should work as is.
>
> If not, check /proc/asounds output.  The entry looks like
>  0 [ID            ]: DRIVER - SHORTNAME
>                      LONGNAME
>
> and in your case, "DRIVER" must be "vc4-hdmi", as same as the config
> file name.

It doesn't work as is -- the default ends up not having iec958
conversion, so nothing will play.  You can do aplay -D iec958, which
works but only as long as you've got stereo input (it seems plug can't
do mono-to-stereo on iec958 data)
Boris BREZILLON April 10, 2017, 12:09 p.m. UTC | #6
Eric, Takashi,

On Fri, 07 Apr 2017 10:20:20 -0700
Eric Anholt <eric@anholt.net> wrote:

> Takashi Iwai <tiwai@suse.de> writes:
> 
> > On Thu, 06 Apr 2017 21:46:29 +0200,
> > Eric Anholt wrote:  
> >> 
> >> Takashi Iwai <tiwai@suse.de> writes:
> >>   
> >> > On Thu, 02 Mar 2017 11:49:33 +0100,
> >> > Boris Brezillon wrote:  
> >> >> 
> >> >> Add a conf file for the VC4-HDMI sound card.
> >> >> 
> >> >> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> >> >> ---
> >> >> Hi,
> >> >> 
> >> >> Sorry for the noise, but I didn't send this patch to the alsa-lib
> >> >> maintainer on my first attempt.
> >> >> 
> >> >> This patch is adding a card config file for the audio sound card whose
> >> >> driver has been submitted here [1] (not accepted yet).
> >> >> 
> >> >> Since I am a total newbie to the alsa world, I'd like to get some
> >> >> feedback on this patch.
> >> >> 
> >> >> Also, the card only supports 2 to 8 channels, and I wonder if we should
> >> >> add a plug element to support mono streams, and where this element
> >> >> should be added (after or before the iec958 element).  
> >> >
> >> > Applied, thanks.  
> >> 
> >> Thanks!
> >> 
> >> Any recommendations on how to restructure this so that things like
> >> 'aplay' from the console also work by default?  
> >
> > Well, once after you have your card config in
> > /usr/share/alsa/cards/vc4-hdmi.conf, aplay should work as is.
> >
> > If not, check /proc/asounds output.  The entry looks like
> >  0 [ID            ]: DRIVER - SHORTNAME
> >                      LONGNAME
> >
> > and in your case, "DRIVER" must be "vc4-hdmi", as same as the config
> > file name.  
> 
> It doesn't work as is -- the default ends up not having iec958
> conversion, so nothing will play.  You can do aplay -D iec958, which
> works but only as long as you've got stereo input (it seems plug can't
> do mono-to-stereo on iec958 data)

Sorry for being so silent during the past weeks, but I've been busy
with other things and was on vacation last week.

As Eric explained, we're looking for advices on how to best expose
the sound card so that it can be easily used by end-users without
requiring advanced options (like -D iec958) or conf tweaking (like
declaring an extra plug element before the iec958 one to convert from
mono to stereo and then using -D iec958-mono).

Takashi, what do you suggest? Is it possible/acceptable to make iec958
the default for this card? What about implicit/automatic mono-to-stereo
conversion, is it achievable?

Thanks,

Boris
Takashi Iwai April 10, 2017, 12:19 p.m. UTC | #7
On Mon, 10 Apr 2017 14:09:11 +0200,
Boris Brezillon wrote:
> 
> Eric, Takashi,
> 
> On Fri, 07 Apr 2017 10:20:20 -0700
> Eric Anholt <eric@anholt.net> wrote:
> 
> > Takashi Iwai <tiwai@suse.de> writes:
> > 
> > > On Thu, 06 Apr 2017 21:46:29 +0200,
> > > Eric Anholt wrote:  
> > >> 
> > >> Takashi Iwai <tiwai@suse.de> writes:
> > >>   
> > >> > On Thu, 02 Mar 2017 11:49:33 +0100,
> > >> > Boris Brezillon wrote:  
> > >> >> 
> > >> >> Add a conf file for the VC4-HDMI sound card.
> > >> >> 
> > >> >> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > >> >> ---
> > >> >> Hi,
> > >> >> 
> > >> >> Sorry for the noise, but I didn't send this patch to the alsa-lib
> > >> >> maintainer on my first attempt.
> > >> >> 
> > >> >> This patch is adding a card config file for the audio sound card whose
> > >> >> driver has been submitted here [1] (not accepted yet).
> > >> >> 
> > >> >> Since I am a total newbie to the alsa world, I'd like to get some
> > >> >> feedback on this patch.
> > >> >> 
> > >> >> Also, the card only supports 2 to 8 channels, and I wonder if we should
> > >> >> add a plug element to support mono streams, and where this element
> > >> >> should be added (after or before the iec958 element).  
> > >> >
> > >> > Applied, thanks.  
> > >> 
> > >> Thanks!
> > >> 
> > >> Any recommendations on how to restructure this so that things like
> > >> 'aplay' from the console also work by default?  
> > >
> > > Well, once after you have your card config in
> > > /usr/share/alsa/cards/vc4-hdmi.conf, aplay should work as is.
> > >
> > > If not, check /proc/asounds output.  The entry looks like
> > >  0 [ID            ]: DRIVER - SHORTNAME
> > >                      LONGNAME
> > >
> > > and in your case, "DRIVER" must be "vc4-hdmi", as same as the config
> > > file name.  
> > 
> > It doesn't work as is -- the default ends up not having iec958
> > conversion, so nothing will play.  You can do aplay -D iec958, which
> > works but only as long as you've got stereo input (it seems plug can't
> > do mono-to-stereo on iec958 data)
> 
> Sorry for being so silent during the past weeks, but I've been busy
> with other things and was on vacation last week.

Thanks for joining.  I was also slow just because I've been sick and
off in the last week :-<  Now getting recovered, and resuming the
task...

> As Eric explained, we're looking for advices on how to best expose
> the sound card so that it can be easily used by end-users without
> requiring advanced options (like -D iec958) or conf tweaking (like
> declaring an extra plug element before the iec958 one to convert from
> mono to stereo and then using -D iec958-mono).
> 
> Takashi, what do you suggest? Is it possible/acceptable to make iec958
> the default for this card? What about implicit/automatic mono-to-stereo
> conversion, is it achievable?

Now I looked at your config again, and one likely problem is that you
wrap plug *before* iec958 plugin.

vc4-hdmi.pcm.iec958.0 {
.....
	type iec958
	slave {
		format IEC958_SUBFRAME_LE
		pcm {
			type plug
			slave.pcm {
				type hw
				card $CARD
			}
		}
	}
	status [ $AES0 $AES1 $AES2 $AES3 ]
}

Why do you need to wrap with plug there?  Instead, it should be
accessing directly to hw, i.e.

vc4-hdmi.pcm.iec958.0 {
	@args [ CARD AES0 AES1 AES2 AES3 ]
	@args.CARD {
		type string
	}
	@args.AES0 {
		type integer
	}
	@args.AES1 {
		type integer
	}
	@args.AES2 {
		type integer
	}
	@args.AES3 {
		type integer
	}
	type iec958
	slave {
		format IEC958_SUBFRAME_LE
		pcm {
			type hw
			card $CARD
		}
	}
	status [ $AES0 $AES1 $AES2 $AES3 ]
}

Then the plug above this plugin should work.

   % aplay -D plug:hdmi foo.wav


(Note that plug over plug doesn't work -- that's the likely reason it
 failed before.)


Then, about the default PCM: I wonder whether the dmix is feasible at
all with this kind of setup.  What format does work with this device?


Takashi
Boris BREZILLON April 10, 2017, 12:35 p.m. UTC | #8
On Mon, 10 Apr 2017 14:19:18 +0200
Takashi Iwai <tiwai@suse.de> wrote:

> On Mon, 10 Apr 2017 14:09:11 +0200,
> Boris Brezillon wrote:
> > 
> > Eric, Takashi,
> > 
> > On Fri, 07 Apr 2017 10:20:20 -0700
> > Eric Anholt <eric@anholt.net> wrote:
> >   
> > > Takashi Iwai <tiwai@suse.de> writes:
> > >   
> > > > On Thu, 06 Apr 2017 21:46:29 +0200,
> > > > Eric Anholt wrote:    
> > > >> 
> > > >> Takashi Iwai <tiwai@suse.de> writes:
> > > >>     
> > > >> > On Thu, 02 Mar 2017 11:49:33 +0100,
> > > >> > Boris Brezillon wrote:    
> > > >> >> 
> > > >> >> Add a conf file for the VC4-HDMI sound card.
> > > >> >> 
> > > >> >> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > > >> >> ---
> > > >> >> Hi,
> > > >> >> 
> > > >> >> Sorry for the noise, but I didn't send this patch to the alsa-lib
> > > >> >> maintainer on my first attempt.
> > > >> >> 
> > > >> >> This patch is adding a card config file for the audio sound card whose
> > > >> >> driver has been submitted here [1] (not accepted yet).
> > > >> >> 
> > > >> >> Since I am a total newbie to the alsa world, I'd like to get some
> > > >> >> feedback on this patch.
> > > >> >> 
> > > >> >> Also, the card only supports 2 to 8 channels, and I wonder if we should
> > > >> >> add a plug element to support mono streams, and where this element
> > > >> >> should be added (after or before the iec958 element).    
> > > >> >
> > > >> > Applied, thanks.    
> > > >> 
> > > >> Thanks!
> > > >> 
> > > >> Any recommendations on how to restructure this so that things like
> > > >> 'aplay' from the console also work by default?    
> > > >
> > > > Well, once after you have your card config in
> > > > /usr/share/alsa/cards/vc4-hdmi.conf, aplay should work as is.
> > > >
> > > > If not, check /proc/asounds output.  The entry looks like
> > > >  0 [ID            ]: DRIVER - SHORTNAME
> > > >                      LONGNAME
> > > >
> > > > and in your case, "DRIVER" must be "vc4-hdmi", as same as the config
> > > > file name.    
> > > 
> > > It doesn't work as is -- the default ends up not having iec958
> > > conversion, so nothing will play.  You can do aplay -D iec958, which
> > > works but only as long as you've got stereo input (it seems plug can't
> > > do mono-to-stereo on iec958 data)  
> > 
> > Sorry for being so silent during the past weeks, but I've been busy
> > with other things and was on vacation last week.  
> 
> Thanks for joining.  I was also slow just because I've been sick and
> off in the last week :-<  Now getting recovered, and resuming the
> task...
> 
> > As Eric explained, we're looking for advices on how to best expose
> > the sound card so that it can be easily used by end-users without
> > requiring advanced options (like -D iec958) or conf tweaking (like
> > declaring an extra plug element before the iec958 one to convert from
> > mono to stereo and then using -D iec958-mono).
> > 
> > Takashi, what do you suggest? Is it possible/acceptable to make iec958
> > the default for this card? What about implicit/automatic mono-to-stereo
> > conversion, is it achievable?  
> 
> Now I looked at your config again, and one likely problem is that you
> wrap plug *before* iec958 plugin.
> 
> vc4-hdmi.pcm.iec958.0 {
> .....
> 	type iec958
> 	slave {
> 		format IEC958_SUBFRAME_LE
> 		pcm {
> 			type plug
> 			slave.pcm {
> 				type hw
> 				card $CARD
> 			}
> 		}
> 	}
> 	status [ $AES0 $AES1 $AES2 $AES3 ]
> }
> 
> Why do you need to wrap with plug there? 

I honestly don't know. As said in my initila submission I'm a total
newbie hence the request for help ;-).

> Instead, it should be
> accessing directly to hw, i.e.
> 
> vc4-hdmi.pcm.iec958.0 {
> 	@args [ CARD AES0 AES1 AES2 AES3 ]
> 	@args.CARD {
> 		type string
> 	}
> 	@args.AES0 {
> 		type integer
> 	}
> 	@args.AES1 {
> 		type integer
> 	}
> 	@args.AES2 {
> 		type integer
> 	}
> 	@args.AES3 {
> 		type integer
> 	}
> 	type iec958
> 	slave {
> 		format IEC958_SUBFRAME_LE
> 		pcm {
> 			type hw
> 			card $CARD
> 		}
> 	}
> 	status [ $AES0 $AES1 $AES2 $AES3 ]
> }
> 
> Then the plug above this plugin should work.
> 
>    % aplay -D plug:hdmi foo.wav

Oh, I didn't know you could dynamically build the pipeline from the
command line.
Note that I'm not including pcm/hdmi.conf, which is probably wrong.

> 
> 
> (Note that plug over plug doesn't work -- that's the likely reason it
>  failed before.)
> 
> 
> Then, about the default PCM: I wonder whether the dmix is feasible at
> all with this kind of setup.  What format does work with this device?

Only IEC958_SUBFRAME_LE

Thanks for your help.

Boris
Takashi Iwai April 10, 2017, 12:42 p.m. UTC | #9
On Mon, 10 Apr 2017 14:35:23 +0200,
Boris Brezillon wrote:
> 
> On Mon, 10 Apr 2017 14:19:18 +0200
> Takashi Iwai <tiwai@suse.de> wrote:
> 
> > On Mon, 10 Apr 2017 14:09:11 +0200,
> > Boris Brezillon wrote:
> > > 
> > > Eric, Takashi,
> > > 
> > > On Fri, 07 Apr 2017 10:20:20 -0700
> > > Eric Anholt <eric@anholt.net> wrote:
> > >   
> > > > Takashi Iwai <tiwai@suse.de> writes:
> > > >   
> > > > > On Thu, 06 Apr 2017 21:46:29 +0200,
> > > > > Eric Anholt wrote:    
> > > > >> 
> > > > >> Takashi Iwai <tiwai@suse.de> writes:
> > > > >>     
> > > > >> > On Thu, 02 Mar 2017 11:49:33 +0100,
> > > > >> > Boris Brezillon wrote:    
> > > > >> >> 
> > > > >> >> Add a conf file for the VC4-HDMI sound card.
> > > > >> >> 
> > > > >> >> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> > > > >> >> ---
> > > > >> >> Hi,
> > > > >> >> 
> > > > >> >> Sorry for the noise, but I didn't send this patch to the alsa-lib
> > > > >> >> maintainer on my first attempt.
> > > > >> >> 
> > > > >> >> This patch is adding a card config file for the audio sound card whose
> > > > >> >> driver has been submitted here [1] (not accepted yet).
> > > > >> >> 
> > > > >> >> Since I am a total newbie to the alsa world, I'd like to get some
> > > > >> >> feedback on this patch.
> > > > >> >> 
> > > > >> >> Also, the card only supports 2 to 8 channels, and I wonder if we should
> > > > >> >> add a plug element to support mono streams, and where this element
> > > > >> >> should be added (after or before the iec958 element).    
> > > > >> >
> > > > >> > Applied, thanks.    
> > > > >> 
> > > > >> Thanks!
> > > > >> 
> > > > >> Any recommendations on how to restructure this so that things like
> > > > >> 'aplay' from the console also work by default?    
> > > > >
> > > > > Well, once after you have your card config in
> > > > > /usr/share/alsa/cards/vc4-hdmi.conf, aplay should work as is.
> > > > >
> > > > > If not, check /proc/asounds output.  The entry looks like
> > > > >  0 [ID            ]: DRIVER - SHORTNAME
> > > > >                      LONGNAME
> > > > >
> > > > > and in your case, "DRIVER" must be "vc4-hdmi", as same as the config
> > > > > file name.    
> > > > 
> > > > It doesn't work as is -- the default ends up not having iec958
> > > > conversion, so nothing will play.  You can do aplay -D iec958, which
> > > > works but only as long as you've got stereo input (it seems plug can't
> > > > do mono-to-stereo on iec958 data)  
> > > 
> > > Sorry for being so silent during the past weeks, but I've been busy
> > > with other things and was on vacation last week.  
> > 
> > Thanks for joining.  I was also slow just because I've been sick and
> > off in the last week :-<  Now getting recovered, and resuming the
> > task...
> > 
> > > As Eric explained, we're looking for advices on how to best expose
> > > the sound card so that it can be easily used by end-users without
> > > requiring advanced options (like -D iec958) or conf tweaking (like
> > > declaring an extra plug element before the iec958 one to convert from
> > > mono to stereo and then using -D iec958-mono).
> > > 
> > > Takashi, what do you suggest? Is it possible/acceptable to make iec958
> > > the default for this card? What about implicit/automatic mono-to-stereo
> > > conversion, is it achievable?  
> > 
> > Now I looked at your config again, and one likely problem is that you
> > wrap plug *before* iec958 plugin.
> > 
> > vc4-hdmi.pcm.iec958.0 {
> > .....
> > 	type iec958
> > 	slave {
> > 		format IEC958_SUBFRAME_LE
> > 		pcm {
> > 			type plug
> > 			slave.pcm {
> > 				type hw
> > 				card $CARD
> > 			}
> > 		}
> > 	}
> > 	status [ $AES0 $AES1 $AES2 $AES3 ]
> > }
> > 
> > Why do you need to wrap with plug there? 
> 
> I honestly don't know. As said in my initila submission I'm a total
> newbie hence the request for help ;-).
> 
> > Instead, it should be
> > accessing directly to hw, i.e.
> > 
> > vc4-hdmi.pcm.iec958.0 {
> > 	@args [ CARD AES0 AES1 AES2 AES3 ]
> > 	@args.CARD {
> > 		type string
> > 	}
> > 	@args.AES0 {
> > 		type integer
> > 	}
> > 	@args.AES1 {
> > 		type integer
> > 	}
> > 	@args.AES2 {
> > 		type integer
> > 	}
> > 	@args.AES3 {
> > 		type integer
> > 	}
> > 	type iec958
> > 	slave {
> > 		format IEC958_SUBFRAME_LE
> > 		pcm {
> > 			type hw
> > 			card $CARD
> > 		}
> > 	}
> > 	status [ $AES0 $AES1 $AES2 $AES3 ]
> > }
> > 
> > Then the plug above this plugin should work.
> > 
> >    % aplay -D plug:hdmi foo.wav
> 
> Oh, I didn't know you could dynamically build the pipeline from the
> command line.
> Note that I'm not including pcm/hdmi.conf, which is probably wrong.

Erm, sorry, the above was ment as "plug:iec958".
But yes, it'd be better to define hdmi PCM as well.

> > (Note that plug over plug doesn't work -- that's the likely reason it
> >  failed before.)
> > 
> > 
> > Then, about the default PCM: I wonder whether the dmix is feasible at
> > all with this kind of setup.  What format does work with this device?
> 
> Only IEC958_SUBFRAME_LE

OK, then even you can drop the explicit format specification in the
above.

And I'm afraid that dmix won't work with IEC958 subframe type.  dmix
can deal with the direct hw access, and it's limited with the normal
linear PCM types.  In theory, we can apply the dmix-style plugin onto
iec958 subframes, but the current code doesn't do it.

That said, the default should be rather passing iec958 or hdmi without
the mixing.  If the stream mixing is required, you need to use some
sound server instead.


Takashi
diff mbox

Patch

diff --git a/src/conf/cards/Makefile.am b/src/conf/cards/Makefile.am
index e8b530e80a8f..00999f0186d6 100644
--- a/src/conf/cards/Makefile.am
+++ b/src/conf/cards/Makefile.am
@@ -51,6 +51,7 @@  cfg_files = aliases.conf \
 	TRID4DWAVENX.conf \
 	USB-Audio.conf \
 	YMF744.conf \
+	vc4-hdmi.conf \
 	VIA686A.conf \
 	VIA8233.conf \
 	VIA8233A.conf \
diff --git a/src/conf/cards/aliases.conf b/src/conf/cards/aliases.conf
index 60f9d26974fd..18a920f41e46 100644
--- a/src/conf/cards/aliases.conf
+++ b/src/conf/cards/aliases.conf
@@ -56,6 +56,7 @@  AV200 cards.CMI8788
 CMI8786 cards.CMI8788
 CMI8787 cards.CMI8788
 pistachio cards.pistachio-card
+VC4-HDMI cards.vc4-hdmi
 
 <confdir:pcm/default.conf>
 <confdir:pcm/dmix.conf>
diff --git a/src/conf/cards/vc4-hdmi.conf b/src/conf/cards/vc4-hdmi.conf
new file mode 100644
index 000000000000..027804a145d1
--- /dev/null
+++ b/src/conf/cards/vc4-hdmi.conf
@@ -0,0 +1,64 @@ 
+#
+# Configuration for the VC4-HDMI sound card using software IEC958
+# subframe conversion
+#
+
+<confdir:pcm/front.conf>
+
+vc4-hdmi.pcm.front.0 {
+	@args [ CARD ]
+	@args.CARD {
+		type string
+	}
+	type hw
+	card $CARD
+}
+
+# default with dmix
+vc4-hdmi.pcm.default {
+	@args [ CARD ]
+	@args.CARD {
+		type string
+	}
+	type asym
+	playback.pcm {
+		type plug
+		slave.pcm {
+			@func concat
+			strings [ "dmix:" $CARD ]
+		}
+	}
+}
+
+<confdir:pcm/iec958.conf>
+
+vc4-hdmi.pcm.iec958.0 {
+	@args [ CARD AES0 AES1 AES2 AES3 ]
+	@args.CARD {
+		type string
+	}
+	@args.AES0 {
+		type integer
+	}
+	@args.AES1 {
+		type integer
+	}
+	@args.AES2 {
+		type integer
+	}
+	@args.AES3 {
+		type integer
+	}
+	type iec958
+	slave {
+		format IEC958_SUBFRAME_LE
+		pcm {
+			type plug
+			slave.pcm {
+				type hw
+				card $CARD
+			}
+		}
+	}
+	status [ $AES0 $AES1 $AES2 $AES3 ]
+}