aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-05-13 03:22:43 -0400
committerJaroslav Kysela <perex@perex.cz>2008-05-19 07:19:17 -0400
commit75146fc0f9368ea41419792ac8bfdd19273b4473 (patch)
tree73d3280052d0a1e63a38c3eaf42fe80cbd616a0c /sound
parentbbbfb5526650cb9d01c5c230a4e3cbbc18474c41 (diff)
[ALSA] oxygen: separate out hardware initialization code
Create separate functions for the code that initializes the hardware, as opposed to initializing internal driver state, so that they can be reused for resume support. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/oxygen/hifier.c11
-rw-r--r--sound/pci/oxygen/oxygen.c26
-rw-r--r--sound/pci/oxygen/virtuoso.c54
3 files changed, 62 insertions, 29 deletions
diff --git a/sound/pci/oxygen/hifier.c b/sound/pci/oxygen/hifier.c
index 0e425d554505..6e45a58ad14b 100644
--- a/sound/pci/oxygen/hifier.c
+++ b/sound/pci/oxygen/hifier.c
@@ -68,15 +68,22 @@ static void update_ak4396_volume(struct oxygen *chip)
68 ak4396_write(chip, AK4396_RCH_ATT, chip->dac_volume[1]); 68 ak4396_write(chip, AK4396_RCH_ATT, chip->dac_volume[1]);
69} 69}
70 70
71static void hifier_init(struct oxygen *chip) 71static void hifier_registers_init(struct oxygen *chip)
72{ 72{
73 struct hifier_data *data = chip->model_data; 73 struct hifier_data *data = chip->model_data;
74 74
75 data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
76 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); 75 ak4396_write(chip, AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
77 ak4396_write(chip, AK4396_CONTROL_2, data->ak4396_ctl2); 76 ak4396_write(chip, AK4396_CONTROL_2, data->ak4396_ctl2);
78 ak4396_write(chip, AK4396_CONTROL_3, AK4396_PCM); 77 ak4396_write(chip, AK4396_CONTROL_3, AK4396_PCM);
79 update_ak4396_volume(chip); 78 update_ak4396_volume(chip);
79}
80
81static void hifier_init(struct oxygen *chip)
82{
83 struct hifier_data *data = chip->model_data;
84
85 data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
86 hifier_registers_init(chip);
80 87
81 snd_component_add(chip->card, "AK4396"); 88 snd_component_add(chip->card, "AK4396");
82 snd_component_add(chip->card, "CS5340"); 89 snd_component_add(chip->card, "CS5340");
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c
index ad8d950fddc6..800ae304a247 100644
--- a/sound/pci/oxygen/oxygen.c
+++ b/sound/pci/oxygen/oxygen.c
@@ -124,12 +124,11 @@ static void update_ak4396_volume(struct oxygen *chip)
124 } 124 }
125} 125}
126 126
127static void ak4396_init(struct oxygen *chip) 127static void ak4396_registers_init(struct oxygen *chip)
128{ 128{
129 struct generic_data *data = chip->model_data; 129 struct generic_data *data = chip->model_data;
130 unsigned int i; 130 unsigned int i;
131 131
132 data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
133 for (i = 0; i < 4; ++i) { 132 for (i = 0; i < 4; ++i) {
134 ak4396_write(chip, i, 133 ak4396_write(chip, i,
135 AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); 134 AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
@@ -139,6 +138,14 @@ static void ak4396_init(struct oxygen *chip)
139 AK4396_CONTROL_3, AK4396_PCM); 138 AK4396_CONTROL_3, AK4396_PCM);
140 } 139 }
141 update_ak4396_volume(chip); 140 update_ak4396_volume(chip);
141}
142
143static void ak4396_init(struct oxygen *chip)
144{
145 struct generic_data *data = chip->model_data;
146
147 data->ak4396_ctl2 = AK4396_SMUTE | AK4396_DEM_OFF | AK4396_DFS_NORMAL;
148 ak4396_registers_init(chip);
142 snd_component_add(chip->card, "AK4396"); 149 snd_component_add(chip->card, "AK4396");
143} 150}
144 151
@@ -149,18 +156,23 @@ static void ak5385_init(struct oxygen *chip)
149 snd_component_add(chip->card, "AK5385"); 156 snd_component_add(chip->card, "AK5385");
150} 157}
151 158
152static void wm8785_init(struct oxygen *chip) 159static void wm8785_registers_init(struct oxygen *chip)
153{ 160{
154 struct generic_data *data = chip->model_data; 161 struct generic_data *data = chip->model_data;
155 162
156 data->saved_wm8785_registers[0] = WM8785_MCR_SLAVE |
157 WM8785_OSR_SINGLE | WM8785_FORMAT_LJUST;
158 data->saved_wm8785_registers[1] = WM8785_WL_24;
159
160 wm8785_write(chip, WM8785_R7, 0); 163 wm8785_write(chip, WM8785_R7, 0);
161 wm8785_write(chip, WM8785_R0, data->saved_wm8785_registers[0]); 164 wm8785_write(chip, WM8785_R0, data->saved_wm8785_registers[0]);
162 wm8785_write(chip, WM8785_R1, data->saved_wm8785_registers[1]); 165 wm8785_write(chip, WM8785_R1, data->saved_wm8785_registers[1]);
166}
163 167
168static void wm8785_init(struct oxygen *chip)
169{
170 struct generic_data *data = chip->model_data;
171
172 data->saved_wm8785_registers[0] = WM8785_MCR_SLAVE |
173 WM8785_OSR_SINGLE | WM8785_FORMAT_LJUST;
174 data->saved_wm8785_registers[1] = WM8785_WL_24;
175 wm8785_registers_init(chip);
164 snd_component_add(chip->card, "WM8785"); 176 snd_component_add(chip->card, "WM8785");
165} 177}
166 178
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index bd9e28583518..e95dc5717ed7 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -204,15 +204,11 @@ static void update_pcm1796_mute(struct oxygen *chip)
204 pcm1796_write(chip, i, 18, value); 204 pcm1796_write(chip, i, 18, value);
205} 205}
206 206
207static void xonar_d2_init(struct oxygen *chip) 207static void pcm1796_init(struct oxygen *chip)
208{ 208{
209 struct xonar_data *data = chip->model_data; 209 struct xonar_data *data = chip->model_data;
210 unsigned int i; 210 unsigned int i;
211 211
212 data->anti_pop_delay = 300;
213 data->output_enable_bit = GPIO_D2_OUTPUT_ENABLE;
214 data->pcm1796_oversampling = PCM1796_OS_64;
215
216 for (i = 0; i < 4; ++i) { 212 for (i = 0; i < 4; ++i) {
217 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); 213 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1);
218 pcm1796_write(chip, i, 20, data->pcm1796_oversampling); 214 pcm1796_write(chip, i, 20, data->pcm1796_oversampling);
@@ -220,6 +216,17 @@ static void xonar_d2_init(struct oxygen *chip)
220 } 216 }
221 update_pcm1796_mute(chip); /* set ATLD before ATL/ATR */ 217 update_pcm1796_mute(chip); /* set ATLD before ATL/ATR */
222 update_pcm1796_volume(chip); 218 update_pcm1796_volume(chip);
219}
220
221static void xonar_d2_init(struct oxygen *chip)
222{
223 struct xonar_data *data = chip->model_data;
224
225 data->anti_pop_delay = 300;
226 data->output_enable_bit = GPIO_D2_OUTPUT_ENABLE;
227 data->pcm1796_oversampling = PCM1796_OS_64;
228
229 pcm1796_init(chip);
223 230
224 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2_ALT); 231 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2_ALT);
225 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_D2_ALT); 232 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_D2_ALT);
@@ -272,24 +279,10 @@ static void update_cs43xx_mute(struct oxygen *chip)
272 update_cs4362a_volumes(chip); 279 update_cs4362a_volumes(chip);
273} 280}
274 281
275static void xonar_dx_init(struct oxygen *chip) 282static void cs43xx_init(struct oxygen *chip)
276{ 283{
277 struct xonar_data *data = chip->model_data; 284 struct xonar_data *data = chip->model_data;
278 285
279 data->anti_pop_delay = 800;
280 data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE;
281 data->ext_power_reg = OXYGEN_GPI_DATA;
282 data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK;
283 data->ext_power_bit = GPI_DX_EXT_POWER;
284 data->cs4398_fm = CS4398_FM_SINGLE | CS4398_DEM_NONE | CS4398_DIF_LJUST;
285 data->cs4362a_fm = CS4362A_FM_SINGLE |
286 CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L;
287
288 oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS,
289 OXYGEN_2WIRE_LENGTH_8 |
290 OXYGEN_2WIRE_INTERRUPT_MASK |
291 OXYGEN_2WIRE_SPEED_FAST);
292
293 /* set CPEN (control port mode) and power down */ 286 /* set CPEN (control port mode) and power down */
294 cs4398_write(chip, 8, CS4398_CPEN | CS4398_PDN); 287 cs4398_write(chip, 8, CS4398_CPEN | CS4398_PDN);
295 cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN); 288 cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN);
@@ -311,6 +304,27 @@ static void xonar_dx_init(struct oxygen *chip)
311 /* clear power down */ 304 /* clear power down */
312 cs4398_write(chip, 8, CS4398_CPEN); 305 cs4398_write(chip, 8, CS4398_CPEN);
313 cs4362a_write(chip, 0x01, CS4362A_CPEN); 306 cs4362a_write(chip, 0x01, CS4362A_CPEN);
307}
308
309static void xonar_dx_init(struct oxygen *chip)
310{
311 struct xonar_data *data = chip->model_data;
312
313 data->anti_pop_delay = 800;
314 data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE;
315 data->ext_power_reg = OXYGEN_GPI_DATA;
316 data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK;
317 data->ext_power_bit = GPI_DX_EXT_POWER;
318 data->cs4398_fm = CS4398_FM_SINGLE | CS4398_DEM_NONE | CS4398_DIF_LJUST;
319 data->cs4362a_fm = CS4362A_FM_SINGLE |
320 CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L;
321
322 oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS,
323 OXYGEN_2WIRE_LENGTH_8 |
324 OXYGEN_2WIRE_INTERRUPT_MASK |
325 OXYGEN_2WIRE_SPEED_FAST);
326
327 cs43xx_init(chip);
314 328
315 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, 329 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL,
316 GPIO_DX_FRONT_PANEL | GPIO_DX_INPUT_ROUTE); 330 GPIO_DX_FRONT_PANEL | GPIO_DX_INPUT_ROUTE);