static int tumbler_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right) { struct tumbler_softc *sc; struct mtx *mixer_lock; int locked; u_int l, r; u_char reg[6]; sc = device_get_softc(mix_getdevinfo(m)); mixer_lock = mixer_get_lock(m); locked = mtx_owned(mixer_lock); switch (dev) { case SOUND_MIXER_VOLUME: if (left > 100 || right > 100) return (0); l = (left == 0 ? 0 : tumbler_volume_table[left - 1]); r = (right == 0 ? 0 : tumbler_volume_table[right - 1]); reg[0] = (l & 0xff0000) >> 16; reg[1] = (l & 0x00ff00) >> 8; reg[2] = l & 0x0000ff; reg[3] = (r & 0xff0000) >> 16; reg[4] = (r & 0x00ff00) >> 8; reg[5] = r & 0x0000ff; /* * We need to unlock the mixer lock because iicbus_transfer() * may sleep. The mixer lock itself is unnecessary here * because it is meant to serialize hardware access, which * is taken care of by the I2C layer, so this is safe. */ if (locked) mtx_unlock(mixer_lock); tumbler_write(sc, TUMBLER_VOLUME, reg); if (locked) mtx_lock(mixer_lock); return (left | (right << 8)); } return (0); }
static int ua_mixer_set(struct snd_mixer *m, unsigned type, unsigned left, unsigned right) { struct lock *lock = mixer_get_lock(m); uint8_t do_unlock; if (lockowned(lock)) { do_unlock = 0; } else { do_unlock = 1; lockmgr(lock, LK_EXCLUSIVE); } uaudio_mixer_set(mix_getdevinfo(m), type, left, right); if (do_unlock) { lockmgr(lock, LK_RELEASE); } return (left | (right << 8)); }
static int ua_mixer_set(struct snd_mixer *m, unsigned type, unsigned left, unsigned right) { struct mtx *mtx = mixer_get_lock(m); uint8_t do_unlock; if (mtx_owned(mtx)) { do_unlock = 0; } else { do_unlock = 1; mtx_lock(mtx); } uaudio_mixer_set(mix_getdevinfo(m), type, left, right); if (do_unlock) { mtx_unlock(mtx); } return (left | (right << 8)); }
static uint32_t ua_mixer_setrecsrc(struct snd_mixer *m, uint32_t src) { struct lock *lock = mixer_get_lock(m); int retval; uint8_t do_unlock; if (lockowned(lock)) { do_unlock = 0; } else { do_unlock = 1; lockmgr(lock, LK_EXCLUSIVE); } retval = uaudio_mixer_setrecsrc(mix_getdevinfo(m), src); if (do_unlock) { lockmgr(lock, LK_RELEASE); } return (retval); }
static uint32_t ua_mixer_setrecsrc(struct snd_mixer *m, uint32_t src) { struct mtx *mtx = mixer_get_lock(m); int retval; uint8_t do_unlock; if (mtx_owned(mtx)) { do_unlock = 0; } else { do_unlock = 1; mtx_lock(mtx); } retval = uaudio_mixer_setrecsrc(mix_getdevinfo(m), src); if (do_unlock) { mtx_unlock(mtx); } return (retval); }
static int onyx_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right) { struct onyx_softc *sc; struct mtx *mixer_lock; int locked; uint8_t l, r; sc = device_get_softc(mix_getdevinfo(m)); mixer_lock = mixer_get_lock(m); locked = mtx_owned(mixer_lock); switch (dev) { case SOUND_MIXER_VOLUME: /* * We need to unlock the mixer lock because iicbus_transfer() * may sleep. The mixer lock itself is unnecessary here * because it is meant to serialize hardware access, which * is taken care of by the I2C layer, so this is safe. */ if (left > 100 || right > 100) return (0); l = left + 128; r = right + 128; if (locked) mtx_unlock(mixer_lock); onyx_write(sc, PCM3052_REG_LEFT_ATTN, l); onyx_write(sc, PCM3052_REG_RIGHT_ATTN, r); if (locked) mtx_lock(mixer_lock); return (left | (right << 8)); } return (0); }