oxygen_mixer.c (75919d7c057be888c7cd7b192fad02182260b04a) oxygen_mixer.c (3d8bb454c4fbe18cea1adfd4183a4a9ef5f0ef04)
1/*
2 * C-Media CMI8788 driver - mixer code
3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 *
6 *
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2.

--- 85 unchanged lines hidden (view full) ---

94 chip->model.update_dac_mute(chip);
95 }
96 mutex_unlock(&chip->mutex);
97 return changed;
98}
99
100static int upmix_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info)
101{
1/*
2 * C-Media CMI8788 driver - mixer code
3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 *
6 *
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2.

--- 85 unchanged lines hidden (view full) ---

94 chip->model.update_dac_mute(chip);
95 }
96 mutex_unlock(&chip->mutex);
97 return changed;
98}
99
100static int upmix_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info)
101{
102 static const char *const names[3] = {
103 "Front", "Front+Surround", "Front+Surround+Back"
102 static const char *const names[5] = {
103 "Front",
104 "Front+Surround",
105 "Front+Surround+Back",
106 "Front+Surround+Center/LFE",
107 "Front+Surround+Center/LFE+Back",
104 };
105 struct oxygen *chip = ctl->private_data;
108 };
109 struct oxygen *chip = ctl->private_data;
106 unsigned int count = 2 + (chip->model.dac_channels == 8);
110 unsigned int count = chip->model.update_center_lfe_mix ? 5 : 3;
107
108 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
109 info->count = 1;
110 info->value.enumerated.items = count;
111 if (info->value.enumerated.item >= count)
112 info->value.enumerated.item = count - 1;
113 strcpy(info->value.enumerated.name, names[info->value.enumerated.item]);
114 return 0;

--- 7 unchanged lines hidden (view full) ---

122 value->value.enumerated.item[0] = chip->dac_routing;
123 mutex_unlock(&chip->mutex);
124 return 0;
125}
126
127void oxygen_update_dac_routing(struct oxygen *chip)
128{
129 /* DAC 0: front, DAC 1: surround, DAC 2: center/LFE, DAC 3: back */
111
112 info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
113 info->count = 1;
114 info->value.enumerated.items = count;
115 if (info->value.enumerated.item >= count)
116 info->value.enumerated.item = count - 1;
117 strcpy(info->value.enumerated.name, names[info->value.enumerated.item]);
118 return 0;

--- 7 unchanged lines hidden (view full) ---

126 value->value.enumerated.item[0] = chip->dac_routing;
127 mutex_unlock(&chip->mutex);
128 return 0;
129}
130
131void oxygen_update_dac_routing(struct oxygen *chip)
132{
133 /* DAC 0: front, DAC 1: surround, DAC 2: center/LFE, DAC 3: back */
130 static const unsigned int reg_values[3] = {
134 static const unsigned int reg_values[5] = {
131 /* stereo -> front */
132 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
133 (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
134 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
135 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
136 /* stereo -> front+surround */
137 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
138 (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
139 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
140 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
141 /* stereo -> front+surround+back */
142 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
143 (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
144 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
145 (0 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
135 /* stereo -> front */
136 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
137 (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
138 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
139 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
140 /* stereo -> front+surround */
141 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
142 (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
143 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
144 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
145 /* stereo -> front+surround+back */
146 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
147 (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
148 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
149 (0 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
150 /* stereo -> front+surround+center/LFE */
151 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
152 (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
153 (0 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
154 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
155 /* stereo -> front+surround+center/LFE+back */
156 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
157 (0 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
158 (0 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
159 (0 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT),
146 };
147 u8 channels;
148 unsigned int reg_value;
149
150 channels = oxygen_read8(chip, OXYGEN_PLAY_CHANNELS) &
151 OXYGEN_PLAY_CHANNELS_MASK;
152 if (channels == OXYGEN_PLAY_CHANNELS_2)
153 reg_value = reg_values[chip->dac_routing];

--- 8 unchanged lines hidden (view full) ---

162 (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
163 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
164 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT);
165 oxygen_write16_masked(chip, OXYGEN_PLAY_ROUTING, reg_value,
166 OXYGEN_PLAY_DAC0_SOURCE_MASK |
167 OXYGEN_PLAY_DAC1_SOURCE_MASK |
168 OXYGEN_PLAY_DAC2_SOURCE_MASK |
169 OXYGEN_PLAY_DAC3_SOURCE_MASK);
160 };
161 u8 channels;
162 unsigned int reg_value;
163
164 channels = oxygen_read8(chip, OXYGEN_PLAY_CHANNELS) &
165 OXYGEN_PLAY_CHANNELS_MASK;
166 if (channels == OXYGEN_PLAY_CHANNELS_2)
167 reg_value = reg_values[chip->dac_routing];

--- 8 unchanged lines hidden (view full) ---

176 (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
177 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
178 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT);
179 oxygen_write16_masked(chip, OXYGEN_PLAY_ROUTING, reg_value,
180 OXYGEN_PLAY_DAC0_SOURCE_MASK |
181 OXYGEN_PLAY_DAC1_SOURCE_MASK |
182 OXYGEN_PLAY_DAC2_SOURCE_MASK |
183 OXYGEN_PLAY_DAC3_SOURCE_MASK);
184 if (chip->model.update_center_lfe_mix)
185 chip->model.update_center_lfe_mix(chip, chip->dac_routing > 2);
170}
171
172static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)
173{
174 struct oxygen *chip = ctl->private_data;
186}
187
188static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value)
189{
190 struct oxygen *chip = ctl->private_data;
175 unsigned int count = 2 + (chip->model.dac_channels == 8);
191 unsigned int count = chip->model.update_center_lfe_mix ? 5 : 3;
176 int changed;
177
192 int changed;
193
194 if (value->value.enumerated.item[0] >= count)
195 return -EINVAL;
178 mutex_lock(&chip->mutex);
179 changed = value->value.enumerated.item[0] != chip->dac_routing;
180 if (changed) {
196 mutex_lock(&chip->mutex);
197 changed = value->value.enumerated.item[0] != chip->dac_routing;
198 if (changed) {
181 chip->dac_routing = min(value->value.enumerated.item[0],
182 count - 1);
183 spin_lock_irq(&chip->reg_lock);
199 chip->dac_routing = value->value.enumerated.item[0];
184 oxygen_update_dac_routing(chip);
200 oxygen_update_dac_routing(chip);
185 spin_unlock_irq(&chip->reg_lock);
186 }
187 mutex_unlock(&chip->mutex);
188 return changed;
189}
190
191static int spdif_switch_get(struct snd_kcontrol *ctl,
192 struct snd_ctl_elem_value *value)
193{

--- 822 unchanged lines hidden ---
201 }
202 mutex_unlock(&chip->mutex);
203 return changed;
204}
205
206static int spdif_switch_get(struct snd_kcontrol *ctl,
207 struct snd_ctl_elem_value *value)
208{

--- 822 unchanged lines hidden ---