[alsa-devel] [PATCH] snd-sbxfi: implement Master volume control
Unfortunately, the X-Fi does not have a hardware master volume control, so we have to create a virtual master and bind all playback controls to it.
This patch depends on the patch that renames Master to PCM.
Signed-off-by: William Pitcock nenolod@sacredspiral.co.uk --- sound/pci/sbxfi/sbxfi.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/sound/pci/sbxfi/sbxfi.c b/sound/pci/sbxfi/sbxfi.c index 3e99a97..d8b32aa 100644 --- a/sound/pci/sbxfi/sbxfi.c +++ b/sound/pci/sbxfi/sbxfi.c @@ -1685,15 +1685,45 @@ static struct snd_kcontrol_new mixers[] __devinitdata = { }, };
+/* list of controls to attach to the master volume control. */ +static const char *slave_vols[] __devinitdata = { + "PCM Playback Volume", +}; + static int __devinit sbxfi_create_mixer(struct sbxfi *chip) { int i, err; + struct snd_kcontrol *vmaster;
for (i = 0; i < ARRAY_SIZE(mixers); i++) { err = snd_ctl_add(chip->card, snd_ctl_new1(&mixers[i], chip)); if (err < 0) return err; } + + /* + * Unfortunately, it seems that there is no master control, unlike + * on the emu10k1 series, so we create a virtual master, and bind + * our playback controls to it. + */ + vmaster = snd_ctl_make_virtual_master("Master Playback Volume", NULL); + if (vmaster == NULL) + return -ENOMEM; + + /* attach the master to the card, and attach all slaves to it. */ + snd_ctl_add(chip->card, vmaster); + for (i = 0; i < ARRAY_SIZE(slave_vols); i++) { + struct snd_kcontrol *slave; + struct snd_ctl_elem_id sid; + + memset(&sid, 0, sizeof(sid)); + strlcpy(sid.name, slave_vols[i], 44); /* XXX this should be a constant defined somewhere */ + sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER; + + if ((slave = snd_ctl_find_id(chip->card, &sid)) != NULL) + snd_ctl_add_slave(vmaster, slave); + } + return 0; }
At Sun, 19 Oct 2008 18:08:15 -0500, William Pitcock wrote:
Unfortunately, the X-Fi does not have a hardware master volume control, so we have to create a virtual master and bind all playback controls to it.
This patch depends on the patch that renames Master to PCM.
Signed-off-by: William Pitcock nenolod@sacredspiral.co.uk
I don't like this patch because the virtual master implementation is already found in sbxfi.c No reason to use yet another vmaster framework in addition.
So, no I don't apply both patches. A simpler fix is just to add PCM volume like Master volume. Both can use the same callbacks, so the addition would be pretty small.
thanks,
Takashi
sound/pci/sbxfi/sbxfi.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/sound/pci/sbxfi/sbxfi.c b/sound/pci/sbxfi/sbxfi.c index 3e99a97..d8b32aa 100644 --- a/sound/pci/sbxfi/sbxfi.c +++ b/sound/pci/sbxfi/sbxfi.c @@ -1685,15 +1685,45 @@ static struct snd_kcontrol_new mixers[] __devinitdata = { }, };
+/* list of controls to attach to the master volume control. */ +static const char *slave_vols[] __devinitdata = {
- "PCM Playback Volume",
+};
static int __devinit sbxfi_create_mixer(struct sbxfi *chip) { int i, err;
struct snd_kcontrol *vmaster;
for (i = 0; i < ARRAY_SIZE(mixers); i++) { err = snd_ctl_add(chip->card, snd_ctl_new1(&mixers[i], chip)); if (err < 0) return err; }
/*
* Unfortunately, it seems that there is no master control, unlike
* on the emu10k1 series, so we create a virtual master, and bind
* our playback controls to it.
*/
vmaster = snd_ctl_make_virtual_master("Master Playback Volume", NULL);
if (vmaster == NULL)
return -ENOMEM;
/* attach the master to the card, and attach all slaves to it. */
snd_ctl_add(chip->card, vmaster);
for (i = 0; i < ARRAY_SIZE(slave_vols); i++) {
struct snd_kcontrol *slave;
struct snd_ctl_elem_id sid;
memset(&sid, 0, sizeof(sid));
strlcpy(sid.name, slave_vols[i], 44); /* XXX this should be a constant defined somewhere */
sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
if ((slave = snd_ctl_find_id(chip->card, &sid)) != NULL)
snd_ctl_add_slave(vmaster, slave);
}
return 0;
}
-- 1.5.5.4
At Mon, 20 Oct 2008 07:59:32 +0200, I wrote:
At Sun, 19 Oct 2008 18:08:15 -0500, William Pitcock wrote:
Unfortunately, the X-Fi does not have a hardware master volume control, so we have to create a virtual master and bind all playback controls to it.
This patch depends on the patch that renames Master to PCM.
Signed-off-by: William Pitcock nenolod@sacredspiral.co.uk
I don't like this patch because the virtual master implementation is already found in sbxfi.c No reason to use yet another vmaster framework in addition.
So, no I don't apply both patches. A simpler fix is just to add PCM volume like Master volume. Both can use the same callbacks, so the addition would be pretty small.
I added PCM volume now using the same mechanism as Master volume. Please give it a try, and let me know if it's broken.
thanks,
Takashi
Takashi Iwai wrote:
At Mon, 20 Oct 2008 07:59:32 +0200, I wrote:
At Sun, 19 Oct 2008 18:08:15 -0500, William Pitcock wrote:
Unfortunately, the X-Fi does not have a hardware master volume control, so we have to create a virtual master and bind all playback controls to it.
This patch depends on the patch that renames Master to PCM.
Signed-off-by: William Pitcock nenolod@sacredspiral.co.uk
I don't like this patch because the virtual master implementation is already found in sbxfi.c No reason to use yet another vmaster framework in addition.
So, no I don't apply both patches. A simpler fix is just to add PCM volume like Master volume. Both can use the same callbacks, so the addition would be pretty small.
I added PCM volume now using the same mechanism as Master volume. Please give it a try, and let me know if it's broken.
The last version from git is again, not working for me.
To make it work the following fixes are needed: The correct option for the ratec is SRCCTL_STATE_INIT, not SRCCTL_STATE_TAIL.
--- sbxfi.c.ori 2008-10-20 14:13:53.000000000 +0200 +++ sbxfi.c 2008-10-20 14:18:06.000000000 +0200 @@ -542,7 +542,7 @@ } ratec |= SRCCTL_FMT_S16; ratec |= SRCCTL_BUS_MASTER; - ratec |= SRCCTL_STATE_TAIL; + ratec |= SRCCTL_STATE_INIT;
ctrl = ratec; ctrl |= SRCCTL_PITCH_MASTER; /* master */
Also for some strange and for me unknown reason the patch "ALSA: snd-sbxfi: use SBXXXX model numbers instead of user-unfriendly names like UAA and ORIG." broke sound output, too. Reverting it and applying the patch above fixes the driver for me.
At Mon, 20 Oct 2008 12:21:47 +0000, Xarteras wrote:
Takashi Iwai wrote:
At Mon, 20 Oct 2008 07:59:32 +0200, I wrote:
At Sun, 19 Oct 2008 18:08:15 -0500, William Pitcock wrote:
Unfortunately, the X-Fi does not have a hardware master volume control, so we have to create a virtual master and bind all playback controls to it.
This patch depends on the patch that renames Master to PCM.
Signed-off-by: William Pitcock nenolod@sacredspiral.co.uk
I don't like this patch because the virtual master implementation is already found in sbxfi.c No reason to use yet another vmaster framework in addition.
So, no I don't apply both patches. A simpler fix is just to add PCM volume like Master volume. Both can use the same callbacks, so the addition would be pretty small.
I added PCM volume now using the same mechanism as Master volume. Please give it a try, and let me know if it's broken.
The last version from git is again, not working for me.
To make it work the following fixes are needed: The correct option for the ratec is SRCCTL_STATE_INIT, not SRCCTL_STATE_TAIL.
--- sbxfi.c.ori 2008-10-20 14:13:53.000000000 +0200 +++ sbxfi.c 2008-10-20 14:18:06.000000000 +0200 @@ -542,7 +542,7 @@ } ratec |= SRCCTL_FMT_S16; ratec |= SRCCTL_BUS_MASTER;
ratec |= SRCCTL_STATE_TAIL;
ratec |= SRCCTL_STATE_INIT; ctrl = ratec; ctrl |= SRCCTL_PITCH_MASTER; /* master */
Oops, thanks for checking it. Will fix it now.
Also for some strange and for me unknown reason the patch "ALSA: snd-sbxfi: use SBXXXX model numbers instead of user-unfriendly names like UAA and ORIG." broke sound output, too. Reverting it and applying the patch above fixes the driver for me.
Hm, it's weird. Checking now...
Takashi
At Mon, 20 Oct 2008 14:25:34 +0200, I wrote:
At Mon, 20 Oct 2008 12:21:47 +0000, Xarteras wrote:
Takashi Iwai wrote:
At Mon, 20 Oct 2008 07:59:32 +0200, I wrote:
At Sun, 19 Oct 2008 18:08:15 -0500, William Pitcock wrote:
Unfortunately, the X-Fi does not have a hardware master volume control, so we have to create a virtual master and bind all playback controls to it.
This patch depends on the patch that renames Master to PCM.
Signed-off-by: William Pitcock nenolod@sacredspiral.co.uk
I don't like this patch because the virtual master implementation is already found in sbxfi.c No reason to use yet another vmaster framework in addition.
So, no I don't apply both patches. A simpler fix is just to add PCM volume like Master volume. Both can use the same callbacks, so the addition would be pretty small.
I added PCM volume now using the same mechanism as Master volume. Please give it a try, and let me know if it's broken.
The last version from git is again, not working for me.
To make it work the following fixes are needed: The correct option for the ratec is SRCCTL_STATE_INIT, not SRCCTL_STATE_TAIL.
--- sbxfi.c.ori 2008-10-20 14:13:53.000000000 +0200 +++ sbxfi.c 2008-10-20 14:18:06.000000000 +0200 @@ -542,7 +542,7 @@ } ratec |= SRCCTL_FMT_S16; ratec |= SRCCTL_BUS_MASTER;
ratec |= SRCCTL_STATE_TAIL;
ratec |= SRCCTL_STATE_INIT; ctrl = ratec; ctrl |= SRCCTL_PITCH_MASTER; /* master */
Oops, thanks for checking it. Will fix it now.
Fixed and pushed out.
Also for some strange and for me unknown reason the patch "ALSA: snd-sbxfi: use SBXXXX model numbers instead of user-unfriendly names like UAA and ORIG." broke sound output, too. Reverting it and applying the patch above fixes the driver for me.
Hm, it's weird. Checking now...
Maybe the id string was changed by the patch unexpectedly? Check /proc/asound/cards output before and after the patch. If so, it's because the mixer setting was lost and not restored via alsactl due to the renaming of the id string. Re-adjust the mixer setting again.
Takashi
Takashi Iwai wrote:
At Mon, 20 Oct 2008 14:25:34 +0200, I wrote:
At Mon, 20 Oct 2008 12:21:47 +0000, Xarteras wrote:
Takashi Iwai wrote:
At Mon, 20 Oct 2008 07:59:32 +0200, I wrote:
At Sun, 19 Oct 2008 18:08:15 -0500, William Pitcock wrote:
Unfortunately, the X-Fi does not have a hardware master volume control, so we have to create a virtual master and bind all playback controls to it.
This patch depends on the patch that renames Master to PCM.
Signed-off-by: William Pitcock nenolod@sacredspiral.co.uk
I don't like this patch because the virtual master implementation is already found in sbxfi.c No reason to use yet another vmaster framework in addition.
So, no I don't apply both patches. A simpler fix is just to add PCM volume like Master volume. Both can use the same callbacks, so the addition would be pretty small.
I added PCM volume now using the same mechanism as Master volume. Please give it a try, and let me know if it's broken.
The last version from git is again, not working for me.
To make it work the following fixes are needed: The correct option for the ratec is SRCCTL_STATE_INIT, not SRCCTL_STATE_TAIL.
--- sbxfi.c.ori 2008-10-20 14:13:53.000000000 +0200 +++ sbxfi.c 2008-10-20 14:18:06.000000000 +0200 @@ -542,7 +542,7 @@ } ratec |= SRCCTL_FMT_S16; ratec |= SRCCTL_BUS_MASTER;
ratec |= SRCCTL_STATE_TAIL;
ratec |= SRCCTL_STATE_INIT; ctrl = ratec; ctrl |= SRCCTL_PITCH_MASTER; /* master */
Oops, thanks for checking it. Will fix it now.
Fixed and pushed out.
Also for some strange and for me unknown reason the patch "ALSA: snd-sbxfi: use SBXXXX model numbers instead of user-unfriendly names like UAA and ORIG." broke sound output, too. Reverting it and applying the patch above fixes the driver for me.
Hm, it's weird. Checking now...
Maybe the id string was changed by the patch unexpectedly? Check /proc/asound/cards output before and after the patch. If so, it's because the mixer setting was lost and not restored via alsactl due to the renaming of the id string. Re-adjust the mixer setting again.
Whoops, don't know how I could miss that. It works now with the new IDs, thanks :)
Jan Wolf
participants (3)
-
Takashi Iwai
-
William Pitcock
-
Xarteras