All of lore.kernel.org
 help / color / mirror / Atom feed
* Softvol only after device has opened
@ 2015-06-09 11:08 Ricard Wanderlof
  2015-06-09 11:52 ` Clemens Ladisch
  0 siblings, 1 reply; 11+ messages in thread
From: Ricard Wanderlof @ 2015-06-09 11:08 UTC (permalink / raw)
  To: alsa-devel


I'm working on implementing support for a MEMS microphone with an I2S 
connection. Since the microphone has no controls but simply outputs I2S 
data from the word go, this means that any gain must be applied later. 
(Microphones of this type are generally specified at outputting 0 dB FS at 
some rediculously high SPL, 120 dB SPL being typical). 

Since we use 16 bit audio in our (SOC) system, I'm trying to apply gain 
using the softvol ALSA plugin, before converting to 16 bit audio (the 
microphone outputs 24 bit audio).

One thing though, the 'softvol' plugin very correctly creates a mixer
control and it all works fine, but only after the device has been opened.
Before that the mixer control doesn't seem to exist, which means that we
cannot adjust the gain until the device is opened by some application.

Is this intentional, a bug, or something that is misconfigured on my part?

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Softvol only after device has opened
  2015-06-09 11:08 Softvol only after device has opened Ricard Wanderlof
@ 2015-06-09 11:52 ` Clemens Ladisch
  2015-06-09 12:19   ` Ricard Wanderlof
  0 siblings, 1 reply; 11+ messages in thread
From: Clemens Ladisch @ 2015-06-09 11:52 UTC (permalink / raw)
  To: Ricard Wanderlof, alsa-devel

Ricard Wanderlof wrote:
> One thing though, the 'softvol' plugin very correctly creates a mixer
> control and it all works fine, but only after the device has been opened.
> Before that the mixer control doesn't seem to exist, which means that we
> cannot adjust the gain until the device is opened by some application.

Before a device using a plugin is opened, no code from that plugin is
run.

Anyway, softvol mixer controls can be saved and restored with the usual
"alsactl store" and "alsactl restore" mechanism.  If you do not want to
save all mixer controls, or if your system does not have nonvolatile
storage, create a file containing only that control and tell alsactl to
restore from it.


Regards,
Clemens

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Softvol only after device has opened
  2015-06-09 11:52 ` Clemens Ladisch
@ 2015-06-09 12:19   ` Ricard Wanderlof
  2015-06-09 12:21     ` Clemens Ladisch
  0 siblings, 1 reply; 11+ messages in thread
From: Ricard Wanderlof @ 2015-06-09 12:19 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel@alsa-project.org


On Tue, 9 Jun 2015, Clemens Ladisch wrote:

> Ricard Wanderlof wrote:
> > One thing though, the 'softvol' plugin very correctly creates a mixer
> > control and it all works fine, but only after the device has been opened.
> > Before that the mixer control doesn't seem to exist, which means that we
> > cannot adjust the gain until the device is opened by some application.
> 
> Before a device using a plugin is opened, no code from that plugin is
> run.
> 
> Anyway, softvol mixer controls can be saved and restored with the usual
> "alsactl store" and "alsactl restore" mechanism.  If you do not want to
> save all mixer controls, or if your system does not have nonvolatile
> storage, create a file containing only that control and tell alsactl to
> restore from it.

Can "alsactl restore" be run before the device is opened then?

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Softvol only after device has opened
  2015-06-09 12:19   ` Ricard Wanderlof
@ 2015-06-09 12:21     ` Clemens Ladisch
  2015-06-09 12:32       ` Ricard Wanderlof
  0 siblings, 1 reply; 11+ messages in thread
From: Clemens Ladisch @ 2015-06-09 12:21 UTC (permalink / raw)
  To: Ricard Wanderlof; +Cc: alsa-devel@alsa-project.org

Ricard Wanderlof wrote:
> Can "alsactl restore" be run before the device is opened then?

Many distributions run "alsactl restore" in some startup script.
You can execute it yourself whenever you want.


Regards,
Clemens

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Softvol only after device has opened
  2015-06-09 12:21     ` Clemens Ladisch
@ 2015-06-09 12:32       ` Ricard Wanderlof
  2015-06-09 12:39         ` Clemens Ladisch
  0 siblings, 1 reply; 11+ messages in thread
From: Ricard Wanderlof @ 2015-06-09 12:32 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: Ricard Wanderlöf, alsa-devel@alsa-project.org


On Tue, 9 Jun 2015, Clemens Ladisch wrote:

> Ricard Wanderlof wrote:
> > Can "alsactl restore" be run before the device is opened then?
> 
> Many distributions run "alsactl restore" in some startup script.
> You can execute it yourself whenever you want.

What I was getting at was that although I can't do:

$ amixer sset Capture 192 

if Capture is defined by the softvol plugin, and I haven't opened the 
device prior to running amixer, however

$ alsactl restore 0:

works, assuming that I've saved the settings previously, even before the 
device is opened. I can understand that this is very useful and desired, 
but given that the underlying control does not yet exist, it puzzles me 
that it actually works.

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Softvol only after device has opened
  2015-06-09 12:32       ` Ricard Wanderlof
@ 2015-06-09 12:39         ` Clemens Ladisch
  2015-06-09 14:32           ` Ricard Wanderlof
  0 siblings, 1 reply; 11+ messages in thread
From: Clemens Ladisch @ 2015-06-09 12:39 UTC (permalink / raw)
  To: Ricard Wanderlof; +Cc: alsa-devel@alsa-project.org

Ricard Wanderlof wrote:
> What I was getting at was that although I can't do:
>
> $ amixer sset Capture 192
>
> if Capture is defined by the softvol plugin, and I haven't opened the
> device prior to running amixer, however
>
> $ alsactl restore 0:
>
> works, assuming that I've saved the settings previously, even before the
> device is opened. I can understand that this is very useful and desired,
> but given that the underlying control does not yet exist, it puzzles me
> that it actually works.

Have a look at /var/lib/asound.state.  "alsactl store" marks any user-
space controls; when "alsactl restore" sees this flag, it will explicitly
recreate the control.


Regards,
Clemens

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Softvol only after device has opened
  2015-06-09 12:39         ` Clemens Ladisch
@ 2015-06-09 14:32           ` Ricard Wanderlof
  2015-06-09 14:38             ` Takashi Iwai
  0 siblings, 1 reply; 11+ messages in thread
From: Ricard Wanderlof @ 2015-06-09 14:32 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel@alsa-project.org


On Tue, 9 Jun 2015, Clemens Ladisch wrote:

> Ricard Wanderlof wrote:
> > What I was getting at was that although I can't do:
> >
> > $ amixer sset Capture 192
> >
> > if Capture is defined by the softvol plugin, and I haven't opened the
> > device prior to running amixer, however
> >
> > $ alsactl restore 0:
> >
> > works, assuming that I've saved the settings previously, even before the
> > device is opened. I can understand that this is very useful and desired,
> > but given that the underlying control does not yet exist, it puzzles me
> > that it actually works.
> 
> Have a look at /var/lib/asound.state.  "alsactl store" marks any user-
> space controls; when "alsactl restore" sees this flag, it will explicitly
> recreate the control.

And there is no other way to recreate the control using an application 
than to use alsactl then?

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Softvol only after device has opened
  2015-06-09 14:32           ` Ricard Wanderlof
@ 2015-06-09 14:38             ` Takashi Iwai
  2015-06-09 14:45               ` Ricard Wanderlof
  0 siblings, 1 reply; 11+ messages in thread
From: Takashi Iwai @ 2015-06-09 14:38 UTC (permalink / raw)
  To: Ricard Wanderlof; +Cc: alsa-devel@alsa-project.org, Clemens Ladisch

At Tue, 9 Jun 2015 16:32:35 +0200,
Ricard Wanderlof wrote:
> 
> 
> On Tue, 9 Jun 2015, Clemens Ladisch wrote:
> 
> > Ricard Wanderlof wrote:
> > > What I was getting at was that although I can't do:
> > >
> > > $ amixer sset Capture 192
> > >
> > > if Capture is defined by the softvol plugin, and I haven't opened the
> > > device prior to running amixer, however
> > >
> > > $ alsactl restore 0:
> > >
> > > works, assuming that I've saved the settings previously, even before the
> > > device is opened. I can understand that this is very useful and desired,
> > > but given that the underlying control does not yet exist, it puzzles me
> > > that it actually works.
> > 
> > Have a look at /var/lib/asound.state.  "alsactl store" marks any user-
> > space controls; when "alsactl restore" sees this flag, it will explicitly
> > recreate the control.
> 
> And there is no other way to recreate the control using an application 
> than to use alsactl then?

There is other way, of course.  It's no magic.  alsactl just creates a
user-space control element using the normal API.


Takashi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Softvol only after device has opened
  2015-06-09 14:38             ` Takashi Iwai
@ 2015-06-09 14:45               ` Ricard Wanderlof
  2015-06-09 14:51                 ` Takashi Iwai
  0 siblings, 1 reply; 11+ messages in thread
From: Ricard Wanderlof @ 2015-06-09 14:45 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel@alsa-project.org, Clemens Ladisch


On Tue, 9 Jun 2015, Takashi Iwai wrote:

> > > Have a look at /var/lib/asound.state.  "alsactl store" marks any user-
> > > space controls; when "alsactl restore" sees this flag, it will explicitly
> > > recreate the control.
> > 
> > And there is no other way to recreate the control using an application 
> > than to use alsactl then?
> 
> There is other way, of course.  It's no magic.  alsactl just creates a
> user-space control element using the normal API.

Yes, of course that's doable, I was wondering if there's some other 
application that I don't know about that could do it. I.e. if there's a 
startup script that normally uses amixer to set up default settings, is it 
possible to add something to that script rather than to write a separate 
application to create the user control, which of course is doable too.

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Softvol only after device has opened
  2015-06-09 14:45               ` Ricard Wanderlof
@ 2015-06-09 14:51                 ` Takashi Iwai
  2015-06-09 15:53                   ` Ricard Wanderlof
  0 siblings, 1 reply; 11+ messages in thread
From: Takashi Iwai @ 2015-06-09 14:51 UTC (permalink / raw)
  To: Ricard Wanderlof; +Cc: alsa-devel@alsa-project.org, Clemens Ladisch

At Tue, 9 Jun 2015 16:45:32 +0200,
Ricard Wanderlof wrote:
> 
> 
> On Tue, 9 Jun 2015, Takashi Iwai wrote:
> 
> > > > Have a look at /var/lib/asound.state.  "alsactl store" marks any user-
> > > > space controls; when "alsactl restore" sees this flag, it will explicitly
> > > > recreate the control.
> > > 
> > > And there is no other way to recreate the control using an application 
> > > than to use alsactl then?
> > 
> > There is other way, of course.  It's no magic.  alsactl just creates a
> > user-space control element using the normal API.
> 
> Yes, of course that's doable, I was wondering if there's some other 
> application that I don't know about that could do it. I.e. if there's a 
> startup script that normally uses amixer to set up default settings, is it 
> possible to add something to that script rather than to write a separate 
> application to create the user control, which of course is doable too.

Just open PCM once and close.  That should suffice :)

Other than that, an easy way is to run alsactl restore with a snippet
of user-space ctl element definition as Clemens suggested.


Takashi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Softvol only after device has opened
  2015-06-09 14:51                 ` Takashi Iwai
@ 2015-06-09 15:53                   ` Ricard Wanderlof
  0 siblings, 0 replies; 11+ messages in thread
From: Ricard Wanderlof @ 2015-06-09 15:53 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel@alsa-project.org, Clemens Ladisch


On Tue, 9 Jun 2015, Takashi Iwai wrote:

> > > There is other way, of course.  It's no magic.  alsactl just creates a
> > > user-space control element using the normal API.
> > 
> > Yes, of course that's doable, I was wondering if there's some other 
> > application that I don't know about that could do it. I.e. if there's a 
> > startup script that normally uses amixer to set up default settings, is it 
> > possible to add something to that script rather than to write a separate 
> > application to create the user control, which of course is doable too.
> 
> Just open PCM once and close.  That should suffice :)
> 
> Other than that, an easy way is to run alsactl restore with a snippet
> of user-space ctl element definition as Clemens suggested.

Ok. Thanks!

/Ricard
-- 
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-06-09 15:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-09 11:08 Softvol only after device has opened Ricard Wanderlof
2015-06-09 11:52 ` Clemens Ladisch
2015-06-09 12:19   ` Ricard Wanderlof
2015-06-09 12:21     ` Clemens Ladisch
2015-06-09 12:32       ` Ricard Wanderlof
2015-06-09 12:39         ` Clemens Ladisch
2015-06-09 14:32           ` Ricard Wanderlof
2015-06-09 14:38             ` Takashi Iwai
2015-06-09 14:45               ` Ricard Wanderlof
2015-06-09 14:51                 ` Takashi Iwai
2015-06-09 15:53                   ` Ricard Wanderlof

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.