2016-03-12 07:52:37

by Danny Milosavljevic

[permalink] [raw]
Subject: Re: [linux-sunxi] Re: [PATCH v8 2/2] ASoc: sun4i-codec: Add FM, Line and Mic inputs

Hi,

does anyone know the answer to the questions below?

> The other direction (making two controls which both do the same and update
> each other's value) doesn't seem to be easily available.

> Should I write a _put handler that does it manually?

> (Or should that be handled by alsa-lib mixer modules instead?)

> Is it possible to merge the "Left Mixer" control and respective
> "Right Mixer" control into one selem in alsamixer?
>
> Because alsamixer actually has support for one-sided muting.

If that's unknown, I can post v9 without doing the grouping-together of mixer controls and we can use it like that - I don't want the patch to stall indefinitely on mere usability issues...

Regards,
Danny


2016-03-12 08:31:21

by Code Kipper

[permalink] [raw]
Subject: Re: [linux-sunxi] Re: [PATCH v8 2/2] ASoc: sun4i-codec: Add FM, Line and Mic inputs

Hi Danny,
I've got some patches to go which covers pretty much everything that
we can manage with the sun4i-codec. I'm only lacking testing of
certain bits as I don't have capable hardware(i.e. FM capture). I've
ignored the phone out part of the A20 as I couldn't find the pins.
I'll try to upload them to my github this weekend. You should have
authorship on some of these so when I send the link feel free to
claim.
BR,
CK

On 12 March 2016 at 08:52, Danny Milosavljevic <[email protected]> wrote:
> Hi,
>
> does anyone know the answer to the questions below?
>
>> The other direction (making two controls which both do the same and update
>> each other's value) doesn't seem to be easily available.
>
>> Should I write a _put handler that does it manually?
>
>> (Or should that be handled by alsa-lib mixer modules instead?)
>
>> Is it possible to merge the "Left Mixer" control and respective
>> "Right Mixer" control into one selem in alsamixer?
>>
>> Because alsamixer actually has support for one-sided muting.
>
> If that's unknown, I can post v9 without doing the grouping-together of mixer controls and we can use it like that - I don't want the patch to stall indefinitely on mere usability issues...
>
> Regards,
> Danny
>
> --
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

2016-03-14 10:49:50

by Maxime Ripard

[permalink] [raw]
Subject: Re: [linux-sunxi] Re: [PATCH v8 2/2] ASoc: sun4i-codec: Add FM, Line and Mic inputs

On Sat, Mar 12, 2016 at 08:52:22AM +0100, Danny Milosavljevic wrote:
> Hi,
>
> does anyone know the answer to the questions below?
>
> > The other direction (making two controls which both do the same and update
> > each other's value) doesn't seem to be easily available.
>
> > Should I write a _put handler that does it manually?
>
> > (Or should that be handled by alsa-lib mixer modules instead?)
>
> > Is it possible to merge the "Left Mixer" control and respective
> > "Right Mixer" control into one selem in alsamixer?
> >
> > Because alsamixer actually has support for one-sided muting.

Mark, do you know how to do it?

IIRC, in order to have shared controls, you just needed to share the
controls structure.

> If that's unknown, I can post v9 without doing the grouping-together
> of mixer controls and we can use it like that - I don't want the
> patch to stall indefinitely on mere usability issues...

Unfortunately, that is exposed to the user-space. Once it's in, you
cannot change it / fix it anymore.

Maxime

--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


Attachments:
(No filename) (1.12 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2016-03-15 10:59:00

by Mark Brown

[permalink] [raw]
Subject: Re: [linux-sunxi] Re: [PATCH v8 2/2] ASoc: sun4i-codec: Add FM, Line and Mic inputs

On Mon, Mar 14, 2016 at 11:49:39AM +0100, Maxime Ripard wrote:
> On Sat, Mar 12, 2016 at 08:52:22AM +0100, Danny Milosavljevic wrote:

> > > The other direction (making two controls which both do the same and update
> > > each other's value) doesn't seem to be easily available.

> > > Should I write a _put handler that does it manually?

> > > (Or should that be handled by alsa-lib mixer modules instead?)

> > > Is it possible to merge the "Left Mixer" control and respective
> > > "Right Mixer" control into one selem in alsamixer?

> > > Because alsamixer actually has support for one-sided muting.

> Mark, do you know how to do it?

> IIRC, in order to have shared controls, you just needed to share the
> controls structure.

I'm having a really hard time telling what "it" is here.


Attachments:
(No filename) (795.00 B)
signature.asc (473.00 B)
Download all attachments

2016-03-19 16:13:52

by Danny Milosavljevic

[permalink] [raw]
Subject: Re: [linux-sunxi] Re: [PATCH v8 2/2] ASoc: sun4i-codec: Add FM, Line and Mic inputs

Hi Mark,

my question is whether it's possible to group together the left and right channel into one selem, and also if it's possible to reuse volumes then. For example:

For sun4i-codec Mic there's right now:
- Left Mixer Mic1 Playback Switch
- Left Mixer Mic2 Playback Switch
- Right Mixer Mic1 Playback Switch
- Right Mixer Mic2 Playback Switch
- Mic Playback Volume

If possible, it could also then be collected together as:
- Mic1 Playback:
Left Mixer Mic1 Playback Switch,
Right Mixer Mic1 Playback Switch,
Mic Playback Volume
- Mic2 Playback:
Left Mixer Mic2 Playback Switch,
Right Mixer Mic2 Playback Switch,
Mic Playback Volume [note: there it is again]

... where each outer group (f.e. "- Mic1 Playback:") is a selem (slider with two mutes in alsamixer).

alsamixer has support for seperate left and right channel muting so it would cut down a lot on the number of visible controls.

But as you can see, Mic Playback Volume is also shared.

Is it possible to group them together like this? How?

Right now, while everything technically works, it's overwhelming to use alsamixer with sun4i-codec as a user - you have to *scroll* for quite a while.

Additionally, while I'm at it:

There's one capture volume right in front of the ADC. Whatever it is you capture, this tells you the gain for the ADC. But for some inputs, there are additional preamps. Right now in the v8 patch we don't distinguish between preamps and ADC gains (because I don't think it's possible), although the user has to kinda distinguish them in his head because for inputs which have preamps only the preamp and the adc gain *together* specify the total gain in the end.

E.g. in the hardware it's

Mic In -> | Mic Preamp | -> | ADC Gain | -> | ADC |

while in alsamixer it's:

[Capture Controls:]

| Mic Preamp | | Capture Volume | | xyz Preamp | | abc Preamp | | qrs Preamp |
^--- ADC Gain

Is it possible to somehow distinguish those in alsamixer? Do we want to?

2016-03-19 16:51:41

by Danny Milosavljevic

[permalink] [raw]
Subject: Re: [linux-sunxi] Re: [PATCH v8 2/2] ASoc: sun4i-codec: Add FM, Line and Mic inputs

Hi Maxime,

> IIRC, in order to have shared controls, you just needed to share the
> controls structure.

Yeah. I did this and it actually works in a way, but in doesn't do all that I want.

There are two different kinds of sharing I mean:

The one kind with the controls structure causes the control to rename itself
to not state its mixer but there's still just one slider in the end.
So instead of "Left Mixer Left XXX" it will just say "Left XXX" if you put it
inside Left Mixer and Right Mixer and share the entry - for this hardware,
that's of doubtful use.

But what I would like to have is that the same Mic Playback Volume (the very
same bits) be used for different sliders
(1) Mic1 Left Channel Playback Volume
(2) Mic1 Right Channel Playback Volume
(3) Mic2 Left Channel Playback Volume (!!)
(4) Mic2 Right Channel Playback Volume

Additionally, Mic1 Playback and Mic2 Playback have two mutes each in the
hardware (all separately switchable).

Now if we could make the alsamixer selems look like the following,
that would be nice:

Mic1_Playback Mic2_Playback

MM MM
ii ii
cc cc

PP PP
ll ll
aa aa
yy yy
bb bb
aa aa
cc cc
kk kk

VV VV
oo oo
ll ll
uu uu
mm mm
ee ee

[Mm] [Nn]
^ ^^-- so are those, separately
+-- this one is a different muter :-)

Where the text is the same, it's supposed to signify the same bits
in the hardware.

Right now in v8 it's (and that's going to take a lot of horizontal space,
sorry - I know E-Mails like this aren't so nice to read):

Mic_Playback_Volume Left_Mic1_Playback_Switch Right_Mic1_Playback_Switch Left_Mic2_Playback_Switch Right_Mic2_Playback_Switch

MM
ii
cc

PP
ll
aa
yy
bb
aa
cc
kk

VV
oo
ll
uu
mm
ee

[MM] [NN] [OO] [PP]
^- WTF ^- WTF ^- WTF ^- WTF

(Actually, it's worse - believe it or not, that's how the simplified explanation looks)

> Unfortunately, that is exposed to the user-space. Once it's in, you
> cannot change it / fix it anymore.

Hmm. Right. Let's get it to work nicely then.

2016-03-21 14:25:03

by Mark Brown

[permalink] [raw]
Subject: Re: [linux-sunxi] Re: [PATCH v8 2/2] ASoc: sun4i-codec: Add FM, Line and Mic inputs

On Sat, Mar 19, 2016 at 05:13:36PM +0100, Danny Milosavljevic wrote:
> Hi Mark,

> my question is whether it's possible to group together the left and right channel into one selem, and also if it's possible to reuse volumes then. For example:

Please fix your mail client to word wrap within paragraphs at something
substantially less than 80 columns. Doing this makes your messages much
easier to read and reply to. This is particularly important for large
walls of text like this.

> Is it possible to group them together like this? How?

This is something you'd need to change in alsamixer and the control
naming standards. None of this stuff is really supposed to be directly
edited by normal users, they should mostly be using a UCM configuration,
so at the minute this is essentially bikeshedding.

> Is it possible to somehow distinguish those in alsamixer? Do we want to?

I think you're looking for something that exports routing to userspace.
Doing that would also help with reducing the faff with naming rules.
Currently nobody is working on that but I think people would be very
happy if someone were to work on it.


Attachments:
(No filename) (1.10 kB)
signature.asc (473.00 B)
Download all attachments

2016-03-21 17:54:50

by Maxime Ripard

[permalink] [raw]
Subject: Re: [linux-sunxi] Re: [PATCH v8 2/2] ASoc: sun4i-codec: Add FM, Line and Mic inputs

On Sat, Mar 19, 2016 at 05:13:36PM +0100, Danny Milosavljevic wrote:
> Hi Mark,
>
> my question is whether it's possible to group together the left and
> right channel into one selem, and also if it's possible to reuse
> volumes then. For example:
>
> For sun4i-codec Mic there's right now:
> - Left Mixer Mic1 Playback Switch
> - Left Mixer Mic2 Playback Switch
> - Right Mixer Mic1 Playback Switch
> - Right Mixer Mic2 Playback Switch
> - Mic Playback Volume
>
> If possible, it could also then be collected together as:
> - Mic1 Playback:
> Left Mixer Mic1 Playback Switch,
> Right Mixer Mic1 Playback Switch,
> Mic Playback Volume
> - Mic2 Playback:
> Left Mixer Mic2 Playback Switch,
> Right Mixer Mic2 Playback Switch,
> Mic Playback Volume [note: there it is again]
>
> ... where each outer group (f.e. "- Mic1 Playback:") is a selem
> (slider with two mutes in alsamixer).
>
> alsamixer has support for seperate left and right channel muting so
> it would cut down a lot on the number of visible controls.
>
> But as you can see, Mic Playback Volume is also shared.
>
> Is it possible to group them together like this? How?
>
> Right now, while everything technically works, it's overwhelming to
> use alsamixer with sun4i-codec as a user - you have to *scroll* for
> quite a while.
>
> Additionally, while I'm at it:
>
> There's one capture volume right in front of the ADC. Whatever it is
> you capture, this tells you the gain for the ADC. But for some
> inputs, there are additional preamps. Right now in the v8 patch we
> don't distinguish between preamps and ADC gains (because I don't
> think it's possible), although the user has to kinda distinguish
> them in his head because for inputs which have preamps only the
> preamp and the adc gain *together* specify the total gain in the
> end.
>
> E.g. in the hardware it's
>
> Mic In -> | Mic Preamp | -> | ADC Gain | -> | ADC |
>
> while in alsamixer it's:
>
> [Capture Controls:]
>
> | Mic Preamp | | Capture Volume | | xyz Preamp | | abc Preamp | | qrs Preamp |
> ^--- ADC Gain
>
> Is it possible to somehow distinguish those in alsamixer? Do we want
> to?


As I recall it, we were mostly discussing the how to deal with the ADC
muxer that muxes both left and right at the same time (so shared
controls), but with different source on each channel.

For example, some valid values are:
4: left channel Mic 1, right channel mic 2
5: left and right channel are Mic1 and Mic2 mixed

As I understand it, you can have shared controls by sharing the
kcontrols structure, but then, you can't different labels.

Maxime

--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


Attachments:
(No filename) (2.69 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2016-03-21 18:06:24

by Maxime Ripard

[permalink] [raw]
Subject: Re: [linux-sunxi] Re: [PATCH v8 2/2] ASoc: sun4i-codec: Add FM, Line and Mic inputs

On Sat, Mar 19, 2016 at 05:51:24PM +0100, Danny Milosavljevic wrote:
> Hi Maxime,
>
> > IIRC, in order to have shared controls, you just needed to share the
> > controls structure.
>
> Yeah. I did this and it actually works in a way, but in doesn't do all that I want.
>
> There are two different kinds of sharing I mean:
>
> The one kind with the controls structure causes the control to rename itself
> to not state its mixer but there's still just one slider in the end.
> So instead of "Left Mixer Left XXX" it will just say "Left XXX" if you put it
> inside Left Mixer and Right Mixer and share the entry - for this hardware,
> that's of doubtful use.
>
> But what I would like to have is that the same Mic Playback Volume (the very
> same bits) be used for different sliders
> (1) Mic1 Left Channel Playback Volume
> (2) Mic1 Right Channel Playback Volume
> (3) Mic2 Left Channel Playback Volume (!!)
> (4) Mic2 Right Channel Playback Volume
>
> Additionally, Mic1 Playback and Mic2 Playback have two mutes each in the
> hardware (all separately switchable).
>
> Now if we could make the alsamixer selems look like the following,
> that would be nice:
>
> Mic1_Playback Mic2_Playback
>
> MM MM
> ii ii
> cc cc
>
> PP PP
> ll ll
> aa aa
> yy yy
> bb bb
> aa aa
> cc cc
> kk kk
>
> VV VV
> oo oo
> ll ll
> uu uu
> mm mm
> ee ee
>
> [Mm] [Nn]
> ^ ^^-- so are those, separately
> +-- this one is a different muter :-)
>
> Where the text is the same, it's supposed to signify the same bits
> in the hardware.
>
> Right now in v8 it's (and that's going to take a lot of horizontal space,
> sorry - I know E-Mails like this aren't so nice to read):
>
> Mic_Playback_Volume Left_Mic1_Playback_Switch Right_Mic1_Playback_Switch Left_Mic2_Playback_Switch Right_Mic2_Playback_Switch
>
> MM
> ii
> cc
>
> PP
> ll
> aa
> yy
> bb
> aa
> cc
> kk
>
> VV
> oo
> ll
> uu
> mm
> ee
>
> [MM] [NN] [OO] [PP]
> ^- WTF ^- WTF ^- WTF ^- WTF
>
> (Actually, it's worse - believe it or not, that's how the simplified explanation looks)

I don't think you should focus too much on alsamixer, there's other
tools to modify the configuration.

Maxime

--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


Attachments:
(No filename) (3.06 kB)
signature.asc (819.00 B)
Digital signature
Download all attachments

2016-03-21 18:19:18

by Mark Brown

[permalink] [raw]
Subject: Re: [linux-sunxi] Re: [PATCH v8 2/2] ASoc: sun4i-codec: Add FM, Line and Mic inputs

On Mon, Mar 21, 2016 at 07:06:05PM +0100, Maxime Ripard wrote:

> I don't think you should focus too much on alsamixer, there's other
> tools to modify the configuration.

The expectation is that most users will use something like UCM and only
system integrators will see the full control set in normal operation.


Attachments:
(No filename) (314.00 B)
signature.asc (473.00 B)
Download all attachments

2016-04-21 08:55:26

by Danny Milosavljevic

[permalink] [raw]
Subject: Re: [PATCH v8 2/2] ASoc: sun4i-codec: Add FM, Line and Mic inputs

Hi Maxime,

On Mon, 21 Mar 2016 18:54:36 +0100
Maxime Ripard <[email protected]> wrote:

> As I recall it, we were mostly discussing the how to deal with the ADC
> muxer that muxes both left and right at the same time (so shared
> controls), but with different source on each channel.

Hmm. Yeah, among other things.

I've used an enum control for that and the routes just enable the
right thing depending on the selected value (either "Mic1+Mic2" or
"Mic1" or "Mic2" or etcetc).

I think this part works fine in v8 - and is as nice as we can
reasonably do it.

-----

Also, for some outputs, there are multiple channels, multiple muters,
but just one playback volume (i.e. the volume is mono but the muters are
stereo AND possibly crossed over, see below).

It would have been possible to retain which channel is which in
the Mic Playback "volumes" - but not necessary.
Multiple muters exist there so it would just have been for consistency.

So let's just not retain that.

> As I understand it, you can have shared controls by sharing the
> kcontrols structure, but then, you can't different labels.

Yes. Because that's the case there's no upside in sharing the
Mic Playback Volume. Therefore, I've moved it back to the common controls
and made it just one control. At that point the user has to use UCM or
just notice that Mic Playback Volume changes the playback volume on all of:
- Left Mixer Mic1 Playback
- Left Mixer Mic2 Playback
- Right Mixer Mic1 Playback
- Right Mixer Mic2 Playback
(those four don't have sliders but physically output something if
individually unmuted).

(The downside of sharing the controls would be that the sharing
detection works by comparing the struct snd_kcontrol_new instance addresses.
Good luck in getting that to work in two struct snd_kcontrol_new[].
I did it before by merging the arrays and index gymnastics but I'd rather
not do it at all now. Note to self: there's a way to dynamically allocate
alsa controls)

----

Also, there's ADC Capture Volume: that one actually affects everything
that is captured, whatever the source. Now, the user has to know this. For
him, it looks as if Mic1 had its own capture volume ("Mic1 Capture Volume")
but that's actually the mic1 preamplifier gain which will be effectively
multiplied by the ADC Capture Volume in the data he gets.

In the long term I think it would be nice if userspace could see the routes.

----

Then, on my hardware there's destructive interference when I enable the DAC->PA and
the Mixer->PA and also enable the DAC->Mixer, to get:

- DAC->PA
- DAC->Mixer->PA

Currently, the user is not prevented from doing this, however it will result
in no perceptible PA sound when he sends something to the DAC.

Is that fine?

----

If all these points are fine like that then let's do it like that.

I'll send a v9 patch along these lines.

Thanks,
Danny