Use standard pcm_get/setflags() rather than dereferencing softc while

enabling SD_F_SOFTPCMVOL or any flags.
This commit is contained in:
Ariff Abdullah 2007-06-02 17:28:26 +00:00
parent e9577a5cd9
commit e510f52136
4 changed files with 26 additions and 41 deletions
sys/dev/sound

@ -1836,7 +1836,6 @@ static int
envy24htmixer_init(struct snd_mixer *m)
{
struct sc_info *sc = mix_getdevinfo(m);
struct snddev_info *d;
#if(0)
device_printf(sc->dev, "envy24htmixer_init()\n");
@ -1850,9 +1849,7 @@ envy24htmixer_init(struct snd_mixer *m)
envy24ht_wrmt(sc, ENVY24HT_MT_VOLRATE, 0x30, 1); /* 0x30 is default value */
#endif
d = device_get_softc(sc->dev);
if (d != NULL)
d->flags |= SD_F_SOFTPCMVOL;
pcm_setflags(sc->dev, pcm_getflags(sc->dev) | SD_F_SOFTPCMVOL);
mix_setdevs(m, ENVY24HT_MIX_MASK);
mix_setrecdevs(m, ENVY24HT_MIX_REC_MASK);

@ -3309,17 +3309,13 @@ hdac_audio_ctl_ossmixer_init(struct snd_mixer *m)
}
if (softpcmvol == 1 || ctl == NULL) {
struct snddev_info *d = NULL;
d = device_get_softc(sc->dev);
if (d != NULL) {
d->flags |= SD_F_SOFTPCMVOL;
HDA_BOOTVERBOSE(
device_printf(sc->dev,
"HDA_DEBUG: %s Soft PCM volume\n",
(softpcmvol == 1) ?
"Forcing" : "Enabling");
);
}
pcm_setflags(sc->dev, pcm_getflags(sc->dev) | SD_F_SOFTPCMVOL);
HDA_BOOTVERBOSE(
device_printf(sc->dev,
"HDA_DEBUG: %s Soft PCM volume\n",
(softpcmvol == 1) ?
"Forcing" : "Enabling");
);
i = 0;
/*
* XXX Temporary quirk for STAC9220, until the parser

@ -922,7 +922,6 @@ static int
ac97mix_init(struct snd_mixer *m)
{
struct ac97_info *codec = mix_getdevinfo(m);
struct snddev_info *d;
u_int32_t i, mask;
if (codec == NULL)
@ -964,9 +963,8 @@ ac97mix_init(struct snd_mixer *m)
ac97_wrcd(codec, AC97_MIX_PCM, 0);
bzero(&codec->mix[SOUND_MIXER_PCM],
sizeof(codec->mix[SOUND_MIXER_PCM]));
d = device_get_softc(codec->dev);
if (d != NULL)
d->flags |= SD_F_SOFTPCMVOL;
pcm_setflags(codec->dev, pcm_getflags(codec->dev) |
SD_F_SOFTPCMVOL);
/* XXX How about master volume ? */
break;
default:

@ -274,27 +274,22 @@ ua_mixer_init(struct snd_mixer *m)
{
u_int32_t mask;
device_t pa_dev;
struct snddev_info *d;
struct ua_info *ua = mix_getdevinfo(m);
pa_dev = device_get_parent(ua->sc_dev);
d = device_get_softc(ua->sc_dev);
mask = uaudio_query_mix_info(pa_dev);
if (d != NULL) {
if (!(mask & SOUND_MASK_PCM)) {
/*
* Emulate missing pcm mixer controller
* through FEEDER_VOLUME
*/
d->flags |= SD_F_SOFTPCMVOL;
}
if (!(mask & SOUND_MASK_VOLUME)) {
mix_setparentchild(m, SOUND_MIXER_VOLUME,
SOUND_MASK_PCM);
mix_setrealdev(m, SOUND_MIXER_VOLUME,
SOUND_MIXER_NONE);
}
if (!(mask & SOUND_MASK_PCM)) {
/*
* Emulate missing pcm mixer controller
* through FEEDER_VOLUME
*/
pcm_setflags(ua->sc_dev, pcm_getflags(ua->sc_dev) |
SD_F_SOFTPCMVOL);
}
if (!(mask & SOUND_MASK_VOLUME)) {
mix_setparentchild(m, SOUND_MIXER_VOLUME, SOUND_MASK_PCM);
mix_setrealdev(m, SOUND_MIXER_VOLUME, SOUND_MIXER_NONE);
}
mix_setdevs(m, mask);
@ -360,10 +355,9 @@ ua_attach(device_t dev)
{
struct ua_info *ua;
struct sndcard_func *func;
struct snddev_info *d;
char status[SND_STATUSLEN];
device_t pa_dev;
u_int32_t nplay, nrec;
u_int32_t nplay, nrec, flags;
int i;
ua = (struct ua_info *)malloc(sizeof *ua, M_DEVBUF, M_ZERO | M_NOWAIT);
@ -408,14 +402,14 @@ ua_attach(device_t dev)
if (nrec > 1)
nrec = 1;
d = device_get_softc(dev);
for (i = 0; d != NULL &&
i < (sizeof(ua_quirks) / sizeof(ua_quirks[0])); i++) {
flags = pcm_getflags(dev);
for (i = 0; i < (sizeof(ua_quirks) / sizeof(ua_quirks[0])); i++) {
if (ua->vendor == ua_quirks[i].vendor &&
ua->product == ua_quirks[i].product &&
ua->release == ua_quirks[i].release)
d->flags |= ua_quirks[i].dflags;
flags |= ua_quirks[i].dflags;
}
pcm_setflags(dev, flags);
#ifndef NO_RECORDING
if (pcm_register(dev, ua, nplay, nrec)) {