static int rt_setvol(struct rtrack *rt, int vol) { int i; mutex_lock(&rt->lock); if (vol == rt->curvol) { if (rt->muted) { rt->muted = 0; outb(0xd8, rt->io); } mutex_unlock(&rt->lock); return 0; } if (vol == 0) { outb(0x48, rt->io); sleep_delay(2000000); outb(0xd0, rt->io); rt->curvol = 0; mutex_unlock(&rt->lock); return 0; } rt->muted = 0; if (vol > rt->curvol) for (i = rt->curvol; i < vol; i++) rt_incvol(rt); else for (i = rt->curvol; i > vol; i--) rt_decvol(rt); rt->curvol = vol; mutex_unlock(&rt->lock); return 0; }
static int rt_setvol(struct rtrack *rt, int vol) { int i; mutex_lock(&rt->lock); if (vol == rt->curvol) { /* requested volume = current */ if (rt->muted) { /* user is unmuting the card */ rt->muted = 0; outb(0xd8, rt->io); /* enable card */ } mutex_unlock(&rt->lock); return 0; } if (vol == 0) { /* volume = 0 means mute the card */ outb(0x48, rt->io); /* volume down but still "on" */ msleep(2000); /* make sure it's totally down */ outb(0xd0, rt->io); /* volume steady, off */ rt->curvol = 0; /* track the volume state! */ mutex_unlock(&rt->lock); return 0; } rt->muted = 0; if (vol > rt->curvol) for (i = rt->curvol; i < vol; i++) rt_incvol(rt); else for (i = rt->curvol; i > vol; i--) rt_decvol(rt); rt->curvol = vol; mutex_unlock(&rt->lock); return 0; }
static int rt_setvol(struct rt_device *dev, int vol) { int i; mutex_lock(&lock); if(vol == dev->curvol) { /* requested volume = current */ if (dev->muted) { /* user is unmuting the card */ dev->muted = 0; outb (0xd8, io); /* enable card */ } mutex_unlock(&lock); return 0; } if(vol == 0) { /* volume = 0 means mute the card */ outb(0x48, io); /* volume down but still "on" */ sleep_delay(2000000); /* make sure it's totally down */ outb(0xd0, io); /* volume steady, off */ dev->curvol = 0; /* track the volume state! */ mutex_unlock(&lock); return 0; } dev->muted = 0; if(vol > dev->curvol) for(i = dev->curvol; i < vol; i++) rt_incvol(); else for(i = dev->curvol; i > vol; i--) rt_decvol(); dev->curvol = vol; mutex_unlock(&lock); return 0; }