Exemplo n.º 1
0
int	 
ad1848_mixer_set_port(struct ad1848_softc *ac, struct ad1848_devmap *map,
    int cnt, mixer_ctrl_t *cp)
{
	ad1848_devmap_t *entry;
	struct ad1848_volume vol;
	int error = EINVAL;
	int dev;

	if (!(entry = ad1848_mixer_find_dev(map, cnt, cp)))
		return (ENXIO);

  	dev = entry->dev;

	switch (entry->kind) {
	case AD1848_KIND_LVL:
		if (cp->type != AUDIO_MIXER_VALUE)
			break;
		if (dev < AD1848_AUX2_CHANNEL ||
		    dev > AD1848_MONITOR_CHANNEL)
			break;
		if (cp->un.value.num_channels != 1 &&
		    mixer_channel_info[dev].right_reg == 0) 
			break;
		ad1848_to_vol(cp, &vol);
		error = ad1848_set_channel_gain(ac, dev, &vol);
		break;

	case AD1848_KIND_MUTE:
		if (cp->type != AUDIO_MIXER_ENUM)
			break;
		ac->mute[dev] = (cp->un.ord ? MUTE_ALL : 0);
		ad1848_mute_channel(ac, dev, ac->mute[dev]);
		error = 0;
		break;

	case AD1848_KIND_RECORDGAIN:
		if (cp->type != AUDIO_MIXER_VALUE)
			break;
		ad1848_to_vol(cp, &vol);
		error = ad1848_set_rec_gain(ac, &vol);
		break;

	case AD1848_KIND_MICGAIN:
		if (cp->type != AUDIO_MIXER_VALUE)
			break;
		ad1848_to_vol(cp, &vol);
		error = ad1848_set_mic_gain(ac, &vol);
		break;

	case AD1848_KIND_RECORDSOURCE:
		if (cp->type != AUDIO_MIXER_ENUM)
			break;
		error = ad1848_set_rec_port(ac,  cp->un.ord);
		break;

	default:
		printf("Invalid kind\n");
		break;
	}

	return (error);
}
Exemplo n.º 2
0
int
ad1848_mixer_get_port(struct ad1848_softc *ac, struct ad1848_devmap *map,
                      int cnt, mixer_ctrl_t *cp)
{
    ad1848_devmap_t *entry;
    struct ad1848_volume vol;
    int error = EINVAL;
    int dev;

    if (!(entry = ad1848_mixer_find_dev(map, cnt, cp)))
        return (ENXIO);

    dev = entry->dev;
    mtx_enter(&audio_lock);
    switch (entry->kind) {
    case AD1848_KIND_LVL:
        if (cp->type != AUDIO_MIXER_VALUE)
            break;
        if (dev < AD1848_AUX2_CHANNEL ||
                dev > AD1848_MONITOR_CHANNEL)
            break;
        if (cp->un.value.num_channels != 1 &&
                mixer_channel_info[dev].right_reg == 0)
            break;
        error = ad1848_get_device_gain(ac, dev, &vol);
        if (!error)
            ad1848_from_vol(cp, &vol);
        break;

    case AD1848_KIND_MUTE:
        if (cp->type != AUDIO_MIXER_ENUM)
            break;
        cp->un.ord = ac->mute[dev] ? 1 : 0;
        error = 0;
        break;

    case AD1848_KIND_RECORDGAIN:
        if (cp->type != AUDIO_MIXER_VALUE)
            break;
        error = ad1848_get_rec_gain(ac, &vol);
        if (!error)
            ad1848_from_vol(cp, &vol);
        break;

    case AD1848_KIND_MICGAIN:
        if (cp->type != AUDIO_MIXER_VALUE)
            break;
        error = ad1848_get_mic_gain(ac, &vol);
        if (!error)
            ad1848_from_vol(cp, &vol);
        break;

    case AD1848_KIND_RECORDSOURCE:
        if (cp->type != AUDIO_MIXER_ENUM)
            break;
        cp->un.ord = ad1848_get_rec_port(ac);
        error = 0;
        break;

    default:
        printf("Invalid kind\n");
        break;
    }
    mtx_leave(&audio_lock);
    return error;
}