aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/oxygen
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2008-04-07 04:24:22 -0400
committerTakashi Iwai <tiwai@suse.de>2008-04-24 06:00:31 -0400
commit271ebfca5823875cc4f134515b6c3887d99b8dc2 (patch)
treedfea6aa149e5fdff918b90edca498bd37ce07a44 /sound/pci/oxygen
parent10e6d5f9b6edd4a12d678716d7fdb94278a83227 (diff)
[ALSA] virtuoso: separate D2/D2X init functions
Use separate model structures for the D2 and D2X so that the init function does not have to check for the model again. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/oxygen')
-rw-r--r--sound/pci/oxygen/virtuoso.c118
1 files changed, 74 insertions, 44 deletions
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c
index 2c3daf3ae4c3..b3259fa0a0b6 100644
--- a/sound/pci/oxygen/virtuoso.c
+++ b/sound/pci/oxygen/virtuoso.c
@@ -61,9 +61,14 @@ MODULE_PARM_DESC(id, "ID string");
61module_param_array(enable, bool, NULL, 0444); 61module_param_array(enable, bool, NULL, 0444);
62MODULE_PARM_DESC(enable, "enable card"); 62MODULE_PARM_DESC(enable, "enable card");
63 63
64enum {
65 MODEL_D2,
66 MODEL_D2X,
67};
68
64static struct pci_device_id xonar_ids[] __devinitdata = { 69static struct pci_device_id xonar_ids[] __devinitdata = {
65 { OXYGEN_PCI_SUBID(0x1043, 0x8269) }, /* Asus Xonar D2 */ 70 { OXYGEN_PCI_SUBID(0x1043, 0x8269), .driver_data = MODEL_D2 },
66 { OXYGEN_PCI_SUBID(0x1043, 0x82b7) }, /* Asus Xonar D2X */ 71 { OXYGEN_PCI_SUBID(0x1043, 0x82b7), .driver_data = MODEL_D2X },
67 { } 72 { }
68}; 73};
69MODULE_DEVICE_TABLE(pci, xonar_ids); 74MODULE_DEVICE_TABLE(pci, xonar_ids);
@@ -78,7 +83,6 @@ MODULE_DEVICE_TABLE(pci, xonar_ids);
78#define GPIO_OUTPUT_ENABLE 0x0100 83#define GPIO_OUTPUT_ENABLE 0x0100
79 84
80struct xonar_data { 85struct xonar_data {
81 u8 is_d2x;
82 u8 has_power; 86 u8 has_power;
83}; 87};
84 88
@@ -97,13 +101,10 @@ static void pcm1796_write(struct oxygen *chip, unsigned int codec,
97 (reg << 8) | value); 101 (reg << 8) | value);
98} 102}
99 103
100static void xonar_init(struct oxygen *chip) 104static void xonar_d2_init(struct oxygen *chip)
101{ 105{
102 struct xonar_data *data = chip->model_data;
103 unsigned int i; 106 unsigned int i;
104 107
105 data->is_d2x = chip->pci->subsystem_device == 0x82b7;
106
107 for (i = 0; i < 4; ++i) { 108 for (i = 0; i < 4; ++i) {
108 pcm1796_write(chip, i, 18, PCM1796_FMT_24_LJUST | PCM1796_ATLD); 109 pcm1796_write(chip, i, 18, PCM1796_FMT_24_LJUST | PCM1796_ATLD);
109 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); 110 pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1);
@@ -118,15 +119,6 @@ static void xonar_init(struct oxygen *chip)
118 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA, 119 oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
119 GPIO_CS5381_M_SINGLE, 120 GPIO_CS5381_M_SINGLE,
120 GPIO_CS5381_M_MASK | GPIO_ALT); 121 GPIO_CS5381_M_MASK | GPIO_ALT);
121 if (data->is_d2x) {
122 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL,
123 GPIO_EXT_POWER);
124 oxygen_set_bits16(chip, OXYGEN_GPIO_INTERRUPT_MASK,
125 GPIO_EXT_POWER);
126 chip->interrupt_mask |= OXYGEN_INT_GPIO;
127 data->has_power = !!(oxygen_read16(chip, OXYGEN_GPIO_DATA)
128 & GPIO_EXT_POWER);
129 }
130 oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC); 122 oxygen_ac97_set_bits(chip, 0, CM9780_JACK, CM9780_FMIC2MIC);
131 msleep(300); 123 msleep(300);
132 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_OUTPUT_ENABLE); 124 oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_OUTPUT_ENABLE);
@@ -136,6 +128,18 @@ static void xonar_init(struct oxygen *chip)
136 snd_component_add(chip->card, "CS5381"); 128 snd_component_add(chip->card, "CS5381");
137} 129}
138 130
131static void xonar_d2x_init(struct oxygen *chip)
132{
133 struct xonar_data *data = chip->model_data;
134
135 xonar_d2_init(chip);
136 oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_EXT_POWER);
137 oxygen_set_bits16(chip, OXYGEN_GPIO_INTERRUPT_MASK, GPIO_EXT_POWER);
138 chip->interrupt_mask |= OXYGEN_INT_GPIO;
139 data->has_power = !!(oxygen_read16(chip, OXYGEN_GPIO_DATA)
140 & GPIO_EXT_POWER);
141}
142
139static void xonar_cleanup(struct oxygen *chip) 143static void xonar_cleanup(struct oxygen *chip)
140{ 144{
141 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE); 145 oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_OUTPUT_ENABLE);
@@ -196,8 +200,6 @@ static void xonar_gpio_changed(struct oxygen *chip)
196 struct xonar_data *data = chip->model_data; 200 struct xonar_data *data = chip->model_data;
197 u8 has_power; 201 u8 has_power;
198 202
199 if (!data->is_d2x)
200 return;
201 has_power = !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) 203 has_power = !!(oxygen_read16(chip, OXYGEN_GPIO_DATA)
202 & GPIO_EXT_POWER); 204 & GPIO_EXT_POWER);
203 if (has_power != data->has_power) { 205 if (has_power != data->has_power) {
@@ -280,31 +282,58 @@ static int xonar_mixer_init(struct oxygen *chip)
280 return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip)); 282 return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip));
281} 283}
282 284
283static const struct oxygen_model model_xonar = { 285static const struct oxygen_model xonar_models[] = {
284 .shortname = "Asus AV200", 286 [MODEL_D2] = {
285 .longname = "Asus Virtuoso 200", 287 .shortname = "Asus AV200",
286 .chip = "AV200", 288 .longname = "Asus Virtuoso 200",
287 .owner = THIS_MODULE, 289 .chip = "AV200",
288 .init = xonar_init, 290 .owner = THIS_MODULE,
289 .control_filter = xonar_control_filter, 291 .init = xonar_d2_init,
290 .mixer_init = xonar_mixer_init, 292 .control_filter = xonar_control_filter,
291 .cleanup = xonar_cleanup, 293 .mixer_init = xonar_mixer_init,
292 .set_dac_params = set_pcm1796_params, 294 .cleanup = xonar_cleanup,
293 .set_adc_params = set_cs5381_params, 295 .set_dac_params = set_pcm1796_params,
294 .update_dac_volume = update_pcm1796_volume, 296 .set_adc_params = set_cs5381_params,
295 .update_dac_mute = update_pcm1796_mute, 297 .update_dac_volume = update_pcm1796_volume,
296 .gpio_changed = xonar_gpio_changed, 298 .update_dac_mute = update_pcm1796_mute,
297 .model_data_size = sizeof(struct xonar_data), 299 .model_data_size = sizeof(struct xonar_data),
298 .pcm_dev_cfg = PLAYBACK_0_TO_I2S | 300 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
299 PLAYBACK_1_TO_SPDIF | 301 PLAYBACK_1_TO_SPDIF |
300 CAPTURE_0_FROM_I2S_2 | 302 CAPTURE_0_FROM_I2S_2 |
301 CAPTURE_1_FROM_SPDIF, 303 CAPTURE_1_FROM_SPDIF,
302 .dac_channels = 8, 304 .dac_channels = 8,
303 .misc_flags = OXYGEN_MISC_MIDI, 305 .misc_flags = OXYGEN_MISC_MIDI,
304 .function_flags = OXYGEN_FUNCTION_SPI | 306 .function_flags = OXYGEN_FUNCTION_SPI |
305 OXYGEN_FUNCTION_ENABLE_SPI_4_5, 307 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
306 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 308 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
307 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, 309 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
310 },
311 [MODEL_D2X] = {
312 .shortname = "Asus AV200",
313 .longname = "Asus Virtuoso 200",
314 .chip = "AV200",
315 .owner = THIS_MODULE,
316 .init = xonar_d2x_init,
317 .control_filter = xonar_control_filter,
318 .mixer_init = xonar_mixer_init,
319 .cleanup = xonar_cleanup,
320 .set_dac_params = set_pcm1796_params,
321 .set_adc_params = set_cs5381_params,
322 .update_dac_volume = update_pcm1796_volume,
323 .update_dac_mute = update_pcm1796_mute,
324 .gpio_changed = xonar_gpio_changed,
325 .model_data_size = sizeof(struct xonar_data),
326 .pcm_dev_cfg = PLAYBACK_0_TO_I2S |
327 PLAYBACK_1_TO_SPDIF |
328 CAPTURE_0_FROM_I2S_2 |
329 CAPTURE_1_FROM_SPDIF,
330 .dac_channels = 8,
331 .misc_flags = OXYGEN_MISC_MIDI,
332 .function_flags = OXYGEN_FUNCTION_SPI |
333 OXYGEN_FUNCTION_ENABLE_SPI_4_5,
334 .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
335 .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST,
336 },
308}; 337};
309 338
310static int __devinit xonar_probe(struct pci_dev *pci, 339static int __devinit xonar_probe(struct pci_dev *pci,
@@ -319,7 +348,8 @@ static int __devinit xonar_probe(struct pci_dev *pci,
319 ++dev; 348 ++dev;
320 return -ENOENT; 349 return -ENOENT;
321 } 350 }
322 err = oxygen_pci_probe(pci, index[dev], id[dev], &model_xonar); 351 err = oxygen_pci_probe(pci, index[dev], id[dev],
352 &xonar_models[pci_id->driver_data]);
323 if (err >= 0) 353 if (err >= 0)
324 ++dev; 354 ++dev;
325 return err; 355 return err;