2019-05-27 09:55:05 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Driver for Digigram VXpocket soundcards
|
|
|
|
*
|
|
|
|
* VX-pocket mixer
|
|
|
|
*
|
|
|
|
* Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/control.h>
|
2006-08-29 20:15:15 +04:00
|
|
|
#include <sound/tlv.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include "vxpocket.h"
|
|
|
|
|
|
|
|
#define MIC_LEVEL_MIN 0
|
|
|
|
#define MIC_LEVEL_MAX 8
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mic level control (for VXPocket)
|
|
|
|
*/
|
2005-11-17 16:46:59 +03:00
|
|
|
static int vx_mic_level_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
|
|
|
|
uinfo->count = 1;
|
|
|
|
uinfo->value.integer.min = 0;
|
|
|
|
uinfo->value.integer.max = MIC_LEVEL_MAX;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 16:46:59 +03:00
|
|
|
static int vx_mic_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 16:46:59 +03:00
|
|
|
struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
|
2017-05-12 11:03:35 +03:00
|
|
|
struct snd_vxpocket *chip = to_vxpocket(_chip);
|
2005-04-17 02:20:36 +04:00
|
|
|
ucontrol->value.integer.value[0] = chip->mic_level;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 16:46:59 +03:00
|
|
|
static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 16:46:59 +03:00
|
|
|
struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
|
2017-05-12 11:03:35 +03:00
|
|
|
struct snd_vxpocket *chip = to_vxpocket(_chip);
|
2007-11-15 18:13:32 +03:00
|
|
|
unsigned int val = ucontrol->value.integer.value[0];
|
|
|
|
|
|
|
|
if (val > MIC_LEVEL_MAX)
|
|
|
|
return -EINVAL;
|
2006-01-16 18:36:05 +03:00
|
|
|
mutex_lock(&_chip->mixer_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (chip->mic_level != ucontrol->value.integer.value[0]) {
|
|
|
|
vx_set_mic_level(_chip, ucontrol->value.integer.value[0]);
|
|
|
|
chip->mic_level = ucontrol->value.integer.value[0];
|
2006-01-16 18:36:05 +03:00
|
|
|
mutex_unlock(&_chip->mixer_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2006-01-16 18:36:05 +03:00
|
|
|
mutex_unlock(&_chip->mixer_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-01-29 17:33:49 +03:00
|
|
|
static const DECLARE_TLV_DB_SCALE(db_scale_mic, -21, 3, 0);
|
2006-08-29 20:15:15 +04:00
|
|
|
|
2017-05-27 17:46:15 +03:00
|
|
|
static const struct snd_kcontrol_new vx_control_mic_level = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
2006-08-29 20:15:15 +04:00
|
|
|
.access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
|
|
|
|
SNDRV_CTL_ELEM_ACCESS_TLV_READ),
|
2005-04-17 02:20:36 +04:00
|
|
|
.name = "Mic Capture Volume",
|
|
|
|
.info = vx_mic_level_info,
|
|
|
|
.get = vx_mic_level_get,
|
|
|
|
.put = vx_mic_level_put,
|
2006-08-29 20:15:15 +04:00
|
|
|
.tlv = { .p = db_scale_mic },
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mic boost level control (for VXP440)
|
|
|
|
*/
|
2007-07-23 17:42:26 +04:00
|
|
|
#define vx_mic_boost_info snd_ctl_boolean_mono_info
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-11-17 16:46:59 +03:00
|
|
|
static int vx_mic_boost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 16:46:59 +03:00
|
|
|
struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
|
2017-05-12 11:03:35 +03:00
|
|
|
struct snd_vxpocket *chip = to_vxpocket(_chip);
|
2005-04-17 02:20:36 +04:00
|
|
|
ucontrol->value.integer.value[0] = chip->mic_level;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-17 16:46:59 +03:00
|
|
|
static int vx_mic_boost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2005-11-17 16:46:59 +03:00
|
|
|
struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
|
2017-05-12 11:03:35 +03:00
|
|
|
struct snd_vxpocket *chip = to_vxpocket(_chip);
|
2007-11-15 18:13:32 +03:00
|
|
|
int val = !!ucontrol->value.integer.value[0];
|
2006-01-16 18:36:05 +03:00
|
|
|
mutex_lock(&_chip->mixer_mutex);
|
2007-11-15 18:13:32 +03:00
|
|
|
if (chip->mic_level != val) {
|
|
|
|
vx_set_mic_boost(_chip, val);
|
|
|
|
chip->mic_level = val;
|
2006-01-16 18:36:05 +03:00
|
|
|
mutex_unlock(&_chip->mixer_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2006-01-16 18:36:05 +03:00
|
|
|
mutex_unlock(&_chip->mixer_mutex);
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-05-27 17:46:15 +03:00
|
|
|
static const struct snd_kcontrol_new vx_control_mic_boost = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
|
|
|
|
.name = "Mic Boost",
|
|
|
|
.info = vx_mic_boost_info,
|
|
|
|
.get = vx_mic_boost_get,
|
|
|
|
.put = vx_mic_boost_put,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-11-17 16:46:59 +03:00
|
|
|
int vxp_add_mic_controls(struct vx_core *_chip)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2017-05-12 11:03:35 +03:00
|
|
|
struct snd_vxpocket *chip = to_vxpocket(_chip);
|
2005-04-17 02:20:36 +04:00
|
|
|
int err;
|
|
|
|
|
|
|
|
/* mute input levels */
|
|
|
|
chip->mic_level = 0;
|
|
|
|
switch (_chip->type) {
|
|
|
|
case VX_TYPE_VXPOCKET:
|
|
|
|
vx_set_mic_level(_chip, 0);
|
|
|
|
break;
|
|
|
|
case VX_TYPE_VXP440:
|
|
|
|
vx_set_mic_boost(_chip, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mic level */
|
|
|
|
switch (_chip->type) {
|
|
|
|
case VX_TYPE_VXPOCKET:
|
|
|
|
if ((err = snd_ctl_add(_chip->card, snd_ctl_new1(&vx_control_mic_level, chip))) < 0)
|
|
|
|
return err;
|
|
|
|
break;
|
|
|
|
case VX_TYPE_VXP440:
|
|
|
|
if ((err = snd_ctl_add(_chip->card, snd_ctl_new1(&vx_control_mic_boost, chip))) < 0)
|
|
|
|
return err;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|