Hi,
I have connect a MAX98357A over SAI3 to an i.MX8. I use the simple-card driver. Everything works. I get sound when I use aplay or gplay. But I wonder when I open alsamixer BEFORE using aplay or gplay I got the message "This sound device does not have any controls"
If I start alsamixer AFTER I used aplay or gplay I can see the Master volume control.
I don't understand why!
My .asoundrc
cat .asoundrc
pcm.!default {
type plug
slave.pcm "softvol"
}
ctl.!default {
type hw
card MAX98357A
}
pcm.mycard {
type hw
card MAX98357A
}
pcm.softvol {
type softvol
slave {
pcm "mycard"
}
control {
name "Master"
card MAX98357A
}
max_dB 20.0
min_dB -51.0
}
Is there a mistake in my .asoundrc?
已解决! 转到解答。
It found out that is enough to call the function snd_pcm_open(). So I wrote a small program to "activate" the softvol mixer.
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <alsa/asoundlib.h>
static char *device = "default"; /* playback device */
int main(int argc, char *argv[]) {
snd_pcm_t *handle;
int err;
printf("Enable sofvol plugin\n");
if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
printf("Playback open error: %d,%s\n", err,snd_strerror(err));
exit(EXIT_FAILURE);
}
snd_pcm_close(handle);
exit(EXIT_SUCCESS);
}
After calling you request the current volume level.
I found the answer in another forum.
The mixer will not show up until it is used for the first time. Per alsa.opensrc.org:
Note: The new volume control won't appear immediately! Only after the first usage of the newly defined device (e.g. with the command above), should amixer controls | grep <control name> display your new control. Mixers that were already started before the first usage (like KMix) have to be restarted to adopt the changes. If you still don't see the new control, try restarting ALSA or your PC.
Since your config sets the default to the softvol device, running speaker-test or using aplay to play a .wav file should be sufficient to make the volume control appear.
It's a pitty because I can't get the current volume value until I run speaker-test or aplay.
It found out that is enough to call the function snd_pcm_open(). So I wrote a small program to "activate" the softvol mixer.
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <alsa/asoundlib.h>
static char *device = "default"; /* playback device */
int main(int argc, char *argv[]) {
snd_pcm_t *handle;
int err;
printf("Enable sofvol plugin\n");
if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
printf("Playback open error: %d,%s\n", err,snd_strerror(err));
exit(EXIT_FAILURE);
}
snd_pcm_close(handle);
exit(EXIT_SUCCESS);
}
After calling you request the current volume level.