diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2008-01-25 02:37:49 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2008-01-31 11:30:14 -0500 |
commit | 976cd62700ae378df330ec82112da3d17e33a0fe (patch) | |
tree | 22d31425c0940b8d7105c4914fd944fcc3c2a8d9 /sound/pci/oxygen/oxygen_mixer.c | |
parent | 09189ac793d7fef7d0f058815043e3d4bf7097c0 (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.c | 21 |
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 @@ | |||
28 | static int dac_volume_info(struct snd_kcontrol *ctl, | 28 | static int dac_volume_info(struct snd_kcontrol *ctl, |
29 | struct snd_ctl_elem_info *info) | 29 | struct snd_ctl_elem_info *info) |
30 | { | 30 | { |
31 | struct oxygen *chip = ctl->private_data; | ||
32 | |||
31 | info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 33 | info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
32 | info->count = 8; | 34 | info->count = chip->model->dac_channels; |
33 | info->value.integer.min = 0; | 35 | info->value.integer.min = 0; |
34 | info->value.integer.max = 0xff; | 36 | info->value.integer.max = 0xff; |
35 | return 0; | 37 | return 0; |
@@ -42,7 +44,7 @@ static int dac_volume_get(struct snd_kcontrol *ctl, | |||
42 | unsigned int i; | 44 | unsigned int i; |
43 | 45 | ||
44 | mutex_lock(&chip->mutex); | 46 | mutex_lock(&chip->mutex); |
45 | for (i = 0; i < 8; ++i) | 47 | for (i = 0; i < chip->model->dac_channels; ++i) |
46 | value->value.integer.value[i] = chip->dac_volume[i]; | 48 | value->value.integer.value[i] = chip->dac_volume[i]; |
47 | mutex_unlock(&chip->mutex); | 49 | mutex_unlock(&chip->mutex); |
48 | return 0; | 50 | return 0; |
@@ -57,7 +59,7 @@ static int dac_volume_put(struct snd_kcontrol *ctl, | |||
57 | 59 | ||
58 | changed = 0; | 60 | changed = 0; |
59 | mutex_lock(&chip->mutex); | 61 | mutex_lock(&chip->mutex); |
60 | for (i = 0; i < 8; ++i) | 62 | for (i = 0; i < chip->model->dac_channels; ++i) |
61 | if (value->value.integer.value[i] != chip->dac_volume[i]) { | 63 | if (value->value.integer.value[i] != chip->dac_volume[i]) { |
62 | chip->dac_volume[i] = value->value.integer.value[i]; | 64 | chip->dac_volume[i] = value->value.integer.value[i]; |
63 | changed = 1; | 65 | changed = 1; |
@@ -100,11 +102,14 @@ static int upmix_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) | |||
100 | static const char *const names[3] = { | 102 | static const char *const names[3] = { |
101 | "Front", "Front+Surround", "Front+Surround+Back" | 103 | "Front", "Front+Surround", "Front+Surround+Back" |
102 | }; | 104 | }; |
105 | struct oxygen *chip = ctl->private_data; | ||
106 | unsigned int count = 2 + (chip->model->dac_channels == 8); | ||
107 | |||
103 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 108 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
104 | info->count = 1; | 109 | info->count = 1; |
105 | info->value.enumerated.items = 3; | 110 | info->value.enumerated.items = count; |
106 | if (info->value.enumerated.item > 2) | 111 | if (info->value.enumerated.item >= count) |
107 | info->value.enumerated.item = 2; | 112 | info->value.enumerated.item = count - 1; |
108 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); | 113 | strcpy(info->value.enumerated.name, names[info->value.enumerated.item]); |
109 | return 0; | 114 | return 0; |
110 | } | 115 | } |
@@ -167,12 +172,14 @@ void oxygen_update_dac_routing(struct oxygen *chip) | |||
167 | static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | 172 | static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) |
168 | { | 173 | { |
169 | struct oxygen *chip = ctl->private_data; | 174 | struct oxygen *chip = ctl->private_data; |
175 | unsigned int count = 2 + (chip->model->dac_channels == 8); | ||
170 | int changed; | 176 | int changed; |
171 | 177 | ||
172 | mutex_lock(&chip->mutex); | 178 | mutex_lock(&chip->mutex); |
173 | changed = value->value.enumerated.item[0] != chip->dac_routing; | 179 | changed = value->value.enumerated.item[0] != chip->dac_routing; |
174 | if (changed) { | 180 | if (changed) { |
175 | chip->dac_routing = min(value->value.enumerated.item[0], 2u); | 181 | chip->dac_routing = min(value->value.enumerated.item[0], |
182 | count - 1); | ||
176 | spin_lock_irq(&chip->reg_lock); | 183 | spin_lock_irq(&chip->reg_lock); |
177 | oxygen_update_dac_routing(chip); | 184 | oxygen_update_dac_routing(chip); |
178 | spin_unlock_irq(&chip->reg_lock); | 185 | spin_unlock_irq(&chip->reg_lock); |