aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-05-13 03:21:48 -0400
committerJaroslav Kysela <perex@perex.cz>2008-05-19 07:19:16 -0400
commitbbbfb5526650cb9d01c5c230a4e3cbbc18474c41 (patch)
treee4e210c41214d6018dd2a623b19f65236d634b51 /sound/pci/oxygen
parente58aee95806c9d2bbcfc84cb85ce958e360165ef (diff)
[ALSA] oxygen: simplify DAC volume initialization
When initializing the DAC volume registers, we can just use the generic volume update functions instead of setting the registers manually. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/pci/oxygen')
-rw-r--r--sound/pci/oxygen/hifier.c15
-rw-r--r--sound/pci/oxygen/oxygen.c27
-rw-r--r--sound/pci/oxygen/virtuoso.c123
3 files changed, 77 insertions, 88 deletions
diff --git a/sound/pci/oxygen/hifier.c b/sound/pci/oxygen/hifier.c
index c5d2c86cacb2..0e425d554505 100644
--- a/sound/pci/oxygen/hifier.c
+++ b/sound/pci/oxygen/hifier.c
@@ -62,6 +62,12 @@ static void ak4396_write(struct oxygen *chip, u8 reg, u8 value)
62 AK4396_WRITE | (reg << 8) | value); 62 AK4396_WRITE | (reg << 8) | value);
63} 63}
64 64
65static void update_ak4396_volume(struct oxygen *chip)
66{
67 ak4396_write(chip, AK4396_LCH_ATT, chip->dac_volume[0]);
68 ak4396_write(chip, AK4396_RCH_ATT, chip->dac_volume[1]);
69}
70
65static void hifier_init(struct oxygen *chip) 71static void hifier_init(struct oxygen *chip)
66{ 72{
67 struct hifier_data *data = chip->model_data; 73 struct hifier_data *data = chip->model_data;
@@ -70,8 +76,7 @@ static void hifier_init(struct oxygen *chip)
70 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); 76 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
71 ak4396_write(chip, AK4396_CONTROL_2, data->ak4396_ctl2); 77 ak4396_write(chip, AK4396_CONTROL_2, data->ak4396_ctl2);
72 ak4396_write(chip, AK4396_CONTROL_3, AK4396_PCM); 78 ak4396_write(chip, AK4396_CONTROL_3, AK4396_PCM);
73 ak4396_write(chip, AK4396_LCH_ATT, 0); 79 update_ak4396_volume(chip);
74 ak4396_write(chip, AK4396_RCH_ATT, 0);
75 80
76 snd_component_add(chip->card, "AK4396"); 81 snd_component_add(chip->card, "AK4396");
77 snd_component_add(chip->card, "CS5340"); 82 snd_component_add(chip->card, "CS5340");
@@ -100,12 +105,6 @@ static void set_ak4396_params(struct oxygen *chip,
100 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); 105 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
101} 106}
102 107
103static void update_ak4396_volume(struct oxygen *chip)
104{
105 ak4396_write(chip, AK4396_LCH_ATT, chip->dac_volume[0]);
106 ak4396_write(chip, AK4396_RCH_ATT, chip->dac_volume[1]);
107}
108
109static void update_ak4396_mute(struct oxygen *chip) 108static void update_ak4396_mute(struct oxygen *chip)
110{ 109{
111 struct hifier_data *data = chip->model_data; 110 struct hifier_data *data = chip->model_data;
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index 8287ac28fe78..ad8d950fddc6 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -112,6 +112,18 @@ static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value)
112 data->saved_wm8785_registers[reg] = value; 112 data->saved_wm8785_registers[reg] = value;
113} 113}
114 114
115static void update_ak4396_volume(struct oxygen *chip)
116{
117 unsigned int i;
118
119 for (i = 0; i < 4; ++i) {
120 ak4396_write(chip, i,
121 AK4396_LCH_ATT, chip->dac_volume[i * 2]);
122 ak4396_write(chip, i,
123 AK4396_RCH_ATT, chip->dac_volume[i * 2 + 1]);
124 }
125}
126
115static void ak4396_init(struct oxygen *chip) 127static void ak4396_init(struct oxygen *chip)
116{ 128{
117 struct generic_data *data = chip->model_data; 129 struct generic_data *data = chip->model_data;
@@ -125,9 +137,8 @@ static void ak4396_init(struct oxygen *chip)
125 AK4396_CONTROL_2, data->ak4396_ctl2); 137 AK4396_CONTROL_2, data->ak4396_ctl2);
126 ak4396_write(chip, i, 138 ak4396_write(chip, i,
127 AK4396_CONTROL_3, AK4396_PCM); 139 AK4396_CONTROL_3, AK4396_PCM);
128 ak4396_write(chip, i, AK4396_LCH_ATT, 0);
129 ak4396_write(chip, i, AK4396_RCH_ATT, 0);
130 } 140 }
141 update_ak4396_volume(chip);
131 snd_component_add(chip->card, "AK4396"); 142 snd_component_add(chip->card, "AK4396");
132} 143}
133 144
@@ -194,18 +205,6 @@ static void set_ak4396_params(struct oxygen *chip,
194 } 205 }
195} 206}
196 207
197static void update_ak4396_volume(struct oxygen *chip)
198{
199 unsigned int i;
200
201 for (i = 0; i < 4; ++i) {
202 ak4396_write(chip, i,
203 AK4396_LCH_ATT, chip->dac_volume[i * 2]);
204 ak4396_write(chip, i,
205 AK4396_RCH_ATT, chip->dac_volume[i * 2 + 1]);
206 }
207}
208
209static void update_ak4396_mute(struct oxygen *chip) 208static void update_ak4396_mute(struct oxygen *chip)
210{ 209{
211 struct generic_data *data = chip->model_data; 210 struct generic_data *data = chip->model_data;
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 110786b2e3b8..bd9e28583518 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -182,6 +182,28 @@ static void xonar_common_init(struct oxygen *chip)
182 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit); 182 oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit);
183} 183}
184 184
185static void update_pcm1796_volume(struct oxygen *chip)
186{
187 unsigned int i;
188
189 for (i = 0; i < 4; ++i) {
190 pcm1796_write(chip, i, 16, chip->dac_volume[i * 2]);
191 pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]);
192 }
193}
194
195static void update_pcm1796_mute(struct oxygen *chip)
196{
197 unsigned int i;
198 u8 value;
199
200 value = PCM1796_DMF_DISABLED | PCM1796_FMT_24_LJUST | PCM1796_ATLD;
201 if (chip->dac_mute)
202 value |= PCM1796_MUTE;
203 for (i = 0; i < 4; ++i)
204 pcm1796_write(chip, i, 18, value);
205}
206
185static void xonar_d2_init(struct oxygen *chip) 207static void xonar_d2_init(struct oxygen *chip)
186{ 208{
187 struct xonar_data *data = chip->model_data; 209 struct xonar_data *data = chip->model_data;
@@ -192,14 +214,12 @@ static void xonar_d2_init(struct oxygen *chip)
192 data->pcm1796_oversampling = PCM1796_OS_64; 214 data->pcm1796_oversampling = PCM1796_OS_64;
193 215
194 for (i = 0; i < 4; ++i) { 216 for (i = 0; i < 4; ++i) {
195 pcm1796_write(chip, i, 18, PCM1796_MUTE | PCM1796_DMF_DISABLED |
196 PCM1796_FMT_24_LJUST | PCM1796_ATLD);
197 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); 217 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1);
198 pcm1796_write(chip, i, 20, data->pcm1796_oversampling); 218 pcm1796_write(chip, i, 20, data->pcm1796_oversampling);
199 pcm1796_write(chip, i, 21, 0); 219 pcm1796_write(chip, i, 21, 0);
200 pcm1796_write(chip, i, 16, 0x0f); /* set ATL/ATR after ATLD */
201 pcm1796_write(chip, i, 17, 0x0f);
202 } 220 }
221 update_pcm1796_mute(chip); /* set ATLD before ATL/ATR */
222 update_pcm1796_volume(chip);
203 223
204 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2_ALT); 224 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2_ALT);
205 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_D2_ALT); 225 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_D2_ALT);
@@ -221,6 +241,37 @@ static void xonar_d2x_init(struct oxygen *chip)
221 xonar_d2_init(chip); 241 xonar_d2_init(chip);
222} 242}
223 243
244static void update_cs4362a_volumes(struct oxygen *chip)
245{
246 u8 mute;
247
248 mute = chip->dac_mute ? CS4362A_MUTE : 0;
249 cs4362a_write(chip, 7, (127 - chip->dac_volume[2]) | mute);
250 cs4362a_write(chip, 8, (127 - chip->dac_volume[3]) | mute);
251 cs4362a_write(chip, 10, (127 - chip->dac_volume[4]) | mute);
252 cs4362a_write(chip, 11, (127 - chip->dac_volume[5]) | mute);
253 cs4362a_write(chip, 13, (127 - chip->dac_volume[6]) | mute);
254 cs4362a_write(chip, 14, (127 - chip->dac_volume[7]) | mute);
255}
256
257static void update_cs43xx_volume(struct oxygen *chip)
258{
259 cs4398_write(chip, 5, (127 - chip->dac_volume[0]) * 2);
260 cs4398_write(chip, 6, (127 - chip->dac_volume[1]) * 2);
261 update_cs4362a_volumes(chip);
262}
263
264static void update_cs43xx_mute(struct oxygen *chip)
265{
266 u8 reg;
267
268 reg = CS4398_MUTEP_LOW | CS4398_PAMUTE;
269 if (chip->dac_mute)
270 reg |= CS4398_MUTE_B | CS4398_MUTE_A;
271 cs4398_write(chip, 4, reg);
272 update_cs4362a_volumes(chip);
273}
274
224static void xonar_dx_init(struct oxygen *chip) 275static void xonar_dx_init(struct oxygen *chip)
225{ 276{
226 struct xonar_data *data = chip->model_data; 277 struct xonar_data *data = chip->model_data;
@@ -245,9 +296,6 @@ static void xonar_dx_init(struct oxygen *chip)
245 /* configure */ 296 /* configure */
246 cs4398_write(chip, 2, data->cs4398_fm); 297 cs4398_write(chip, 2, data->cs4398_fm);
247 cs4398_write(chip, 3, CS4398_ATAPI_B_R | CS4398_ATAPI_A_L); 298 cs4398_write(chip, 3, CS4398_ATAPI_B_R | CS4398_ATAPI_A_L);
248 cs4398_write(chip, 4, CS4398_MUTEP_LOW | CS4398_PAMUTE);
249 cs4398_write(chip, 5, 0xfe);
250 cs4398_write(chip, 6, 0xfe);
251 cs4398_write(chip, 7, CS4398_RMP_DN | CS4398_RMP_UP | 299 cs4398_write(chip, 7, CS4398_RMP_DN | CS4398_RMP_UP |
252 CS4398_ZERO_CROSS | CS4398_SOFT_RAMP); 300 CS4398_ZERO_CROSS | CS4398_SOFT_RAMP);
253 cs4362a_write(chip, 0x02, CS4362A_DIF_LJUST); 301 cs4362a_write(chip, 0x02, CS4362A_DIF_LJUST);
@@ -256,14 +304,10 @@ static void xonar_dx_init(struct oxygen *chip)
256 cs4362a_write(chip, 0x04, CS4362A_RMP_DN | CS4362A_DEM_NONE); 304 cs4362a_write(chip, 0x04, CS4362A_RMP_DN | CS4362A_DEM_NONE);
257 cs4362a_write(chip, 0x05, 0); 305 cs4362a_write(chip, 0x05, 0);
258 cs4362a_write(chip, 0x06, data->cs4362a_fm); 306 cs4362a_write(chip, 0x06, data->cs4362a_fm);
259 cs4362a_write(chip, 0x07, 0x7f | CS4362A_MUTE);
260 cs4362a_write(chip, 0x08, 0x7f | CS4362A_MUTE);
261 cs4362a_write(chip, 0x09, data->cs4362a_fm); 307 cs4362a_write(chip, 0x09, data->cs4362a_fm);
262 cs4362a_write(chip, 0x0a, 0x7f | CS4362A_MUTE);
263 cs4362a_write(chip, 0x0b, 0x7f | CS4362A_MUTE);
264 cs4362a_write(chip, 0x0c, data->cs4362a_fm); 308 cs4362a_write(chip, 0x0c, data->cs4362a_fm);
265 cs4362a_write(chip, 0x0d, 0x7f | CS4362A_MUTE); 309 update_cs43xx_volume(chip);
266 cs4362a_write(chip, 0x0e, 0x7f | CS4362A_MUTE); 310 update_cs43xx_mute(chip);
267 /* clear power down */ 311 /* clear power down */
268 cs4398_write(chip, 8, CS4398_CPEN); 312 cs4398_write(chip, 8, CS4398_CPEN);
269 cs4362a_write(chip, 0x01, CS4362A_CPEN); 313 cs4362a_write(chip, 0x01, CS4362A_CPEN);
@@ -306,28 +350,6 @@ static void set_pcm1796_params(struct oxygen *chip,
306 pcm1796_write(chip, i, 20, data->pcm1796_oversampling); 350 pcm1796_write(chip, i, 20, data->pcm1796_oversampling);
307} 351}
308 352
309static void update_pcm1796_volume(struct oxygen *chip)
310{
311 unsigned int i;
312
313 for (i = 0; i < 4; ++i) {
314 pcm1796_write(chip, i, 16, chip->dac_volume[i * 2]);
315 pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]);
316 }
317}
318
319static void update_pcm1796_mute(struct oxygen *chip)
320{
321 unsigned int i;
322 u8 value;
323
324 value = PCM1796_FMT_24_LJUST | PCM1796_ATLD;
325 if (chip->dac_mute)
326 value |= PCM1796_MUTE;
327 for (i = 0; i < 4; ++i)
328 pcm1796_write(chip, i, 18, value);
329}
330
331static void set_cs53x1_params(struct oxygen *chip, 353static void set_cs53x1_params(struct oxygen *chip,
332 struct snd_pcm_hw_params *params) 354 struct snd_pcm_hw_params *params)
333{ 355{
@@ -366,37 +388,6 @@ static void set_cs43xx_params(struct oxygen *chip,
366 cs4362a_write(chip, 0x0c, data->cs4362a_fm); 388 cs4362a_write(chip, 0x0c, data->cs4362a_fm);
367} 389}
368 390
369static void update_cs4362a_volumes(struct oxygen *chip)
370{
371 u8 mute;
372
373 mute = chip->dac_mute ? CS4362A_MUTE : 0;
374 cs4362a_write(chip, 7, (127 - chip->dac_volume[2]) | mute);
375 cs4362a_write(chip, 8, (127 - chip->dac_volume[3]) | mute);
376 cs4362a_write(chip, 10, (127 - chip->dac_volume[4]) | mute);
377 cs4362a_write(chip, 11, (127 - chip->dac_volume[5]) | mute);
378 cs4362a_write(chip, 13, (127 - chip->dac_volume[6]) | mute);
379 cs4362a_write(chip, 14, (127 - chip->dac_volume[7]) | mute);
380}
381
382static void update_cs43xx_volume(struct oxygen *chip)
383{
384 cs4398_write(chip, 5, (127 - chip->dac_volume[0]) * 2);
385 cs4398_write(chip, 6, (127 - chip->dac_volume[1]) * 2);
386 update_cs4362a_volumes(chip);
387}
388
389static void update_cs43xx_mute(struct oxygen *chip)
390{
391 u8 reg;
392
393 reg = CS4398_MUTEP_LOW | CS4398_PAMUTE;
394 if (chip->dac_mute)
395 reg |= CS4398_MUTE_B | CS4398_MUTE_A;
396 cs4398_write(chip, 4, reg);
397 update_cs4362a_volumes(chip);
398}
399
400static void xonar_gpio_changed(struct oxygen *chip) 391static void xonar_gpio_changed(struct oxygen *chip)
401{ 392{
402 struct xonar_data *data = chip->model_data; 393 struct xonar_data *data = chip->model_data;