Add a new API for soundcards that have hardware volume control:
- The mixer_hwmute() function can be called when a soundcard receives a mute request. - The mixer_hwstep() function can be used to adjust the volume of one or both channels. - The 'hw.snd.hwvol_step' sysctl determines the amount that mixer_hwstep() adjusts the volume by on each call. - The 'hw.snd.hwvol_mixer' sysctl specifies the mixer device to adjust the volume on for both functions. The values used correspond to the SOUNDCARD_MIXER_* constants.
This commit is contained in:
parent
b3b7ccfe38
commit
d0d4e34743
@ -254,6 +254,42 @@ mixer_ioctl(snddev_info *d, u_long cmd, caddr_t arg)
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
static int hwvol_step = 5;
|
||||
SYSCTL_INT(_hw_snd, OID_AUTO, hwvol_step, CTLFLAG_RW, &hwvol_step, 0, "");
|
||||
|
||||
static int hwvol_mixer = SOUND_MIXER_VOLUME;
|
||||
SYSCTL_INT(_hw_snd, OID_AUTO, hwvol_mixer, CTLFLAG_RW, &hwvol_mixer, 0, "");
|
||||
|
||||
void
|
||||
mixer_hwmute(device_t dev)
|
||||
{
|
||||
snddev_info *d;
|
||||
|
||||
d = device_get_softc(dev);
|
||||
mixer_set(d->mixer, hwvol_mixer, 0);
|
||||
}
|
||||
|
||||
void
|
||||
mixer_hwstep(device_t dev, int left_step, int right_step)
|
||||
{
|
||||
snddev_info *d;
|
||||
int level, left, right;
|
||||
|
||||
d = device_get_softc(dev);
|
||||
level = mixer_get(d->mixer, hwvol_mixer);
|
||||
if (level != -1) {
|
||||
left = level & 0xff;
|
||||
right = level >> 8;
|
||||
left += left_step * hwvol_step;
|
||||
if (left < 0)
|
||||
left = 0;
|
||||
right += right_step * hwvol_step;
|
||||
if (right < 0)
|
||||
right = 0;
|
||||
mixer_set(d->mixer, hwvol_mixer, left | right << 8);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The various mixers use a variety of bitmasks etc. The Voxware
|
||||
* driver had a very nice technique to describe a mixer and interface
|
||||
|
@ -33,6 +33,9 @@ extern int mixer_ioctl(snddev_info *d, u_long cmd, caddr_t arg);
|
||||
extern int mixer_busy(snd_mixer *m, int busy);
|
||||
extern int mixer_isbusy(snd_mixer *m);
|
||||
|
||||
void mixer_hwmute(device_t dev);
|
||||
void mixer_hwstep(device_t dev, int left_step, int right_step);
|
||||
|
||||
extern void change_bits(mixer_tab *t, u_char *regval, int dev, int chn, int newval);
|
||||
|
||||
void mix_setdevs(snd_mixer *m, u_int32_t v);
|
||||
|
Loading…
Reference in New Issue
Block a user