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>

authored by Roman Volkov and committed by Clemens Ladisch cf218b2e c754639a

+26 -8
+2 -1
sound/pci/oxygen/xonar_dg.h
··· 28 28 unsigned char cs4245_shadow[17]; 29 29 /* output select: headphone/speakers */ 30 30 unsigned char output_sel; 31 - s8 input_vol[4][2]; 31 + /* volumes for all capture sources */ 32 + char input_vol[4][2]; 32 33 unsigned int input_sel; 33 34 u8 hp_vol_att; 34 35 };
+24 -7
sound/pci/oxygen/xonar_dg_mixer.c
··· 190 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 208 static int input_vol_info(struct snd_kcontrol *ctl, 194 209 struct snd_ctl_elem_info *info) 195 210 { ··· 236 221 struct dg *data = chip->model_data; 237 222 unsigned int idx = ctl->private_value; 238 223 int changed = 0; 224 + int ret = 0; 239 225 240 226 if (value->value.integer.value[0] < 2 * -12 || 241 227 value->value.integer.value[0] > 2 * 12 || ··· 250 234 data->input_vol[idx][0] = value->value.integer.value[0]; 251 235 data->input_vol[idx][1] = value->value.integer.value[1]; 252 236 if (idx == data->input_sel) { 253 - cs4245_write_cached(chip, CS4245_PGA_A_CTRL, 254 - data->input_vol[idx][0]); 255 - cs4245_write_cached(chip, CS4245_PGA_B_CTRL, 256 - data->input_vol[idx][1]); 237 + ret = input_volume_apply(chip, 238 + data->input_vol[idx][0], 239 + data->input_vol[idx][1]); 257 240 } 241 + changed = ret >= 0 ? 1 : ret; 258 242 } 259 243 mutex_unlock(&chip->mutex); 260 244 return changed; 261 245 } 262 - 263 - static DECLARE_TLV_DB_SCALE(cs4245_pga_db_scale, -1200, 50, 0); 264 246 265 247 static int input_sel_info(struct snd_kcontrol *ctl, 266 248 struct snd_ctl_elem_info *info) ··· 359 345 #define INPUT_VOLUME(xname, index) { \ 360 346 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 361 347 .name = xname, \ 348 + .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ 349 + SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ 362 350 .info = input_vol_info, \ 363 351 .get = input_vol_get, \ 364 352 .put = input_vol_put, \ 365 - .tlv = { .p = cs4245_pga_db_scale }, \ 353 + .tlv = { .p = pga_db_scale }, \ 366 354 .private_value = index, \ 367 355 } 368 356 static const DECLARE_TLV_DB_MINMAX(hp_db_scale, -12550, 0); 357 + static const DECLARE_TLV_DB_MINMAX(pga_db_scale, -1200, 1200); 369 358 static const struct snd_kcontrol_new dg_controls[] = { 370 359 { 371 360 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,