summaryrefslogtreecommitdiff
path: root/sound/pci/oxygen/oxygen_mixer.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-01-25 08:37:49 +0100
committerJaroslav Kysela <perex@perex.cz>2008-01-31 17:30:14 +0100
commit976cd62700ae378df330ec82112da3d17e33a0fe (patch)
tree22d31425c0940b8d7105c4914fd944fcc3c2a8d9 /sound/pci/oxygen/oxygen_mixer.c
parent09189ac793d7fef7d0f058815043e3d4bf7097c0 (diff)
[ALSA] oxygen: make the number of analog output configurable
Add a field to struct oxygen_model to allow model drivers for cards with less than eight output channels. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/oxygen/oxygen_mixer.c')
-rw-r--r--sound/pci/oxygen/oxygen_mixer.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c
index 6b7420fdd026..21b227a94ace 100644
--- a/sound/pci/oxygen/oxygen_mixer.c
+++ b/sound/pci/oxygen/oxygen_mixer.c
@@ -28,8 +28,10 @@
static int dac_volume_info(struct snd_kcontrol *ctl,
struct snd_ctl_elem_info *info)
{
+ struct oxygen *chip = ctl->private_data;
+
info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
- info->count = 8;
+ info->count = chip->model->dac_channels;
info->value.integer.min = 0;
info->value.integer.max = 0xff;
return 0;
@@ -42,7 +44,7 @@ static int dac_volume_get(struct snd_kcontrol *ctl,
unsigned int i;
mutex_lock(&chip->mutex);
- for (i = 0; i < 8; ++i)
+ for (i = 0; i < chip->model->dac_channels; ++i)
value->value.integer.value[i] = chip->dac_volume[i];
mutex_unlock(&chip->mutex);
return 0;
@@ -57,7 +59,7 @@ static int dac_volume_put(struct snd_kcontrol *ctl,
changed = 0;
mutex_lock(&chip->mutex);
- for (i = 0; i < 8; ++i)
+ for (i = 0; i < chip->model->dac_channels; ++i)
if (value->value.integer.value[i] != chip->dac_volume[i]) {
chip->dac_volume[i] = value->value.integer.value[i];
changed = 1;
@@ -100,11 +102,14 @@ static int upmix_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info)
static const char *const names[3] = {
"Front", "Front+Surround", "Front+Surround+Back"
};
+ struct oxygen *chip = ctl->private_data;
+ unsigned int count = 2 + (chip->model->dac_channels == 8);
+
info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
info->count = 1;
- info->value.enumerated.items = 3;
- if (info->value.enumerated.item > 2)
- info->value.enumerated.item = 2;
+ info->value.enumerated.items = count;
+ if (info->value.enumerated.item >= count)
+ info->value.enumerated.item = count - 1;
strcpy(info->value.enumerated.name, names[info->value.enumerated.item]);
return 0;
}
@@ -167,12 +172,14 @@ void oxygen_update_dac_routing(struct oxygen *chip)
static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)
{
struct oxygen *chip = ctl->private_data;
+ unsigned int count = 2 + (chip->model->dac_channels == 8);
int changed;
mutex_lock(&chip->mutex);
changed = value->value.enumerated.item[0] != chip->dac_routing;
if (changed) {
- chip->dac_routing = min(value->value.enumerated.item[0], 2u);
+ chip->dac_routing = min(value->value.enumerated.item[0],
+ count - 1);
spin_lock_irq(&chip->reg_lock);
oxygen_update_dac_routing(chip);
spin_unlock_irq(&chip->reg_lock);