Exemplo n.º 1
0
static int
tumbler_init(struct snd_mixer *m)
{
    struct tumbler_softc *sc;
    u_int		x = 0;

    sc = device_get_softc(mix_getdevinfo(m));

    tumbler_write(sc, TUMBLER_LB0, tumbler_initdata.LB0);
    tumbler_write(sc, TUMBLER_LB1, tumbler_initdata.LB1);
    tumbler_write(sc, TUMBLER_LB2, tumbler_initdata.LB2);
    tumbler_write(sc, TUMBLER_LB3, tumbler_initdata.LB3);
    tumbler_write(sc, TUMBLER_LB4, tumbler_initdata.LB4);
    tumbler_write(sc, TUMBLER_LB5, tumbler_initdata.LB5);
    tumbler_write(sc, TUMBLER_RB0, tumbler_initdata.RB0);
    tumbler_write(sc, TUMBLER_RB1, tumbler_initdata.RB1);
    tumbler_write(sc, TUMBLER_RB1, tumbler_initdata.RB1);
    tumbler_write(sc, TUMBLER_RB2, tumbler_initdata.RB2);
    tumbler_write(sc, TUMBLER_RB3, tumbler_initdata.RB3);
    tumbler_write(sc, TUMBLER_RB4, tumbler_initdata.RB4);
    tumbler_write(sc, TUMBLER_RB5, tumbler_initdata.RB5);
    tumbler_write(sc, TUMBLER_MCR, tumbler_initdata.MCR);
    tumbler_write(sc, TUMBLER_DRC, tumbler_initdata.DRC);
    tumbler_write(sc, TUMBLER_VOLUME, tumbler_initdata.VOLUME);
    tumbler_write(sc, TUMBLER_TREBLE, tumbler_initdata.TREBLE);
    tumbler_write(sc, TUMBLER_BASS, tumbler_initdata.BASS);
    tumbler_write(sc, TUMBLER_MIXER1, tumbler_initdata.MIXER1);
    tumbler_write(sc, TUMBLER_MIXER2, tumbler_initdata.MIXER2);

    x |= SOUND_MASK_VOLUME;
    mix_setdevs(m, x);

    return (0);
}
Exemplo n.º 2
0
static int
screamer_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
{
	struct davbus_softc *d;
	int lval, rval;

	lval = ((100 - left) * 15 / 100) & 0xf;
	rval = ((100 - right) * 15 / 100) & 0xf;
	DPRINTF(("volume %d %d\n", lval, rval));

	d = mix_getdevinfo(m);

	switch (dev) {
	case SOUND_MIXER_VOLUME:
		mtx_lock(&d->mutex);
		screamer_write_locked(d, SCREAMER_CODEC_ADDR2, (lval << 6) |
		    rval);
		screamer_write_locked(d, SCREAMER_CODEC_ADDR4, (lval << 6) | 
		    rval);
		mtx_unlock(&d->mutex);

		return (left | (right << 8));
	}

	return (0);
}
Exemplo n.º 3
0
static int
onyx_init(struct snd_mixer *m)
{
	struct onyx_softc *sc;
	u_int  x = 0;

	sc = device_get_softc(mix_getdevinfo(m));

	onyx_write(sc, PCM3052_REG_LEFT_ATTN, onyx_initdata.LEFT_ATTN);
	onyx_write(sc, PCM3052_REG_RIGHT_ATTN, onyx_initdata.RIGHT_ATTN);
	onyx_write(sc, PCM3052_REG_CONTROL, onyx_initdata.CONTROL);
	onyx_write(sc, PCM3052_REG_DAC_CONTROL,
		      onyx_initdata.DAC_CONTROL);
	onyx_write(sc, PCM3052_REG_DAC_DEEMPH, onyx_initdata.DAC_DEEMPH);
	onyx_write(sc, PCM3052_REG_DAC_FILTER, onyx_initdata.DAC_FILTER);
	onyx_write(sc, PCM3052_REG_OUT_PHASE, onyx_initdata.OUT_PHASE);
	onyx_write(sc, PCM3052_REG_ADC_CONTROL,
		      onyx_initdata.ADC_CONTROL);
	onyx_write(sc, PCM3052_REG_ADC_HPF_BP, onyx_initdata.ADC_HPF_BP);
	onyx_write(sc, PCM3052_REG_INFO_1, onyx_initdata.INFO_1);
	onyx_write(sc, PCM3052_REG_INFO_2, onyx_initdata.INFO_2);
	onyx_write(sc, PCM3052_REG_INFO_3, onyx_initdata.INFO_3);
	onyx_write(sc, PCM3052_REG_INFO_4, onyx_initdata.INFO_4);

	x |= SOUND_MASK_VOLUME;
	mix_setdevs(m, x);

	return (0);
}
Exemplo n.º 4
0
static int
screamer_init(struct snd_mixer *m)
{
	struct davbus_softc *d;

	d = mix_getdevinfo(m);

	d->read_status = screamer_read_status;
	d->set_outputs = screamer_set_outputs;

	mtx_lock(&d->mutex);

	screamer_write_locked(d, SCREAMER_CODEC_ADDR0, SCREAMER_INPUT_CD | 
	    SCREAMER_DEFAULT_CD_GAIN);

	screamer_set_outputs(d, screamer_read_status(d, 
	    bus_read_4(d->reg, DAVBUS_CODEC_STATUS)));

	screamer_write_locked(d, SCREAMER_CODEC_ADDR2, 0);
	screamer_write_locked(d, SCREAMER_CODEC_ADDR4, 0);
	screamer_write_locked(d, SCREAMER_CODEC_ADDR5, 0);
	screamer_write_locked(d, SCREAMER_CODEC_ADDR6, 0);

	mtx_unlock(&d->mutex);

	mix_setdevs(m, SOUND_MASK_VOLUME);

	return (0);
}
Exemplo n.º 5
0
static int
burgundy_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
{
	struct davbus_softc *d;
	int lval, rval;

	lval = ((100 - left) * 15 / 100) & 0xf;
	rval = ((100 - right) * 15 / 100) & 0xf;
	DPRINTF(("volume %d %d\n", lval, rval));

	d = mix_getdevinfo(m);

	switch (dev) {
	case SOUND_MIXER_VOLUME:
		mtx_lock(&d->mutex);

		burgundy_write_locked(d, BURGUNDY_OL13_REG, lval);
		burgundy_write_locked(d, BURGUNDY_OL14_REG, (rval << 4) | lval);
		burgundy_write_locked(d, BURGUNDY_OL15_REG, (rval << 4) | lval);
		burgundy_write_locked(d, BURGUNDY_OL16_REG, (rval << 4) | lval);
		burgundy_write_locked(d, BURGUNDY_OL17_REG, lval);

		mtx_unlock(&d->mutex);

		return (left | (right << 8));
	}

	return (0);
}
Exemplo n.º 6
0
static u_int32_t
ad1816mix_setrecsrc(struct snd_mixer *m, u_int32_t src)
{
    struct ad1816_info *ad1816 = mix_getdevinfo(m);
    int dev;

    switch (src) {
    case SOUND_MASK_LINE:
    case SOUND_MASK_LINE3:
        dev = 0x00;
        break;

    case SOUND_MASK_CD:
    case SOUND_MASK_LINE1:
        dev = 0x20;
        break;

    case SOUND_MASK_MIC:
    default:
        dev = 0x50;
        src = SOUND_MASK_MIC;
    }

    dev |= dev << 8;
    ad1816_lock(ad1816);
    ad1816_write(ad1816, 20, (ad1816_read(ad1816, 20) & ~0x7070) | dev);
    ad1816_unlock(ad1816);
    return src;
}
Exemplo n.º 7
0
static int
ua_mixer_set(struct snd_mixer *m, unsigned type, unsigned left, unsigned right)
{
	device_t pa_dev;
	struct ua_info *ua = mix_getdevinfo(m);

	pa_dev = device_get_parent(ua->sc_dev);
	uaudio_mixer_set(pa_dev, type, left, right);

	return left | (right << 8);
}
Exemplo n.º 8
0
static int
burgundy_init(struct snd_mixer *m)
{
	struct davbus_softc *d;

	d = mix_getdevinfo(m);

	d->read_status = burgundy_read_status;
	d->set_outputs = burgundy_set_outputs;

	/*
	 * We configure the Burgundy codec as follows:
	 *
	 * 	o Input subframe 0 is connected to input digital
	 *	  stream A (ISA).
	 *	o Stream A (ISA) is mixed in mixer 2 (MIX2).
	 *	o Output of mixer 2 (MIX2) is routed to output sources
	 *	  OS0 and OS1 which can be converted to analog.
	 *
	 */
	mtx_lock(&d->mutex);

	burgundy_write_locked(d, 0x16700, 0x40);
	
	burgundy_write_locked(d, BURGUNDY_MIX0_REG, 0); 
	burgundy_write_locked(d, BURGUNDY_MIX1_REG, 0);
	burgundy_write_locked(d, BURGUNDY_MIX2_REG, BURGUNDY_MIX_ISA);
	burgundy_write_locked(d, BURGUNDY_MIX3_REG, 0);

	burgundy_write_locked(d, BURGUNDY_OS_REG, BURGUNDY_OS0_MIX2 | 
	    BURGUNDY_OS1_MIX2);

	burgundy_write_locked(d, BURGUNDY_SDIN_REG, BURGUNDY_ISA_SF0);

	/* Set several digital scalers to unity gain. */
	burgundy_write_locked(d, BURGUNDY_MXS2L_REG, BURGUNDY_MXS_UNITY);
	burgundy_write_locked(d, BURGUNDY_MXS2R_REG, BURGUNDY_MXS_UNITY);
	burgundy_write_locked(d, BURGUNDY_OSS0L_REG, BURGUNDY_OSS_UNITY);
	burgundy_write_locked(d, BURGUNDY_OSS0R_REG, BURGUNDY_OSS_UNITY);
	burgundy_write_locked(d, BURGUNDY_OSS1L_REG, BURGUNDY_OSS_UNITY);
	burgundy_write_locked(d, BURGUNDY_OSS1R_REG, BURGUNDY_OSS_UNITY);
	burgundy_write_locked(d, BURGUNDY_ISSAL_REG, BURGUNDY_ISS_UNITY);
	burgundy_write_locked(d, BURGUNDY_ISSAR_REG, BURGUNDY_ISS_UNITY);

	burgundy_set_outputs(d, burgundy_read_status(d, 
	    bus_read_4(d->reg, DAVBUS_CODEC_STATUS)));

	mtx_unlock(&d->mutex);

	mix_setdevs(m, SOUND_MASK_VOLUME);

	return (0);
}
Exemplo n.º 9
0
static int
ua_mixer_init(struct snd_mixer *m)
{
	u_int32_t mask;
	device_t pa_dev;
	struct ua_info *ua = mix_getdevinfo(m);

	pa_dev = device_get_parent(ua->sc_dev);

	mask = uaudio_query_mix_info(pa_dev);
	mix_setdevs(m,	mask);

	return 0;
}
Exemplo n.º 10
0
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);
}
Exemplo n.º 11
0
static int
bcmmix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
{
    	struct bcm2835_audio_info *sc = mix_getdevinfo(m);

	switch (dev) {
	case SOUND_MIXER_VOLUME:
		sc->volume = left;
		bcm2835_audio_update_controls(sc);
		break;

	default:
		break;
	}

    	return left | (left << 8);
}
Exemplo n.º 12
0
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));
}
Exemplo n.º 13
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));
}
Exemplo n.º 14
0
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);
}
Exemplo n.º 15
0
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);
}
Exemplo n.º 16
0
static int
snapper_init(struct snd_mixer *m)
{
	struct snapper_softc *sc;
	u_int		x = 0;

	sc = device_get_softc(mix_getdevinfo(m));

        snapper_write(sc, SNAPPER_LB0, snapper_initdata.LB0);
	snapper_write(sc, SNAPPER_LB1, snapper_initdata.LB1);
	snapper_write(sc, SNAPPER_LB2, snapper_initdata.LB2);
	snapper_write(sc, SNAPPER_LB3, snapper_initdata.LB3);
	snapper_write(sc, SNAPPER_LB4, snapper_initdata.LB4);
	snapper_write(sc, SNAPPER_LB5, snapper_initdata.LB5);
	snapper_write(sc, SNAPPER_LB6, snapper_initdata.LB6);
	snapper_write(sc, SNAPPER_RB0, snapper_initdata.RB0);
	snapper_write(sc, SNAPPER_RB1, snapper_initdata.RB1);
	snapper_write(sc, SNAPPER_RB1, snapper_initdata.RB1);
	snapper_write(sc, SNAPPER_RB2, snapper_initdata.RB2);
	snapper_write(sc, SNAPPER_RB3, snapper_initdata.RB3);
	snapper_write(sc, SNAPPER_RB4, snapper_initdata.RB4);
	snapper_write(sc, SNAPPER_RB5, snapper_initdata.RB5);
	snapper_write(sc, SNAPPER_RB6, snapper_initdata.RB6);
	snapper_write(sc, SNAPPER_MCR1, snapper_initdata.MCR1);
	snapper_write(sc, SNAPPER_MCR2, snapper_initdata.MCR2);
	snapper_write(sc, SNAPPER_DRC, snapper_initdata.DRC);
	snapper_write(sc, SNAPPER_VOLUME, snapper_initdata.VOLUME);
	snapper_write(sc, SNAPPER_TREBLE, snapper_initdata.TREBLE);
	snapper_write(sc, SNAPPER_BASS, snapper_initdata.BASS);
	snapper_write(sc, SNAPPER_MIXER_L, snapper_initdata.MIXER_L);
	snapper_write(sc, SNAPPER_MIXER_R, snapper_initdata.MIXER_R);
	snapper_write(sc, SNAPPER_LLB, snapper_initdata.LLB);
	snapper_write(sc, SNAPPER_RLB, snapper_initdata.RLB);
	snapper_write(sc, SNAPPER_LLB_GAIN, snapper_initdata.LLB_GAIN);
	snapper_write(sc, SNAPPER_RLB_GAIN, snapper_initdata.RLB_GAIN);
	snapper_write(sc, SNAPPER_ACR, snapper_initdata.ACR);

	x |= SOUND_MASK_VOLUME;
	mix_setdevs(m, x);

	return (0);
}
Exemplo n.º 17
0
static int
bcmmix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
{
    	struct bcm2835_audio_info *sc = mix_getdevinfo(m);

	switch (dev) {
	case SOUND_MIXER_VOLUME:
		BCM2835_AUDIO_LOCK(sc);
		sc->volume = left;
		bcm2835_worker_update_params(sc);
		BCM2835_AUDIO_UNLOCK(sc);

		break;

	default:
		break;
	}

    	return left | (left << 8);
}
Exemplo n.º 18
0
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);
}
Exemplo n.º 19
0
static int
a10codec_mixer_init(struct snd_mixer *m)
{
	struct a10codec_info *sc = mix_getdevinfo(m);
	pcell_t prop[4];
	phandle_t node;
	device_t gpio;
	uint32_t val;
	ssize_t len;
	int pin;

	mix_setdevs(m, SOUND_MASK_VOLUME | SOUND_MASK_LINE | SOUND_MASK_RECLEV);
	mix_setrecdevs(m, SOUND_MASK_LINE | SOUND_MASK_LINE1 | SOUND_MASK_MIC);

	/* Unmute input source to PA */
	val = CODEC_READ(sc, AC_DAC_ACTL);
	val |= DAC_ACTL_PAMUTE;
	CODEC_WRITE(sc, AC_DAC_ACTL, val);

	/* Enable PA */
	val = CODEC_READ(sc, AC_ADC_ACTL);
	val |= ADC_ACTL_PA_EN;
	CODEC_WRITE(sc, AC_ADC_ACTL, val);

	/* Unmute PA */
	node = ofw_bus_get_node(sc->dev);
	len = OF_getencprop(node, "allwinner,pa-gpios", prop, sizeof(prop));
	if (len > 0 && (len / sizeof(prop[0])) == 4) {
		gpio = OF_device_from_xref(prop[0]);
		if (gpio != NULL) {
			pin = prop[1] * 32 + prop[2];
			GPIO_PIN_SETFLAGS(gpio, pin, GPIO_PIN_OUTPUT);
			GPIO_PIN_SET(gpio, pin, GPIO_PIN_LOW);
		}
	}

	return (0);
}
Exemplo n.º 20
0
static int
ad1816mix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
{
    struct ad1816_info *ad1816 = mix_getdevinfo(m);
    u_short reg = 0;

    /* Scale volumes */
    left = AD1816_MUTE - (AD1816_MUTE * left) / 100;
    right = AD1816_MUTE - (AD1816_MUTE * right) / 100;

    reg = (left << 8) | right;

    /* do channel selective muting if volume is zero */
    if (left == AD1816_MUTE)	reg |= 0x8000;
    if (right == AD1816_MUTE)	reg |= 0x0080;

    ad1816_lock(ad1816);
    switch (dev) {
    case SOUND_MIXER_VOLUME:	/* Register 14 master volume */
        ad1816_write(ad1816, 14, reg);
        break;

    case SOUND_MIXER_CD:	/* Register 15 cd */
    case SOUND_MIXER_LINE1:
        ad1816_write(ad1816, 15, reg);
        break;

    case SOUND_MIXER_SYNTH:	/* Register 16 synth */
        ad1816_write(ad1816, 16, reg);
        break;

    case SOUND_MIXER_PCM:	/* Register 4 pcm */
        ad1816_write(ad1816, 4, reg);
        break;

    case SOUND_MIXER_LINE:
    case SOUND_MIXER_LINE3:	/* Register 18 line in */
        ad1816_write(ad1816, 18, reg);
        break;

    case SOUND_MIXER_MIC:	/* Register 19 mic volume */
        ad1816_write(ad1816, 19, reg & ~0xff);	/* mic is mono */
        break;

    case SOUND_MIXER_IGAIN:
        /* and now to something completely different ... */
        ad1816_write(ad1816, 20, ((ad1816_read(ad1816, 20) & ~0x0f0f)
                                  | (((AD1816_MUTE - left) / 2) << 8) /* four bits of adc gain */
                                  | ((AD1816_MUTE - right) / 2)));
        break;

    default:
        printf("ad1816_mixer_set(): unknown device.\n");
        break;
    }
    ad1816_unlock(ad1816);

    left = ((AD1816_MUTE - left) * 100) / AD1816_MUTE;
    right = ((AD1816_MUTE - right) * 100) / AD1816_MUTE;

    return left | (right << 8);
}
Exemplo n.º 21
0
static int
ua_mixer_uninit(struct snd_mixer *m)
{
	return (uaudio_mixer_uninit_sub(mix_getdevinfo(m)));
}