diff options
author | Roman Volkov <v1ron@mail.ru> | 2014-01-24 07:18:17 -0500 |
---|---|---|
committer | Clemens Ladisch <clemens@ladisch.de> | 2014-01-29 14:45:51 -0500 |
commit | cf218b2ef345a26f4ae242907150035950f90cb8 (patch) | |
tree | d77dd99778d1244897de537ee698b84238c3a448 /sound | |
parent | c754639a29e8d00933ccd2d7ec41505d0074de8b (diff) |
ALSA: oxygen: Xonar DG(X): modify capture volume functions
Modify the input_vol_* functions to use the new SPI routines,
There is a new applying function that will be called when
the capture source changed.
Signed-off-by: Roman Volkov <v1ron@mail.ru>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/oxygen/xonar_dg.h | 3 | ||||
-rw-r--r-- | sound/pci/oxygen/xonar_dg_mixer.c | 31 |
2 files changed, 26 insertions, 8 deletions
diff --git a/sound/pci/oxygen/xonar_dg.h b/sound/pci/oxygen/xonar_dg.h index a5cb75121f40..a7e511026f48 100644 --- a/sound/pci/oxygen/xonar_dg.h +++ b/sound/pci/oxygen/xonar_dg.h | |||
@@ -28,7 +28,8 @@ struct dg { | |||
28 | unsigned char cs4245_shadow[17]; | 28 | unsigned char cs4245_shadow[17]; |
29 | /* output select: headphone/speakers */ | 29 | /* output select: headphone/speakers */ |
30 | unsigned char output_sel; | 30 | unsigned char output_sel; |
31 | s8 input_vol[4][2]; | 31 | /* volumes for all capture sources */ |
32 | char input_vol[4][2]; | ||
32 | unsigned int input_sel; | 33 | unsigned int input_sel; |
33 | u8 hp_vol_att; | 34 | u8 hp_vol_att; |
34 | }; | 35 | }; |
diff --git a/sound/pci/oxygen/xonar_dg_mixer.c b/sound/pci/oxygen/xonar_dg_mixer.c index 0c310e7c3a04..2417a1efd719 100644 --- a/sound/pci/oxygen/xonar_dg_mixer.c +++ b/sound/pci/oxygen/xonar_dg_mixer.c | |||
@@ -190,6 +190,21 @@ static int hp_mute_put(struct snd_kcontrol *ctl, | |||
190 | return changed; | 190 | return changed; |
191 | } | 191 | } |
192 | 192 | ||
193 | /* capture volume for all sources */ | ||
194 | |||
195 | static int input_volume_apply(struct oxygen *chip, char left, char right) | ||
196 | { | ||
197 | struct dg *data = chip->model_data; | ||
198 | int ret; | ||
199 | |||
200 | data->cs4245_shadow[CS4245_PGA_A_CTRL] = left; | ||
201 | data->cs4245_shadow[CS4245_PGA_B_CTRL] = right; | ||
202 | ret = cs4245_write_spi(chip, CS4245_PGA_A_CTRL); | ||
203 | if (ret < 0) | ||
204 | return ret; | ||
205 | return cs4245_write_spi(chip, CS4245_PGA_B_CTRL); | ||
206 | } | ||
207 | |||
193 | static int input_vol_info(struct snd_kcontrol *ctl, | 208 | static int input_vol_info(struct snd_kcontrol *ctl, |
194 | struct snd_ctl_elem_info *info) | 209 | struct snd_ctl_elem_info *info) |
195 | { | 210 | { |
@@ -221,6 +236,7 @@ static int input_vol_put(struct snd_kcontrol *ctl, | |||
221 | struct dg *data = chip->model_data; | 236 | struct dg *data = chip->model_data; |
222 | unsigned int idx = ctl->private_value; | 237 | unsigned int idx = ctl->private_value; |
223 | int changed = 0; | 238 | int changed = 0; |
239 | int ret = 0; | ||
224 | 240 | ||
225 | if (value->value.integer.value[0] < 2 * -12 || | 241 | if (value->value.integer.value[0] < 2 * -12 || |
226 | value->value.integer.value[0] > 2 * 12 || | 242 | value->value.integer.value[0] > 2 * 12 || |
@@ -234,18 +250,16 @@ static int input_vol_put(struct snd_kcontrol *ctl, | |||
234 | data->input_vol[idx][0] = value->value.integer.value[0]; | 250 | data->input_vol[idx][0] = value->value.integer.value[0]; |
235 | data->input_vol[idx][1] = value->value.integer.value[1]; | 251 | data->input_vol[idx][1] = value->value.integer.value[1]; |
236 | if (idx == data->input_sel) { | 252 | if (idx == data->input_sel) { |
237 | cs4245_write_cached(chip, CS4245_PGA_A_CTRL, | 253 | ret = input_volume_apply(chip, |
238 | data->input_vol[idx][0]); | 254 | data->input_vol[idx][0], |
239 | cs4245_write_cached(chip, CS4245_PGA_B_CTRL, | 255 | data->input_vol[idx][1]); |
240 | data->input_vol[idx][1]); | ||
241 | } | 256 | } |
257 | changed = ret >= 0 ? 1 : ret; | ||
242 | } | 258 | } |
243 | mutex_unlock(&chip->mutex); | 259 | mutex_unlock(&chip->mutex); |
244 | return changed; | 260 | return changed; |
245 | } | 261 | } |
246 | 262 | ||
247 | static DECLARE_TLV_DB_SCALE(cs4245_pga_db_scale, -1200, 50, 0); | ||
248 | |||
249 | static int input_sel_info(struct snd_kcontrol *ctl, | 263 | static int input_sel_info(struct snd_kcontrol *ctl, |
250 | struct snd_ctl_elem_info *info) | 264 | struct snd_ctl_elem_info *info) |
251 | { | 265 | { |
@@ -345,13 +359,16 @@ static int hpf_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | |||
345 | #define INPUT_VOLUME(xname, index) { \ | 359 | #define INPUT_VOLUME(xname, index) { \ |
346 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | 360 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
347 | .name = xname, \ | 361 | .name = xname, \ |
362 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | ||
363 | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ | ||
348 | .info = input_vol_info, \ | 364 | .info = input_vol_info, \ |
349 | .get = input_vol_get, \ | 365 | .get = input_vol_get, \ |
350 | .put = input_vol_put, \ | 366 | .put = input_vol_put, \ |
351 | .tlv = { .p = cs4245_pga_db_scale }, \ | 367 | .tlv = { .p = pga_db_scale }, \ |
352 | .private_value = index, \ | 368 | .private_value = index, \ |
353 | } | 369 | } |
354 | static const DECLARE_TLV_DB_MINMAX(hp_db_scale, -12550, 0); | 370 | static const DECLARE_TLV_DB_MINMAX(hp_db_scale, -12550, 0); |
371 | static const DECLARE_TLV_DB_MINMAX(pga_db_scale, -1200, 1200); | ||
355 | static const struct snd_kcontrol_new dg_controls[] = { | 372 | static const struct snd_kcontrol_new dg_controls[] = { |
356 | { | 373 | { |
357 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 374 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |