aboutsummaryrefslogtreecommitdiffstats
path: root/sound/drivers/opl4/opl4_mixer.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /sound/drivers/opl4/opl4_mixer.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'sound/drivers/opl4/opl4_mixer.c')
-rw-r--r--sound/drivers/opl4/opl4_mixer.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/sound/drivers/opl4/opl4_mixer.c b/sound/drivers/opl4/opl4_mixer.c
new file mode 100644
index 000000000000..ec7a228fbe7e
--- /dev/null
+++ b/sound/drivers/opl4/opl4_mixer.c
@@ -0,0 +1,95 @@
1/*
2 * OPL4 mixer functions
3 * Copyright (c) 2003 by Clemens Ladisch <clemens@ladisch.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include "opl4_local.h"
21#include <sound/control.h>
22
23static int snd_opl4_ctl_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
24{
25 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
26 uinfo->count = 2;
27 uinfo->value.integer.min = 0;
28 uinfo->value.integer.max = 7;
29 return 0;
30}
31
32static int snd_opl4_ctl_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
33{
34 opl4_t *opl4 = snd_kcontrol_chip(kcontrol);
35 unsigned long flags;
36 u8 reg = kcontrol->private_value;
37 u8 value;
38
39 spin_lock_irqsave(&opl4->reg_lock, flags);
40 value = snd_opl4_read(opl4, reg);
41 spin_unlock_irqrestore(&opl4->reg_lock, flags);
42 ucontrol->value.integer.value[0] = 7 - (value & 7);
43 ucontrol->value.integer.value[1] = 7 - ((value >> 3) & 7);
44 return 0;
45}
46
47static int snd_opl4_ctl_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
48{
49 opl4_t *opl4 = snd_kcontrol_chip(kcontrol);
50 unsigned long flags;
51 u8 reg = kcontrol->private_value;
52 u8 value, old_value;
53
54 value = (7 - (ucontrol->value.integer.value[0] & 7)) |
55 ((7 - (ucontrol->value.integer.value[1] & 7)) << 3);
56 spin_lock_irqsave(&opl4->reg_lock, flags);
57 old_value = snd_opl4_read(opl4, reg);
58 snd_opl4_write(opl4, reg, value);
59 spin_unlock_irqrestore(&opl4->reg_lock, flags);
60 return value != old_value;
61}
62
63static snd_kcontrol_new_t snd_opl4_controls[] = {
64 {
65 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
66 .name = "FM Playback Volume",
67 .info = snd_opl4_ctl_info,
68 .get = snd_opl4_ctl_get,
69 .put = snd_opl4_ctl_put,
70 .private_value = OPL4_REG_MIX_CONTROL_FM
71 },
72 {
73 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
74 .name = "Wavetable Playback Volume",
75 .info = snd_opl4_ctl_info,
76 .get = snd_opl4_ctl_get,
77 .put = snd_opl4_ctl_put,
78 .private_value = OPL4_REG_MIX_CONTROL_PCM
79 }
80};
81
82int snd_opl4_create_mixer(opl4_t *opl4)
83{
84 snd_card_t *card = opl4->card;
85 int i, err;
86
87 strcat(card->mixername, ",OPL4");
88
89 for (i = 0; i < 2; ++i) {
90 err = snd_ctl_add(card, snd_ctl_new1(&snd_opl4_controls[i], opl4));
91 if (err < 0)
92 return err;
93 }
94 return 0;
95}