summaryrefslogtreecommitdiffstats
path: root/kernel/sound/pcmcia/vx/vxp_mixer.c
diff options
context:
space:
mode:
authorYunhong Jiang <yunhong.jiang@intel.com>2015-08-04 12:17:53 -0700
committerYunhong Jiang <yunhong.jiang@intel.com>2015-08-04 15:44:42 -0700
commit9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00 (patch)
tree1c9cafbcd35f783a87880a10f85d1a060db1a563 /kernel/sound/pcmcia/vx/vxp_mixer.c
parent98260f3884f4a202f9ca5eabed40b1354c489b29 (diff)
Add the rt linux 4.1.3-rt3 as base
Import the rt linux 4.1.3-rt3 as OPNFV kvm base. It's from git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git linux-4.1.y-rt and the base is: commit 0917f823c59692d751951bf5ea699a2d1e2f26a2 Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Date: Sat Jul 25 12:13:34 2015 +0200 Prepare v4.1.3-rt3 Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> We lose all the git history this way and it's not good. We should apply another opnfv project repo in future. Change-Id: I87543d81c9df70d99c5001fbdf646b202c19f423 Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
Diffstat (limited to 'kernel/sound/pcmcia/vx/vxp_mixer.c')
-rw-r--r--kernel/sound/pcmcia/vx/vxp_mixer.c151
1 files changed, 151 insertions, 0 deletions
diff --git a/kernel/sound/pcmcia/vx/vxp_mixer.c b/kernel/sound/pcmcia/vx/vxp_mixer.c
new file mode 100644
index 000000000..a4a664259
--- /dev/null
+++ b/kernel/sound/pcmcia/vx/vxp_mixer.c
@@ -0,0 +1,151 @@
+/*
+ * Driver for Digigram VXpocket soundcards
+ *
+ * VX-pocket mixer
+ *
+ * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <sound/core.h>
+#include <sound/control.h>
+#include <sound/tlv.h>
+#include "vxpocket.h"
+
+#define MIC_LEVEL_MIN 0
+#define MIC_LEVEL_MAX 8
+
+/*
+ * mic level control (for VXPocket)
+ */
+static int vx_mic_level_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
+{
+ uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+ uinfo->count = 1;
+ uinfo->value.integer.min = 0;
+ uinfo->value.integer.max = MIC_LEVEL_MAX;
+ return 0;
+}
+
+static int vx_mic_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+ struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
+ struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
+ ucontrol->value.integer.value[0] = chip->mic_level;
+ return 0;
+}
+
+static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+ struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
+ struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
+ unsigned int val = ucontrol->value.integer.value[0];
+
+ if (val > MIC_LEVEL_MAX)
+ return -EINVAL;
+ mutex_lock(&_chip->mixer_mutex);
+ 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];
+ mutex_unlock(&_chip->mixer_mutex);
+ return 1;
+ }
+ mutex_unlock(&_chip->mixer_mutex);
+ return 0;
+}
+
+static const DECLARE_TLV_DB_SCALE(db_scale_mic, -21, 3, 0);
+
+static struct snd_kcontrol_new vx_control_mic_level = {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE |
+ SNDRV_CTL_ELEM_ACCESS_TLV_READ),
+ .name = "Mic Capture Volume",
+ .info = vx_mic_level_info,
+ .get = vx_mic_level_get,
+ .put = vx_mic_level_put,
+ .tlv = { .p = db_scale_mic },
+};
+
+/*
+ * mic boost level control (for VXP440)
+ */
+#define vx_mic_boost_info snd_ctl_boolean_mono_info
+
+static int vx_mic_boost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+ struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
+ struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
+ ucontrol->value.integer.value[0] = chip->mic_level;
+ return 0;
+}
+
+static int vx_mic_boost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+ struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
+ struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
+ int val = !!ucontrol->value.integer.value[0];
+ mutex_lock(&_chip->mixer_mutex);
+ if (chip->mic_level != val) {
+ vx_set_mic_boost(_chip, val);
+ chip->mic_level = val;
+ mutex_unlock(&_chip->mixer_mutex);
+ return 1;
+ }
+ mutex_unlock(&_chip->mixer_mutex);
+ return 0;
+}
+
+static struct snd_kcontrol_new vx_control_mic_boost = {
+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+ .name = "Mic Boost",
+ .info = vx_mic_boost_info,
+ .get = vx_mic_boost_get,
+ .put = vx_mic_boost_put,
+};
+
+
+int vxp_add_mic_controls(struct vx_core *_chip)
+{
+ struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
+ 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;
+}
+