diff options
Diffstat (limited to 'sound/pci/oxygen')
-rw-r--r-- | sound/pci/oxygen/hifier.c | 15 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen.c | 92 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen.h | 103 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_io.c | 22 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_lib.c | 101 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_mixer.c | 48 | ||||
-rw-r--r-- | sound/pci/oxygen/oxygen_pcm.c | 47 | ||||
-rw-r--r-- | sound/pci/oxygen/virtuoso.c | 594 |
8 files changed, 664 insertions, 358 deletions
diff --git a/sound/pci/oxygen/hifier.c b/sound/pci/oxygen/hifier.c index dad393ae040a..1ab833f843eb 100644 --- a/sound/pci/oxygen/hifier.c +++ b/sound/pci/oxygen/hifier.c | |||
@@ -94,6 +94,11 @@ static void hifier_cleanup(struct oxygen *chip) | |||
94 | { | 94 | { |
95 | } | 95 | } |
96 | 96 | ||
97 | static void hifier_resume(struct oxygen *chip) | ||
98 | { | ||
99 | hifier_registers_init(chip); | ||
100 | } | ||
101 | |||
97 | static void set_ak4396_params(struct oxygen *chip, | 102 | static void set_ak4396_params(struct oxygen *chip, |
98 | struct snd_pcm_hw_params *params) | 103 | struct snd_pcm_hw_params *params) |
99 | { | 104 | { |
@@ -150,16 +155,16 @@ static const struct oxygen_model model_hifier = { | |||
150 | .init = hifier_init, | 155 | .init = hifier_init, |
151 | .control_filter = hifier_control_filter, | 156 | .control_filter = hifier_control_filter, |
152 | .cleanup = hifier_cleanup, | 157 | .cleanup = hifier_cleanup, |
153 | .resume = hifier_registers_init, | 158 | .resume = hifier_resume, |
154 | .set_dac_params = set_ak4396_params, | 159 | .set_dac_params = set_ak4396_params, |
155 | .set_adc_params = set_cs5340_params, | 160 | .set_adc_params = set_cs5340_params, |
156 | .update_dac_volume = update_ak4396_volume, | 161 | .update_dac_volume = update_ak4396_volume, |
157 | .update_dac_mute = update_ak4396_mute, | 162 | .update_dac_mute = update_ak4396_mute, |
158 | .dac_tlv = ak4396_db_scale, | 163 | .dac_tlv = ak4396_db_scale, |
159 | .model_data_size = sizeof(struct hifier_data), | 164 | .model_data_size = sizeof(struct hifier_data), |
160 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | | 165 | .device_config = PLAYBACK_0_TO_I2S | |
161 | PLAYBACK_1_TO_SPDIF | | 166 | PLAYBACK_1_TO_SPDIF | |
162 | CAPTURE_0_FROM_I2S_1, | 167 | CAPTURE_0_FROM_I2S_1, |
163 | .dac_channels = 2, | 168 | .dac_channels = 2, |
164 | .dac_volume_min = 0, | 169 | .dac_volume_min = 0, |
165 | .dac_volume_max = 255, | 170 | .dac_volume_max = 255, |
@@ -180,7 +185,7 @@ static int __devinit hifier_probe(struct pci_dev *pci, | |||
180 | ++dev; | 185 | ++dev; |
181 | return -ENOENT; | 186 | return -ENOENT; |
182 | } | 187 | } |
183 | err = oxygen_pci_probe(pci, index[dev], id[dev], &model_hifier); | 188 | err = oxygen_pci_probe(pci, index[dev], id[dev], &model_hifier, 0); |
184 | if (err >= 0) | 189 | if (err >= 0) |
185 | ++dev; | 190 | ++dev; |
186 | return err; | 191 | return err; |
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c index c5829d30ef86..b60f6212745a 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c | |||
@@ -58,17 +58,22 @@ MODULE_PARM_DESC(id, "ID string"); | |||
58 | module_param_array(enable, bool, NULL, 0444); | 58 | module_param_array(enable, bool, NULL, 0444); |
59 | MODULE_PARM_DESC(enable, "enable card"); | 59 | MODULE_PARM_DESC(enable, "enable card"); |
60 | 60 | ||
61 | enum { | ||
62 | MODEL_CMEDIA_REF, /* C-Media's reference design */ | ||
63 | MODEL_MERIDIAN, /* AuzenTech X-Meridian */ | ||
64 | }; | ||
65 | |||
61 | static struct pci_device_id oxygen_ids[] __devinitdata = { | 66 | static struct pci_device_id oxygen_ids[] __devinitdata = { |
62 | { OXYGEN_PCI_SUBID(0x10b0, 0x0216) }, | 67 | { OXYGEN_PCI_SUBID(0x10b0, 0x0216), .driver_data = MODEL_CMEDIA_REF }, |
63 | { OXYGEN_PCI_SUBID(0x10b0, 0x0218) }, | 68 | { OXYGEN_PCI_SUBID(0x10b0, 0x0218), .driver_data = MODEL_CMEDIA_REF }, |
64 | { OXYGEN_PCI_SUBID(0x10b0, 0x0219) }, | 69 | { OXYGEN_PCI_SUBID(0x10b0, 0x0219), .driver_data = MODEL_CMEDIA_REF }, |
65 | { OXYGEN_PCI_SUBID(0x13f6, 0x0001) }, | 70 | { OXYGEN_PCI_SUBID(0x13f6, 0x0001), .driver_data = MODEL_CMEDIA_REF }, |
66 | { OXYGEN_PCI_SUBID(0x13f6, 0x0010) }, | 71 | { OXYGEN_PCI_SUBID(0x13f6, 0x0010), .driver_data = MODEL_CMEDIA_REF }, |
67 | { OXYGEN_PCI_SUBID(0x13f6, 0x8788) }, | 72 | { OXYGEN_PCI_SUBID(0x13f6, 0x8788), .driver_data = MODEL_CMEDIA_REF }, |
68 | { OXYGEN_PCI_SUBID(0x147a, 0xa017) }, | 73 | { OXYGEN_PCI_SUBID(0x147a, 0xa017), .driver_data = MODEL_CMEDIA_REF }, |
69 | { OXYGEN_PCI_SUBID(0x1a58, 0x0910) }, | 74 | { OXYGEN_PCI_SUBID(0x1a58, 0x0910), .driver_data = MODEL_CMEDIA_REF }, |
70 | { OXYGEN_PCI_SUBID(0x415a, 0x5431), .driver_data = 1 }, | 75 | { OXYGEN_PCI_SUBID(0x415a, 0x5431), .driver_data = MODEL_MERIDIAN }, |
71 | { OXYGEN_PCI_SUBID(0x7284, 0x9761) }, | 76 | { OXYGEN_PCI_SUBID(0x7284, 0x9761), .driver_data = MODEL_CMEDIA_REF }, |
72 | { } | 77 | { } |
73 | }; | 78 | }; |
74 | MODULE_DEVICE_TABLE(pci, oxygen_ids); | 79 | MODULE_DEVICE_TABLE(pci, oxygen_ids); |
@@ -199,6 +204,11 @@ static void generic_resume(struct oxygen *chip) | |||
199 | wm8785_registers_init(chip); | 204 | wm8785_registers_init(chip); |
200 | } | 205 | } |
201 | 206 | ||
207 | static void meridian_resume(struct oxygen *chip) | ||
208 | { | ||
209 | ak4396_registers_init(chip); | ||
210 | } | ||
211 | |||
202 | static void set_ak4396_params(struct oxygen *chip, | 212 | static void set_ak4396_params(struct oxygen *chip, |
203 | struct snd_pcm_hw_params *params) | 213 | struct snd_pcm_hw_params *params) |
204 | { | 214 | { |
@@ -281,11 +291,28 @@ static void set_ak5385_params(struct oxygen *chip, | |||
281 | 291 | ||
282 | static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); | 292 | static const DECLARE_TLV_DB_LINEAR(ak4396_db_scale, TLV_DB_GAIN_MUTE, 0); |
283 | 293 | ||
294 | static int generic_probe(struct oxygen *chip, unsigned long driver_data) | ||
295 | { | ||
296 | if (driver_data == MODEL_MERIDIAN) { | ||
297 | chip->model.init = meridian_init; | ||
298 | chip->model.resume = meridian_resume; | ||
299 | chip->model.set_adc_params = set_ak5385_params; | ||
300 | chip->model.device_config = PLAYBACK_0_TO_I2S | | ||
301 | PLAYBACK_1_TO_SPDIF | | ||
302 | CAPTURE_0_FROM_I2S_2 | | ||
303 | CAPTURE_1_FROM_SPDIF; | ||
304 | chip->model.misc_flags = OXYGEN_MISC_MIDI; | ||
305 | chip->model.device_config |= MIDI_OUTPUT | MIDI_INPUT; | ||
306 | } | ||
307 | return 0; | ||
308 | } | ||
309 | |||
284 | static const struct oxygen_model model_generic = { | 310 | static const struct oxygen_model model_generic = { |
285 | .shortname = "C-Media CMI8788", | 311 | .shortname = "C-Media CMI8788", |
286 | .longname = "C-Media Oxygen HD Audio", | 312 | .longname = "C-Media Oxygen HD Audio", |
287 | .chip = "CMI8788", | 313 | .chip = "CMI8788", |
288 | .owner = THIS_MODULE, | 314 | .owner = THIS_MODULE, |
315 | .probe = generic_probe, | ||
289 | .init = generic_init, | 316 | .init = generic_init, |
290 | .cleanup = generic_cleanup, | 317 | .cleanup = generic_cleanup, |
291 | .resume = generic_resume, | 318 | .resume = generic_resume, |
@@ -295,44 +322,15 @@ static const struct oxygen_model model_generic = { | |||
295 | .update_dac_mute = update_ak4396_mute, | 322 | .update_dac_mute = update_ak4396_mute, |
296 | .dac_tlv = ak4396_db_scale, | 323 | .dac_tlv = ak4396_db_scale, |
297 | .model_data_size = sizeof(struct generic_data), | 324 | .model_data_size = sizeof(struct generic_data), |
298 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | | 325 | .device_config = PLAYBACK_0_TO_I2S | |
299 | PLAYBACK_1_TO_SPDIF | | 326 | PLAYBACK_1_TO_SPDIF | |
300 | PLAYBACK_2_TO_AC97_1 | | 327 | PLAYBACK_2_TO_AC97_1 | |
301 | CAPTURE_0_FROM_I2S_1 | | 328 | CAPTURE_0_FROM_I2S_1 | |
302 | CAPTURE_1_FROM_SPDIF | | 329 | CAPTURE_1_FROM_SPDIF | |
303 | CAPTURE_2_FROM_AC97_1, | 330 | CAPTURE_2_FROM_AC97_1, |
304 | .dac_channels = 8, | ||
305 | .dac_volume_min = 0, | ||
306 | .dac_volume_max = 255, | ||
307 | .function_flags = OXYGEN_FUNCTION_SPI | | ||
308 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, | ||
309 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
310 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
311 | }; | ||
312 | static const struct oxygen_model model_meridian = { | ||
313 | .shortname = "C-Media CMI8788", | ||
314 | .longname = "C-Media Oxygen HD Audio", | ||
315 | .chip = "CMI8788", | ||
316 | .owner = THIS_MODULE, | ||
317 | .init = meridian_init, | ||
318 | .cleanup = generic_cleanup, | ||
319 | .resume = ak4396_registers_init, | ||
320 | .set_dac_params = set_ak4396_params, | ||
321 | .set_adc_params = set_ak5385_params, | ||
322 | .update_dac_volume = update_ak4396_volume, | ||
323 | .update_dac_mute = update_ak4396_mute, | ||
324 | .dac_tlv = ak4396_db_scale, | ||
325 | .model_data_size = sizeof(struct generic_data), | ||
326 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | | ||
327 | PLAYBACK_1_TO_SPDIF | | ||
328 | PLAYBACK_2_TO_AC97_1 | | ||
329 | CAPTURE_0_FROM_I2S_2 | | ||
330 | CAPTURE_1_FROM_SPDIF | | ||
331 | CAPTURE_2_FROM_AC97_1, | ||
332 | .dac_channels = 8, | 331 | .dac_channels = 8, |
333 | .dac_volume_min = 0, | 332 | .dac_volume_min = 0, |
334 | .dac_volume_max = 255, | 333 | .dac_volume_max = 255, |
335 | .misc_flags = OXYGEN_MISC_MIDI, | ||
336 | .function_flags = OXYGEN_FUNCTION_SPI | | 334 | .function_flags = OXYGEN_FUNCTION_SPI | |
337 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, | 335 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, |
338 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 336 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
@@ -343,7 +341,6 @@ static int __devinit generic_oxygen_probe(struct pci_dev *pci, | |||
343 | const struct pci_device_id *pci_id) | 341 | const struct pci_device_id *pci_id) |
344 | { | 342 | { |
345 | static int dev; | 343 | static int dev; |
346 | int is_meridian; | ||
347 | int err; | 344 | int err; |
348 | 345 | ||
349 | if (dev >= SNDRV_CARDS) | 346 | if (dev >= SNDRV_CARDS) |
@@ -352,9 +349,8 @@ static int __devinit generic_oxygen_probe(struct pci_dev *pci, | |||
352 | ++dev; | 349 | ++dev; |
353 | return -ENOENT; | 350 | return -ENOENT; |
354 | } | 351 | } |
355 | is_meridian = pci_id->driver_data; | ||
356 | err = oxygen_pci_probe(pci, index[dev], id[dev], | 352 | err = oxygen_pci_probe(pci, index[dev], id[dev], |
357 | is_meridian ? &model_meridian : &model_generic); | 353 | &model_generic, pci_id->driver_data); |
358 | if (err >= 0) | 354 | if (err >= 0) |
359 | ++dev; | 355 | ++dev; |
360 | return err; | 356 | return err; |
diff --git a/sound/pci/oxygen/oxygen.h b/sound/pci/oxygen/oxygen.h index 74a644880074..19107c6307e5 100644 --- a/sound/pci/oxygen/oxygen.h +++ b/sound/pci/oxygen/oxygen.h | |||
@@ -19,14 +19,19 @@ | |||
19 | #define OXYGEN_IO_SIZE 0x100 | 19 | #define OXYGEN_IO_SIZE 0x100 |
20 | 20 | ||
21 | /* model-specific configuration of outputs/inputs */ | 21 | /* model-specific configuration of outputs/inputs */ |
22 | #define PLAYBACK_0_TO_I2S 0x001 | 22 | #define PLAYBACK_0_TO_I2S 0x0001 |
23 | #define PLAYBACK_1_TO_SPDIF 0x004 | 23 | /* PLAYBACK_0_TO_AC97_0 not implemented */ |
24 | #define PLAYBACK_2_TO_AC97_1 0x008 | 24 | #define PLAYBACK_1_TO_SPDIF 0x0004 |
25 | #define CAPTURE_0_FROM_I2S_1 0x010 | 25 | #define PLAYBACK_2_TO_AC97_1 0x0008 |
26 | #define CAPTURE_0_FROM_I2S_2 0x020 | 26 | #define CAPTURE_0_FROM_I2S_1 0x0010 |
27 | #define CAPTURE_1_FROM_SPDIF 0x080 | 27 | #define CAPTURE_0_FROM_I2S_2 0x0020 |
28 | #define CAPTURE_2_FROM_I2S_2 0x100 | 28 | /* CAPTURE_0_FROM_AC97_0 not implemented */ |
29 | #define CAPTURE_2_FROM_AC97_1 0x200 | 29 | #define CAPTURE_1_FROM_SPDIF 0x0080 |
30 | #define CAPTURE_2_FROM_I2S_2 0x0100 | ||
31 | #define CAPTURE_2_FROM_AC97_1 0x0200 | ||
32 | /* CAPTURE_3_FROM_I2S_3 not implemented */ | ||
33 | #define MIDI_OUTPUT 0x0800 | ||
34 | #define MIDI_INPUT 0x1000 | ||
30 | 35 | ||
31 | enum { | 36 | enum { |
32 | CONTROL_SPDIF_PCM, | 37 | CONTROL_SPDIF_PCM, |
@@ -51,7 +56,43 @@ struct snd_pcm_hardware; | |||
51 | struct snd_pcm_hw_params; | 56 | struct snd_pcm_hw_params; |
52 | struct snd_kcontrol_new; | 57 | struct snd_kcontrol_new; |
53 | struct snd_rawmidi; | 58 | struct snd_rawmidi; |
54 | struct oxygen_model; | 59 | struct oxygen; |
60 | |||
61 | struct oxygen_model { | ||
62 | const char *shortname; | ||
63 | const char *longname; | ||
64 | const char *chip; | ||
65 | struct module *owner; | ||
66 | int (*probe)(struct oxygen *chip, unsigned long driver_data); | ||
67 | void (*init)(struct oxygen *chip); | ||
68 | int (*control_filter)(struct snd_kcontrol_new *template); | ||
69 | int (*mixer_init)(struct oxygen *chip); | ||
70 | void (*cleanup)(struct oxygen *chip); | ||
71 | void (*suspend)(struct oxygen *chip); | ||
72 | void (*resume)(struct oxygen *chip); | ||
73 | void (*pcm_hardware_filter)(unsigned int channel, | ||
74 | struct snd_pcm_hardware *hardware); | ||
75 | void (*set_dac_params)(struct oxygen *chip, | ||
76 | struct snd_pcm_hw_params *params); | ||
77 | void (*set_adc_params)(struct oxygen *chip, | ||
78 | struct snd_pcm_hw_params *params); | ||
79 | void (*update_dac_volume)(struct oxygen *chip); | ||
80 | void (*update_dac_mute)(struct oxygen *chip); | ||
81 | void (*gpio_changed)(struct oxygen *chip); | ||
82 | void (*uart_input)(struct oxygen *chip); | ||
83 | void (*ac97_switch)(struct oxygen *chip, | ||
84 | unsigned int reg, unsigned int mute); | ||
85 | const unsigned int *dac_tlv; | ||
86 | size_t model_data_size; | ||
87 | unsigned int device_config; | ||
88 | u8 dac_channels; | ||
89 | u8 dac_volume_min; | ||
90 | u8 dac_volume_max; | ||
91 | u8 misc_flags; | ||
92 | u8 function_flags; | ||
93 | u16 dac_i2s_format; | ||
94 | u16 adc_i2s_format; | ||
95 | }; | ||
55 | 96 | ||
56 | struct oxygen { | 97 | struct oxygen { |
57 | unsigned long addr; | 98 | unsigned long addr; |
@@ -61,7 +102,6 @@ struct oxygen { | |||
61 | struct pci_dev *pci; | 102 | struct pci_dev *pci; |
62 | struct snd_rawmidi *midi; | 103 | struct snd_rawmidi *midi; |
63 | int irq; | 104 | int irq; |
64 | const struct oxygen_model *model; | ||
65 | void *model_data; | 105 | void *model_data; |
66 | unsigned int interrupt_mask; | 106 | unsigned int interrupt_mask; |
67 | u8 dac_volume[8]; | 107 | u8 dac_volume[8]; |
@@ -86,46 +126,16 @@ struct oxygen { | |||
86 | __le32 _32[OXYGEN_IO_SIZE / 4]; | 126 | __le32 _32[OXYGEN_IO_SIZE / 4]; |
87 | } saved_registers; | 127 | } saved_registers; |
88 | u16 saved_ac97_registers[2][0x40]; | 128 | u16 saved_ac97_registers[2][0x40]; |
89 | }; | 129 | unsigned int uart_input_count; |
90 | 130 | u8 uart_input[32]; | |
91 | struct oxygen_model { | 131 | struct oxygen_model model; |
92 | const char *shortname; | ||
93 | const char *longname; | ||
94 | const char *chip; | ||
95 | struct module *owner; | ||
96 | void (*init)(struct oxygen *chip); | ||
97 | int (*control_filter)(struct snd_kcontrol_new *template); | ||
98 | int (*mixer_init)(struct oxygen *chip); | ||
99 | void (*cleanup)(struct oxygen *chip); | ||
100 | void (*suspend)(struct oxygen *chip); | ||
101 | void (*resume)(struct oxygen *chip); | ||
102 | void (*pcm_hardware_filter)(unsigned int channel, | ||
103 | struct snd_pcm_hardware *hardware); | ||
104 | void (*set_dac_params)(struct oxygen *chip, | ||
105 | struct snd_pcm_hw_params *params); | ||
106 | void (*set_adc_params)(struct oxygen *chip, | ||
107 | struct snd_pcm_hw_params *params); | ||
108 | void (*update_dac_volume)(struct oxygen *chip); | ||
109 | void (*update_dac_mute)(struct oxygen *chip); | ||
110 | void (*gpio_changed)(struct oxygen *chip); | ||
111 | void (*ac97_switch)(struct oxygen *chip, | ||
112 | unsigned int reg, unsigned int mute); | ||
113 | const unsigned int *dac_tlv; | ||
114 | size_t model_data_size; | ||
115 | unsigned int pcm_dev_cfg; | ||
116 | u8 dac_channels; | ||
117 | u8 dac_volume_min; | ||
118 | u8 dac_volume_max; | ||
119 | u8 misc_flags; | ||
120 | u8 function_flags; | ||
121 | u16 dac_i2s_format; | ||
122 | u16 adc_i2s_format; | ||
123 | }; | 132 | }; |
124 | 133 | ||
125 | /* oxygen_lib.c */ | 134 | /* oxygen_lib.c */ |
126 | 135 | ||
127 | int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, | 136 | int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, |
128 | const struct oxygen_model *model); | 137 | const struct oxygen_model *model, |
138 | unsigned long driver_data); | ||
129 | void oxygen_pci_remove(struct pci_dev *pci); | 139 | void oxygen_pci_remove(struct pci_dev *pci); |
130 | #ifdef CONFIG_PM | 140 | #ifdef CONFIG_PM |
131 | int oxygen_pci_suspend(struct pci_dev *pci, pm_message_t state); | 141 | int oxygen_pci_suspend(struct pci_dev *pci, pm_message_t state); |
@@ -167,6 +177,9 @@ void oxygen_write_ac97_masked(struct oxygen *chip, unsigned int codec, | |||
167 | void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data); | 177 | void oxygen_write_spi(struct oxygen *chip, u8 control, unsigned int data); |
168 | void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data); | 178 | void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data); |
169 | 179 | ||
180 | void oxygen_reset_uart(struct oxygen *chip); | ||
181 | void oxygen_write_uart(struct oxygen *chip, u8 data); | ||
182 | |||
170 | static inline void oxygen_set_bits8(struct oxygen *chip, | 183 | static inline void oxygen_set_bits8(struct oxygen *chip, |
171 | unsigned int reg, u8 value) | 184 | unsigned int reg, u8 value) |
172 | { | 185 | { |
diff --git a/sound/pci/oxygen/oxygen_io.c b/sound/pci/oxygen/oxygen_io.c index 83f135f80df4..3126c4b403dd 100644 --- a/sound/pci/oxygen/oxygen_io.c +++ b/sound/pci/oxygen/oxygen_io.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/sched.h> | 21 | #include <linux/sched.h> |
22 | #include <sound/core.h> | 22 | #include <sound/core.h> |
23 | #include <sound/mpu401.h> | ||
23 | #include <asm/io.h> | 24 | #include <asm/io.h> |
24 | #include "oxygen.h" | 25 | #include "oxygen.h" |
25 | 26 | ||
@@ -232,3 +233,24 @@ void oxygen_write_i2c(struct oxygen *chip, u8 device, u8 map, u8 data) | |||
232 | device | OXYGEN_2WIRE_DIR_WRITE); | 233 | device | OXYGEN_2WIRE_DIR_WRITE); |
233 | } | 234 | } |
234 | EXPORT_SYMBOL(oxygen_write_i2c); | 235 | EXPORT_SYMBOL(oxygen_write_i2c); |
236 | |||
237 | static void _write_uart(struct oxygen *chip, unsigned int port, u8 data) | ||
238 | { | ||
239 | if (oxygen_read8(chip, OXYGEN_MPU401 + 1) & MPU401_TX_FULL) | ||
240 | msleep(1); | ||
241 | oxygen_write8(chip, OXYGEN_MPU401 + port, data); | ||
242 | } | ||
243 | |||
244 | void oxygen_reset_uart(struct oxygen *chip) | ||
245 | { | ||
246 | _write_uart(chip, 1, MPU401_RESET); | ||
247 | msleep(1); /* wait for ACK */ | ||
248 | _write_uart(chip, 1, MPU401_ENTER_UART); | ||
249 | } | ||
250 | EXPORT_SYMBOL(oxygen_reset_uart); | ||
251 | |||
252 | void oxygen_write_uart(struct oxygen *chip, u8 data) | ||
253 | { | ||
254 | _write_uart(chip, 0, data); | ||
255 | } | ||
256 | EXPORT_SYMBOL(oxygen_write_uart); | ||
diff --git a/sound/pci/oxygen/oxygen_lib.c b/sound/pci/oxygen/oxygen_lib.c index 22f37851045e..84f481d41efa 100644 --- a/sound/pci/oxygen/oxygen_lib.c +++ b/sound/pci/oxygen/oxygen_lib.c | |||
@@ -35,6 +35,30 @@ MODULE_DESCRIPTION("C-Media CMI8788 helper library"); | |||
35 | MODULE_LICENSE("GPL v2"); | 35 | MODULE_LICENSE("GPL v2"); |
36 | 36 | ||
37 | 37 | ||
38 | static inline int oxygen_uart_input_ready(struct oxygen *chip) | ||
39 | { | ||
40 | return !(oxygen_read8(chip, OXYGEN_MPU401 + 1) & MPU401_RX_EMPTY); | ||
41 | } | ||
42 | |||
43 | static void oxygen_read_uart(struct oxygen *chip) | ||
44 | { | ||
45 | if (unlikely(!oxygen_uart_input_ready(chip))) { | ||
46 | /* no data, but read it anyway to clear the interrupt */ | ||
47 | oxygen_read8(chip, OXYGEN_MPU401); | ||
48 | return; | ||
49 | } | ||
50 | do { | ||
51 | u8 data = oxygen_read8(chip, OXYGEN_MPU401); | ||
52 | if (data == MPU401_ACK) | ||
53 | continue; | ||
54 | if (chip->uart_input_count >= ARRAY_SIZE(chip->uart_input)) | ||
55 | chip->uart_input_count = 0; | ||
56 | chip->uart_input[chip->uart_input_count++] = data; | ||
57 | } while (oxygen_uart_input_ready(chip)); | ||
58 | if (chip->model.uart_input) | ||
59 | chip->model.uart_input(chip); | ||
60 | } | ||
61 | |||
38 | static irqreturn_t oxygen_interrupt(int dummy, void *dev_id) | 62 | static irqreturn_t oxygen_interrupt(int dummy, void *dev_id) |
39 | { | 63 | { |
40 | struct oxygen *chip = dev_id; | 64 | struct oxygen *chip = dev_id; |
@@ -87,8 +111,12 @@ static irqreturn_t oxygen_interrupt(int dummy, void *dev_id) | |||
87 | if (status & OXYGEN_INT_GPIO) | 111 | if (status & OXYGEN_INT_GPIO) |
88 | schedule_work(&chip->gpio_work); | 112 | schedule_work(&chip->gpio_work); |
89 | 113 | ||
90 | if ((status & OXYGEN_INT_MIDI) && chip->midi) | 114 | if (status & OXYGEN_INT_MIDI) { |
91 | snd_mpu401_uart_interrupt(0, chip->midi->private_data); | 115 | if (chip->midi) |
116 | snd_mpu401_uart_interrupt(0, chip->midi->private_data); | ||
117 | else | ||
118 | oxygen_read_uart(chip); | ||
119 | } | ||
92 | 120 | ||
93 | if (status & OXYGEN_INT_AC97) | 121 | if (status & OXYGEN_INT_AC97) |
94 | wake_up(&chip->ac97_waitqueue); | 122 | wake_up(&chip->ac97_waitqueue); |
@@ -161,8 +189,8 @@ static void oxygen_gpio_changed(struct work_struct *work) | |||
161 | { | 189 | { |
162 | struct oxygen *chip = container_of(work, struct oxygen, gpio_work); | 190 | struct oxygen *chip = container_of(work, struct oxygen, gpio_work); |
163 | 191 | ||
164 | if (chip->model->gpio_changed) | 192 | if (chip->model.gpio_changed) |
165 | chip->model->gpio_changed(chip); | 193 | chip->model.gpio_changed(chip); |
166 | } | 194 | } |
167 | 195 | ||
168 | #ifdef CONFIG_PROC_FS | 196 | #ifdef CONFIG_PROC_FS |
@@ -221,7 +249,7 @@ static void oxygen_init(struct oxygen *chip) | |||
221 | 249 | ||
222 | chip->dac_routing = 1; | 250 | chip->dac_routing = 1; |
223 | for (i = 0; i < 8; ++i) | 251 | for (i = 0; i < 8; ++i) |
224 | chip->dac_volume[i] = chip->model->dac_volume_min; | 252 | chip->dac_volume[i] = chip->model.dac_volume_min; |
225 | chip->dac_mute = 1; | 253 | chip->dac_mute = 1; |
226 | chip->spdif_playback_enable = 1; | 254 | chip->spdif_playback_enable = 1; |
227 | chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL | | 255 | chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL | |
@@ -243,7 +271,7 @@ static void oxygen_init(struct oxygen *chip) | |||
243 | 271 | ||
244 | oxygen_write8_masked(chip, OXYGEN_FUNCTION, | 272 | oxygen_write8_masked(chip, OXYGEN_FUNCTION, |
245 | OXYGEN_FUNCTION_RESET_CODEC | | 273 | OXYGEN_FUNCTION_RESET_CODEC | |
246 | chip->model->function_flags, | 274 | chip->model.function_flags, |
247 | OXYGEN_FUNCTION_RESET_CODEC | | 275 | OXYGEN_FUNCTION_RESET_CODEC | |
248 | OXYGEN_FUNCTION_2WIRE_SPI_MASK | | 276 | OXYGEN_FUNCTION_2WIRE_SPI_MASK | |
249 | OXYGEN_FUNCTION_ENABLE_SPI_4_5); | 277 | OXYGEN_FUNCTION_ENABLE_SPI_4_5); |
@@ -255,7 +283,7 @@ static void oxygen_init(struct oxygen *chip) | |||
255 | OXYGEN_DMA_MULTICH_BURST_8); | 283 | OXYGEN_DMA_MULTICH_BURST_8); |
256 | oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0); | 284 | oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0); |
257 | oxygen_write8_masked(chip, OXYGEN_MISC, | 285 | oxygen_write8_masked(chip, OXYGEN_MISC, |
258 | chip->model->misc_flags, | 286 | chip->model.misc_flags, |
259 | OXYGEN_MISC_WRITE_PCI_SUBID | | 287 | OXYGEN_MISC_WRITE_PCI_SUBID | |
260 | OXYGEN_MISC_REC_C_FROM_SPDIF | | 288 | OXYGEN_MISC_REC_C_FROM_SPDIF | |
261 | OXYGEN_MISC_REC_B_FROM_AC97 | | 289 | OXYGEN_MISC_REC_B_FROM_AC97 | |
@@ -270,21 +298,21 @@ static void oxygen_init(struct oxygen *chip) | |||
270 | (OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT)); | 298 | (OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT)); |
271 | oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2); | 299 | oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2); |
272 | oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT, | 300 | oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT, |
273 | OXYGEN_RATE_48000 | chip->model->dac_i2s_format | | 301 | OXYGEN_RATE_48000 | chip->model.dac_i2s_format | |
274 | OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | | 302 | OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | |
275 | OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); | 303 | OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); |
276 | if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_1) | 304 | if (chip->model.device_config & CAPTURE_0_FROM_I2S_1) |
277 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, | 305 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, |
278 | OXYGEN_RATE_48000 | chip->model->adc_i2s_format | | 306 | OXYGEN_RATE_48000 | chip->model.adc_i2s_format | |
279 | OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | | 307 | OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | |
280 | OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); | 308 | OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); |
281 | else | 309 | else |
282 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, | 310 | oxygen_write16(chip, OXYGEN_I2S_A_FORMAT, |
283 | OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK); | 311 | OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK); |
284 | if (chip->model->pcm_dev_cfg & (CAPTURE_0_FROM_I2S_2 | | 312 | if (chip->model.device_config & (CAPTURE_0_FROM_I2S_2 | |
285 | CAPTURE_2_FROM_I2S_2)) | 313 | CAPTURE_2_FROM_I2S_2)) |
286 | oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, | 314 | oxygen_write16(chip, OXYGEN_I2S_B_FORMAT, |
287 | OXYGEN_RATE_48000 | chip->model->adc_i2s_format | | 315 | OXYGEN_RATE_48000 | chip->model.adc_i2s_format | |
288 | OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | | 316 | OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 | |
289 | OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); | 317 | OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64); |
290 | else | 318 | else |
@@ -295,7 +323,7 @@ static void oxygen_init(struct oxygen *chip) | |||
295 | oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL, | 323 | oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL, |
296 | OXYGEN_SPDIF_OUT_ENABLE | | 324 | OXYGEN_SPDIF_OUT_ENABLE | |
297 | OXYGEN_SPDIF_LOOPBACK); | 325 | OXYGEN_SPDIF_LOOPBACK); |
298 | if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) | 326 | if (chip->model.device_config & CAPTURE_1_FROM_SPDIF) |
299 | oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL, | 327 | oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL, |
300 | OXYGEN_SPDIF_SENSE_MASK | | 328 | OXYGEN_SPDIF_SENSE_MASK | |
301 | OXYGEN_SPDIF_LOCK_MASK | | 329 | OXYGEN_SPDIF_LOCK_MASK | |
@@ -417,14 +445,15 @@ static void oxygen_card_free(struct snd_card *card) | |||
417 | if (chip->irq >= 0) | 445 | if (chip->irq >= 0) |
418 | free_irq(chip->irq, chip); | 446 | free_irq(chip->irq, chip); |
419 | flush_scheduled_work(); | 447 | flush_scheduled_work(); |
420 | chip->model->cleanup(chip); | 448 | chip->model.cleanup(chip); |
421 | mutex_destroy(&chip->mutex); | 449 | mutex_destroy(&chip->mutex); |
422 | pci_release_regions(chip->pci); | 450 | pci_release_regions(chip->pci); |
423 | pci_disable_device(chip->pci); | 451 | pci_disable_device(chip->pci); |
424 | } | 452 | } |
425 | 453 | ||
426 | int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, | 454 | int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, |
427 | const struct oxygen_model *model) | 455 | const struct oxygen_model *model, |
456 | unsigned long driver_data) | ||
428 | { | 457 | { |
429 | struct snd_card *card; | 458 | struct snd_card *card; |
430 | struct oxygen *chip; | 459 | struct oxygen *chip; |
@@ -439,7 +468,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, | |||
439 | chip->card = card; | 468 | chip->card = card; |
440 | chip->pci = pci; | 469 | chip->pci = pci; |
441 | chip->irq = -1; | 470 | chip->irq = -1; |
442 | chip->model = model; | 471 | chip->model = *model; |
443 | chip->model_data = chip + 1; | 472 | chip->model_data = chip + 1; |
444 | spin_lock_init(&chip->reg_lock); | 473 | spin_lock_init(&chip->reg_lock); |
445 | mutex_init(&chip->mutex); | 474 | mutex_init(&chip->mutex); |
@@ -470,23 +499,28 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, | |||
470 | snd_card_set_dev(card, &pci->dev); | 499 | snd_card_set_dev(card, &pci->dev); |
471 | card->private_free = oxygen_card_free; | 500 | card->private_free = oxygen_card_free; |
472 | 501 | ||
502 | if (chip->model.probe) { | ||
503 | err = chip->model.probe(chip, driver_data); | ||
504 | if (err < 0) | ||
505 | goto err_card; | ||
506 | } | ||
473 | oxygen_init(chip); | 507 | oxygen_init(chip); |
474 | model->init(chip); | 508 | chip->model.init(chip); |
475 | 509 | ||
476 | err = request_irq(pci->irq, oxygen_interrupt, IRQF_SHARED, | 510 | err = request_irq(pci->irq, oxygen_interrupt, IRQF_SHARED, |
477 | model->chip, chip); | 511 | chip->model.chip, chip); |
478 | if (err < 0) { | 512 | if (err < 0) { |
479 | snd_printk(KERN_ERR "cannot grab interrupt %d\n", pci->irq); | 513 | snd_printk(KERN_ERR "cannot grab interrupt %d\n", pci->irq); |
480 | goto err_card; | 514 | goto err_card; |
481 | } | 515 | } |
482 | chip->irq = pci->irq; | 516 | chip->irq = pci->irq; |
483 | 517 | ||
484 | strcpy(card->driver, model->chip); | 518 | strcpy(card->driver, chip->model.chip); |
485 | strcpy(card->shortname, model->shortname); | 519 | strcpy(card->shortname, chip->model.shortname); |
486 | sprintf(card->longname, "%s (rev %u) at %#lx, irq %i", | 520 | sprintf(card->longname, "%s (rev %u) at %#lx, irq %i", |
487 | model->longname, chip->revision, chip->addr, chip->irq); | 521 | chip->model.longname, chip->revision, chip->addr, chip->irq); |
488 | strcpy(card->mixername, model->chip); | 522 | strcpy(card->mixername, chip->model.chip); |
489 | snd_component_add(card, model->chip); | 523 | snd_component_add(card, chip->model.chip); |
490 | 524 | ||
491 | err = oxygen_pcm_init(chip); | 525 | err = oxygen_pcm_init(chip); |
492 | if (err < 0) | 526 | if (err < 0) |
@@ -496,10 +530,15 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, | |||
496 | if (err < 0) | 530 | if (err < 0) |
497 | goto err_card; | 531 | goto err_card; |
498 | 532 | ||
499 | if (model->misc_flags & OXYGEN_MISC_MIDI) { | 533 | if (chip->model.device_config & (MIDI_OUTPUT | MIDI_INPUT)) { |
534 | unsigned int info_flags = MPU401_INFO_INTEGRATED; | ||
535 | if (chip->model.device_config & MIDI_OUTPUT) | ||
536 | info_flags |= MPU401_INFO_OUTPUT; | ||
537 | if (chip->model.device_config & MIDI_INPUT) | ||
538 | info_flags |= MPU401_INFO_INPUT; | ||
500 | err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI, | 539 | err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI, |
501 | chip->addr + OXYGEN_MPU401, | 540 | chip->addr + OXYGEN_MPU401, |
502 | MPU401_INFO_INTEGRATED, 0, 0, | 541 | info_flags, 0, 0, |
503 | &chip->midi); | 542 | &chip->midi); |
504 | if (err < 0) | 543 | if (err < 0) |
505 | goto err_card; | 544 | goto err_card; |
@@ -508,7 +547,7 @@ int oxygen_pci_probe(struct pci_dev *pci, int index, char *id, | |||
508 | oxygen_proc_init(chip); | 547 | oxygen_proc_init(chip); |
509 | 548 | ||
510 | spin_lock_irq(&chip->reg_lock); | 549 | spin_lock_irq(&chip->reg_lock); |
511 | if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) | 550 | if (chip->model.device_config & CAPTURE_1_FROM_SPDIF) |
512 | chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT; | 551 | chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT; |
513 | if (chip->has_ac97_0 | chip->has_ac97_1) | 552 | if (chip->has_ac97_0 | chip->has_ac97_1) |
514 | chip->interrupt_mask |= OXYGEN_INT_AC97; | 553 | chip->interrupt_mask |= OXYGEN_INT_AC97; |
@@ -552,8 +591,8 @@ int oxygen_pci_suspend(struct pci_dev *pci, pm_message_t state) | |||
552 | if (chip->streams[i]) | 591 | if (chip->streams[i]) |
553 | snd_pcm_suspend(chip->streams[i]); | 592 | snd_pcm_suspend(chip->streams[i]); |
554 | 593 | ||
555 | if (chip->model->suspend) | 594 | if (chip->model.suspend) |
556 | chip->model->suspend(chip); | 595 | chip->model.suspend(chip); |
557 | 596 | ||
558 | spin_lock_irq(&chip->reg_lock); | 597 | spin_lock_irq(&chip->reg_lock); |
559 | saved_interrupt_mask = chip->interrupt_mask; | 598 | saved_interrupt_mask = chip->interrupt_mask; |
@@ -624,8 +663,8 @@ int oxygen_pci_resume(struct pci_dev *pci) | |||
624 | if (chip->has_ac97_1) | 663 | if (chip->has_ac97_1) |
625 | oxygen_restore_ac97(chip, 1); | 664 | oxygen_restore_ac97(chip, 1); |
626 | 665 | ||
627 | if (chip->model->resume) | 666 | if (chip->model.resume) |
628 | chip->model->resume(chip); | 667 | chip->model.resume(chip); |
629 | 668 | ||
630 | oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask); | 669 | oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask); |
631 | 670 | ||
diff --git a/sound/pci/oxygen/oxygen_mixer.c b/sound/pci/oxygen/oxygen_mixer.c index 05eb8994c141..304da169bfdc 100644 --- a/sound/pci/oxygen/oxygen_mixer.c +++ b/sound/pci/oxygen/oxygen_mixer.c | |||
@@ -31,9 +31,9 @@ static int dac_volume_info(struct snd_kcontrol *ctl, | |||
31 | struct oxygen *chip = ctl->private_data; | 31 | struct oxygen *chip = ctl->private_data; |
32 | 32 | ||
33 | info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 33 | info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
34 | info->count = chip->model->dac_channels; | 34 | info->count = chip->model.dac_channels; |
35 | info->value.integer.min = chip->model->dac_volume_min; | 35 | info->value.integer.min = chip->model.dac_volume_min; |
36 | info->value.integer.max = chip->model->dac_volume_max; | 36 | info->value.integer.max = chip->model.dac_volume_max; |
37 | return 0; | 37 | return 0; |
38 | } | 38 | } |
39 | 39 | ||
@@ -44,7 +44,7 @@ static int dac_volume_get(struct snd_kcontrol *ctl, | |||
44 | unsigned int i; | 44 | unsigned int i; |
45 | 45 | ||
46 | mutex_lock(&chip->mutex); | 46 | mutex_lock(&chip->mutex); |
47 | for (i = 0; i < chip->model->dac_channels; ++i) | 47 | for (i = 0; i < chip->model.dac_channels; ++i) |
48 | value->value.integer.value[i] = chip->dac_volume[i]; | 48 | value->value.integer.value[i] = chip->dac_volume[i]; |
49 | mutex_unlock(&chip->mutex); | 49 | mutex_unlock(&chip->mutex); |
50 | return 0; | 50 | return 0; |
@@ -59,13 +59,13 @@ static int dac_volume_put(struct snd_kcontrol *ctl, | |||
59 | 59 | ||
60 | changed = 0; | 60 | changed = 0; |
61 | mutex_lock(&chip->mutex); | 61 | mutex_lock(&chip->mutex); |
62 | for (i = 0; i < chip->model->dac_channels; ++i) | 62 | for (i = 0; i < chip->model.dac_channels; ++i) |
63 | if (value->value.integer.value[i] != chip->dac_volume[i]) { | 63 | if (value->value.integer.value[i] != chip->dac_volume[i]) { |
64 | chip->dac_volume[i] = value->value.integer.value[i]; | 64 | chip->dac_volume[i] = value->value.integer.value[i]; |
65 | changed = 1; | 65 | changed = 1; |
66 | } | 66 | } |
67 | if (changed) | 67 | if (changed) |
68 | chip->model->update_dac_volume(chip); | 68 | chip->model.update_dac_volume(chip); |
69 | mutex_unlock(&chip->mutex); | 69 | mutex_unlock(&chip->mutex); |
70 | return changed; | 70 | return changed; |
71 | } | 71 | } |
@@ -91,7 +91,7 @@ static int dac_mute_put(struct snd_kcontrol *ctl, | |||
91 | changed = !value->value.integer.value[0] != chip->dac_mute; | 91 | changed = !value->value.integer.value[0] != chip->dac_mute; |
92 | if (changed) { | 92 | if (changed) { |
93 | chip->dac_mute = !value->value.integer.value[0]; | 93 | chip->dac_mute = !value->value.integer.value[0]; |
94 | chip->model->update_dac_mute(chip); | 94 | chip->model.update_dac_mute(chip); |
95 | } | 95 | } |
96 | mutex_unlock(&chip->mutex); | 96 | mutex_unlock(&chip->mutex); |
97 | return changed; | 97 | return changed; |
@@ -103,7 +103,7 @@ static int upmix_info(struct snd_kcontrol *ctl, struct snd_ctl_elem_info *info) | |||
103 | "Front", "Front+Surround", "Front+Surround+Back" | 103 | "Front", "Front+Surround", "Front+Surround+Back" |
104 | }; | 104 | }; |
105 | struct oxygen *chip = ctl->private_data; | 105 | struct oxygen *chip = ctl->private_data; |
106 | unsigned int count = 2 + (chip->model->dac_channels == 8); | 106 | unsigned int count = 2 + (chip->model.dac_channels == 8); |
107 | 107 | ||
108 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 108 | info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
109 | info->count = 1; | 109 | info->count = 1; |
@@ -172,7 +172,7 @@ void oxygen_update_dac_routing(struct oxygen *chip) | |||
172 | static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) | 172 | static int upmix_put(struct snd_kcontrol *ctl, struct snd_ctl_elem_value *value) |
173 | { | 173 | { |
174 | struct oxygen *chip = ctl->private_data; | 174 | struct oxygen *chip = ctl->private_data; |
175 | unsigned int count = 2 + (chip->model->dac_channels == 8); | 175 | unsigned int count = 2 + (chip->model.dac_channels == 8); |
176 | int changed; | 176 | int changed; |
177 | 177 | ||
178 | mutex_lock(&chip->mutex); | 178 | mutex_lock(&chip->mutex); |
@@ -211,13 +211,13 @@ static unsigned int oxygen_spdif_rate(unsigned int oxygen_rate) | |||
211 | case OXYGEN_RATE_64000: | 211 | case OXYGEN_RATE_64000: |
212 | return 0xb << OXYGEN_SPDIF_CS_RATE_SHIFT; | 212 | return 0xb << OXYGEN_SPDIF_CS_RATE_SHIFT; |
213 | case OXYGEN_RATE_88200: | 213 | case OXYGEN_RATE_88200: |
214 | return 0x8 << OXYGEN_SPDIF_CS_RATE_SHIFT; | 214 | return IEC958_AES3_CON_FS_88200 << OXYGEN_SPDIF_CS_RATE_SHIFT; |
215 | case OXYGEN_RATE_96000: | 215 | case OXYGEN_RATE_96000: |
216 | return 0xa << OXYGEN_SPDIF_CS_RATE_SHIFT; | 216 | return IEC958_AES3_CON_FS_96000 << OXYGEN_SPDIF_CS_RATE_SHIFT; |
217 | case OXYGEN_RATE_176400: | 217 | case OXYGEN_RATE_176400: |
218 | return 0xc << OXYGEN_SPDIF_CS_RATE_SHIFT; | 218 | return IEC958_AES3_CON_FS_176400 << OXYGEN_SPDIF_CS_RATE_SHIFT; |
219 | case OXYGEN_RATE_192000: | 219 | case OXYGEN_RATE_192000: |
220 | return 0xe << OXYGEN_SPDIF_CS_RATE_SHIFT; | 220 | return IEC958_AES3_CON_FS_192000 << OXYGEN_SPDIF_CS_RATE_SHIFT; |
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
@@ -521,8 +521,8 @@ static void mute_ac97_ctl(struct oxygen *chip, unsigned int control) | |||
521 | value = oxygen_read_ac97(chip, 0, priv_idx); | 521 | value = oxygen_read_ac97(chip, 0, priv_idx); |
522 | if (!(value & 0x8000)) { | 522 | if (!(value & 0x8000)) { |
523 | oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000); | 523 | oxygen_write_ac97(chip, 0, priv_idx, value | 0x8000); |
524 | if (chip->model->ac97_switch) | 524 | if (chip->model.ac97_switch) |
525 | chip->model->ac97_switch(chip, priv_idx, 0x8000); | 525 | chip->model.ac97_switch(chip, priv_idx, 0x8000); |
526 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, | 526 | snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, |
527 | &chip->controls[control]->id); | 527 | &chip->controls[control]->id); |
528 | } | 528 | } |
@@ -549,8 +549,8 @@ static int ac97_switch_put(struct snd_kcontrol *ctl, | |||
549 | change = newreg != oldreg; | 549 | change = newreg != oldreg; |
550 | if (change) { | 550 | if (change) { |
551 | oxygen_write_ac97(chip, codec, index, newreg); | 551 | oxygen_write_ac97(chip, codec, index, newreg); |
552 | if (codec == 0 && chip->model->ac97_switch) | 552 | if (codec == 0 && chip->model.ac97_switch) |
553 | chip->model->ac97_switch(chip, index, newreg & 0x8000); | 553 | chip->model.ac97_switch(chip, index, newreg & 0x8000); |
554 | if (index == AC97_LINE) { | 554 | if (index == AC97_LINE) { |
555 | oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS, | 555 | oxygen_write_ac97_masked(chip, 0, CM9780_GPIO_STATUS, |
556 | newreg & 0x8000 ? | 556 | newreg & 0x8000 ? |
@@ -939,16 +939,16 @@ static int add_controls(struct oxygen *chip, | |||
939 | 939 | ||
940 | for (i = 0; i < count; ++i) { | 940 | for (i = 0; i < count; ++i) { |
941 | template = controls[i]; | 941 | template = controls[i]; |
942 | if (chip->model->control_filter) { | 942 | if (chip->model.control_filter) { |
943 | err = chip->model->control_filter(&template); | 943 | err = chip->model.control_filter(&template); |
944 | if (err < 0) | 944 | if (err < 0) |
945 | return err; | 945 | return err; |
946 | if (err == 1) | 946 | if (err == 1) |
947 | continue; | 947 | continue; |
948 | } | 948 | } |
949 | if (!strcmp(template.name, "Master Playback Volume") && | 949 | if (!strcmp(template.name, "Master Playback Volume") && |
950 | chip->model->dac_tlv) { | 950 | chip->model.dac_tlv) { |
951 | template.tlv.p = chip->model->dac_tlv; | 951 | template.tlv.p = chip->model.dac_tlv; |
952 | template.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; | 952 | template.access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; |
953 | } | 953 | } |
954 | ctl = snd_ctl_new1(&template, chip); | 954 | ctl = snd_ctl_new1(&template, chip); |
@@ -974,14 +974,14 @@ int oxygen_mixer_init(struct oxygen *chip) | |||
974 | err = add_controls(chip, controls, ARRAY_SIZE(controls)); | 974 | err = add_controls(chip, controls, ARRAY_SIZE(controls)); |
975 | if (err < 0) | 975 | if (err < 0) |
976 | return err; | 976 | return err; |
977 | if (chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF) { | 977 | if (chip->model.device_config & CAPTURE_1_FROM_SPDIF) { |
978 | err = add_controls(chip, spdif_input_controls, | 978 | err = add_controls(chip, spdif_input_controls, |
979 | ARRAY_SIZE(spdif_input_controls)); | 979 | ARRAY_SIZE(spdif_input_controls)); |
980 | if (err < 0) | 980 | if (err < 0) |
981 | return err; | 981 | return err; |
982 | } | 982 | } |
983 | for (i = 0; i < ARRAY_SIZE(monitor_controls); ++i) { | 983 | for (i = 0; i < ARRAY_SIZE(monitor_controls); ++i) { |
984 | if (!(chip->model->pcm_dev_cfg & monitor_controls[i].pcm_dev)) | 984 | if (!(chip->model.device_config & monitor_controls[i].pcm_dev)) |
985 | continue; | 985 | continue; |
986 | err = add_controls(chip, monitor_controls[i].controls, | 986 | err = add_controls(chip, monitor_controls[i].controls, |
987 | ARRAY_SIZE(monitor_controls[i].controls)); | 987 | ARRAY_SIZE(monitor_controls[i].controls)); |
@@ -1000,5 +1000,5 @@ int oxygen_mixer_init(struct oxygen *chip) | |||
1000 | if (err < 0) | 1000 | if (err < 0) |
1001 | return err; | 1001 | return err; |
1002 | } | 1002 | } |
1003 | return chip->model->mixer_init ? chip->model->mixer_init(chip) : 0; | 1003 | return chip->model.mixer_init ? chip->model.mixer_init(chip) : 0; |
1004 | } | 1004 | } |
diff --git a/sound/pci/oxygen/oxygen_pcm.c b/sound/pci/oxygen/oxygen_pcm.c index c4ad65a3406f..c262049961e1 100644 --- a/sound/pci/oxygen/oxygen_pcm.c +++ b/sound/pci/oxygen/oxygen_pcm.c | |||
@@ -129,7 +129,7 @@ static int oxygen_open(struct snd_pcm_substream *substream, | |||
129 | 129 | ||
130 | runtime->private_data = (void *)(uintptr_t)channel; | 130 | runtime->private_data = (void *)(uintptr_t)channel; |
131 | if (channel == PCM_B && chip->has_ac97_1 && | 131 | if (channel == PCM_B && chip->has_ac97_1 && |
132 | (chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1)) | 132 | (chip->model.device_config & CAPTURE_2_FROM_AC97_1)) |
133 | runtime->hw = oxygen_ac97_hardware; | 133 | runtime->hw = oxygen_ac97_hardware; |
134 | else | 134 | else |
135 | runtime->hw = *oxygen_hardware[channel]; | 135 | runtime->hw = *oxygen_hardware[channel]; |
@@ -140,11 +140,11 @@ static int oxygen_open(struct snd_pcm_substream *substream, | |||
140 | runtime->hw.rate_min = 44100; | 140 | runtime->hw.rate_min = 44100; |
141 | break; | 141 | break; |
142 | case PCM_MULTICH: | 142 | case PCM_MULTICH: |
143 | runtime->hw.channels_max = chip->model->dac_channels; | 143 | runtime->hw.channels_max = chip->model.dac_channels; |
144 | break; | 144 | break; |
145 | } | 145 | } |
146 | if (chip->model->pcm_hardware_filter) | 146 | if (chip->model.pcm_hardware_filter) |
147 | chip->model->pcm_hardware_filter(channel, &runtime->hw); | 147 | chip->model.pcm_hardware_filter(channel, &runtime->hw); |
148 | err = snd_pcm_hw_constraint_step(runtime, 0, | 148 | err = snd_pcm_hw_constraint_step(runtime, 0, |
149 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); | 149 | SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32); |
150 | if (err < 0) | 150 | if (err < 0) |
@@ -355,7 +355,7 @@ static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream, | |||
355 | oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT, | 355 | oxygen_write16_masked(chip, OXYGEN_I2S_A_FORMAT, |
356 | oxygen_rate(hw_params) | | 356 | oxygen_rate(hw_params) | |
357 | oxygen_i2s_mclk(hw_params) | | 357 | oxygen_i2s_mclk(hw_params) | |
358 | chip->model->adc_i2s_format | | 358 | chip->model.adc_i2s_format | |
359 | oxygen_i2s_bits(hw_params), | 359 | oxygen_i2s_bits(hw_params), |
360 | OXYGEN_I2S_RATE_MASK | | 360 | OXYGEN_I2S_RATE_MASK | |
361 | OXYGEN_I2S_FORMAT_MASK | | 361 | OXYGEN_I2S_FORMAT_MASK | |
@@ -364,7 +364,7 @@ static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream, | |||
364 | spin_unlock_irq(&chip->reg_lock); | 364 | spin_unlock_irq(&chip->reg_lock); |
365 | 365 | ||
366 | mutex_lock(&chip->mutex); | 366 | mutex_lock(&chip->mutex); |
367 | chip->model->set_adc_params(chip, hw_params); | 367 | chip->model.set_adc_params(chip, hw_params); |
368 | mutex_unlock(&chip->mutex); | 368 | mutex_unlock(&chip->mutex); |
369 | return 0; | 369 | return 0; |
370 | } | 370 | } |
@@ -381,7 +381,7 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream, | |||
381 | return err; | 381 | return err; |
382 | 382 | ||
383 | is_ac97 = chip->has_ac97_1 && | 383 | is_ac97 = chip->has_ac97_1 && |
384 | (chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1); | 384 | (chip->model.device_config & CAPTURE_2_FROM_AC97_1); |
385 | 385 | ||
386 | spin_lock_irq(&chip->reg_lock); | 386 | spin_lock_irq(&chip->reg_lock); |
387 | oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, | 387 | oxygen_write8_masked(chip, OXYGEN_REC_FORMAT, |
@@ -391,7 +391,7 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream, | |||
391 | oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT, | 391 | oxygen_write16_masked(chip, OXYGEN_I2S_B_FORMAT, |
392 | oxygen_rate(hw_params) | | 392 | oxygen_rate(hw_params) | |
393 | oxygen_i2s_mclk(hw_params) | | 393 | oxygen_i2s_mclk(hw_params) | |
394 | chip->model->adc_i2s_format | | 394 | chip->model.adc_i2s_format | |
395 | oxygen_i2s_bits(hw_params), | 395 | oxygen_i2s_bits(hw_params), |
396 | OXYGEN_I2S_RATE_MASK | | 396 | OXYGEN_I2S_RATE_MASK | |
397 | OXYGEN_I2S_FORMAT_MASK | | 397 | OXYGEN_I2S_FORMAT_MASK | |
@@ -401,7 +401,7 @@ static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream, | |||
401 | 401 | ||
402 | if (!is_ac97) { | 402 | if (!is_ac97) { |
403 | mutex_lock(&chip->mutex); | 403 | mutex_lock(&chip->mutex); |
404 | chip->model->set_adc_params(chip, hw_params); | 404 | chip->model.set_adc_params(chip, hw_params); |
405 | mutex_unlock(&chip->mutex); | 405 | mutex_unlock(&chip->mutex); |
406 | } | 406 | } |
407 | return 0; | 407 | return 0; |
@@ -468,7 +468,7 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream, | |||
468 | OXYGEN_MULTICH_FORMAT_MASK); | 468 | OXYGEN_MULTICH_FORMAT_MASK); |
469 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, | 469 | oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT, |
470 | oxygen_rate(hw_params) | | 470 | oxygen_rate(hw_params) | |
471 | chip->model->dac_i2s_format | | 471 | chip->model.dac_i2s_format | |
472 | oxygen_i2s_bits(hw_params), | 472 | oxygen_i2s_bits(hw_params), |
473 | OXYGEN_I2S_RATE_MASK | | 473 | OXYGEN_I2S_RATE_MASK | |
474 | OXYGEN_I2S_FORMAT_MASK | | 474 | OXYGEN_I2S_FORMAT_MASK | |
@@ -478,7 +478,7 @@ static int oxygen_multich_hw_params(struct snd_pcm_substream *substream, | |||
478 | spin_unlock_irq(&chip->reg_lock); | 478 | spin_unlock_irq(&chip->reg_lock); |
479 | 479 | ||
480 | mutex_lock(&chip->mutex); | 480 | mutex_lock(&chip->mutex); |
481 | chip->model->set_dac_params(chip, hw_params); | 481 | chip->model.set_dac_params(chip, hw_params); |
482 | mutex_unlock(&chip->mutex); | 482 | mutex_unlock(&chip->mutex); |
483 | return 0; | 483 | return 0; |
484 | } | 484 | } |
@@ -657,25 +657,26 @@ int oxygen_pcm_init(struct oxygen *chip) | |||
657 | int outs, ins; | 657 | int outs, ins; |
658 | int err; | 658 | int err; |
659 | 659 | ||
660 | outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_0_TO_I2S); | 660 | outs = !!(chip->model.device_config & PLAYBACK_0_TO_I2S); |
661 | ins = !!(chip->model->pcm_dev_cfg & (CAPTURE_0_FROM_I2S_1 | | 661 | ins = !!(chip->model.device_config & (CAPTURE_0_FROM_I2S_1 | |
662 | CAPTURE_0_FROM_I2S_2)); | 662 | CAPTURE_0_FROM_I2S_2)); |
663 | if (outs | ins) { | 663 | if (outs | ins) { |
664 | err = snd_pcm_new(chip->card, "Analog", 0, outs, ins, &pcm); | 664 | err = snd_pcm_new(chip->card, "Multichannel", |
665 | 0, outs, ins, &pcm); | ||
665 | if (err < 0) | 666 | if (err < 0) |
666 | return err; | 667 | return err; |
667 | if (outs) | 668 | if (outs) |
668 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, | 669 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, |
669 | &oxygen_multich_ops); | 670 | &oxygen_multich_ops); |
670 | if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_1) | 671 | if (chip->model.device_config & CAPTURE_0_FROM_I2S_1) |
671 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, | 672 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, |
672 | &oxygen_rec_a_ops); | 673 | &oxygen_rec_a_ops); |
673 | else if (chip->model->pcm_dev_cfg & CAPTURE_0_FROM_I2S_2) | 674 | else if (chip->model.device_config & CAPTURE_0_FROM_I2S_2) |
674 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, | 675 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, |
675 | &oxygen_rec_b_ops); | 676 | &oxygen_rec_b_ops); |
676 | pcm->private_data = chip; | 677 | pcm->private_data = chip; |
677 | pcm->private_free = oxygen_pcm_free; | 678 | pcm->private_free = oxygen_pcm_free; |
678 | strcpy(pcm->name, "Analog"); | 679 | strcpy(pcm->name, "Multichannel"); |
679 | if (outs) | 680 | if (outs) |
680 | snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, | 681 | snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream, |
681 | SNDRV_DMA_TYPE_DEV, | 682 | SNDRV_DMA_TYPE_DEV, |
@@ -690,8 +691,8 @@ int oxygen_pcm_init(struct oxygen *chip) | |||
690 | BUFFER_BYTES_MAX); | 691 | BUFFER_BYTES_MAX); |
691 | } | 692 | } |
692 | 693 | ||
693 | outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_1_TO_SPDIF); | 694 | outs = !!(chip->model.device_config & PLAYBACK_1_TO_SPDIF); |
694 | ins = !!(chip->model->pcm_dev_cfg & CAPTURE_1_FROM_SPDIF); | 695 | ins = !!(chip->model.device_config & CAPTURE_1_FROM_SPDIF); |
695 | if (outs | ins) { | 696 | if (outs | ins) { |
696 | err = snd_pcm_new(chip->card, "Digital", 1, outs, ins, &pcm); | 697 | err = snd_pcm_new(chip->card, "Digital", 1, outs, ins, &pcm); |
697 | if (err < 0) | 698 | if (err < 0) |
@@ -712,11 +713,11 @@ int oxygen_pcm_init(struct oxygen *chip) | |||
712 | } | 713 | } |
713 | 714 | ||
714 | if (chip->has_ac97_1) { | 715 | if (chip->has_ac97_1) { |
715 | outs = !!(chip->model->pcm_dev_cfg & PLAYBACK_2_TO_AC97_1); | 716 | outs = !!(chip->model.device_config & PLAYBACK_2_TO_AC97_1); |
716 | ins = !!(chip->model->pcm_dev_cfg & CAPTURE_2_FROM_AC97_1); | 717 | ins = !!(chip->model.device_config & CAPTURE_2_FROM_AC97_1); |
717 | } else { | 718 | } else { |
718 | outs = 0; | 719 | outs = 0; |
719 | ins = !!(chip->model->pcm_dev_cfg & CAPTURE_2_FROM_I2S_2); | 720 | ins = !!(chip->model.device_config & CAPTURE_2_FROM_I2S_2); |
720 | } | 721 | } |
721 | if (outs | ins) { | 722 | if (outs | ins) { |
722 | err = snd_pcm_new(chip->card, outs ? "AC97" : "Analog2", | 723 | err = snd_pcm_new(chip->card, outs ? "AC97" : "Analog2", |
diff --git a/sound/pci/oxygen/virtuoso.c b/sound/pci/oxygen/virtuoso.c index 01d7b75f9182..98c6a8c65d81 100644 --- a/sound/pci/oxygen/virtuoso.c +++ b/sound/pci/oxygen/virtuoso.c | |||
@@ -62,14 +62,66 @@ | |||
62 | * AD0 <- 0 | 62 | * AD0 <- 0 |
63 | */ | 63 | */ |
64 | 64 | ||
65 | /* | ||
66 | * Xonar HDAV1.3 (Deluxe) | ||
67 | * ---------------------- | ||
68 | * | ||
69 | * CMI8788: | ||
70 | * | ||
71 | * I²C <-> PCM1796 (front) | ||
72 | * | ||
73 | * GPI 0 <- external power present | ||
74 | * | ||
75 | * GPIO 0 -> enable output to speakers | ||
76 | * GPIO 2 -> M0 of CS5381 | ||
77 | * GPIO 3 -> M1 of CS5381 | ||
78 | * GPIO 8 -> route input jack to line-in (0) or mic-in (1) | ||
79 | * | ||
80 | * TXD -> HDMI controller | ||
81 | * RXD <- HDMI controller | ||
82 | * | ||
83 | * PCM1796 front: AD1,0 <- 0,0 | ||
84 | * | ||
85 | * no daughterboard | ||
86 | * ---------------- | ||
87 | * | ||
88 | * GPIO 4 <- 1 | ||
89 | * | ||
90 | * H6 daughterboard | ||
91 | * ---------------- | ||
92 | * | ||
93 | * GPIO 4 <- 0 | ||
94 | * GPIO 5 <- 0 | ||
95 | * | ||
96 | * I²C <-> PCM1796 (surround) | ||
97 | * <-> PCM1796 (center/LFE) | ||
98 | * <-> PCM1796 (back) | ||
99 | * | ||
100 | * PCM1796 surround: AD1,0 <- 0,1 | ||
101 | * PCM1796 center/LFE: AD1,0 <- 1,0 | ||
102 | * PCM1796 back: AD1,0 <- 1,1 | ||
103 | * | ||
104 | * unknown daughterboard | ||
105 | * --------------------- | ||
106 | * | ||
107 | * GPIO 4 <- 0 | ||
108 | * GPIO 5 <- 1 | ||
109 | * | ||
110 | * I²C <-> CS4362A (surround, center/LFE, back) | ||
111 | * | ||
112 | * CS4362A: AD0 <- 0 | ||
113 | */ | ||
114 | |||
65 | #include <linux/pci.h> | 115 | #include <linux/pci.h> |
66 | #include <linux/delay.h> | 116 | #include <linux/delay.h> |
67 | #include <linux/mutex.h> | 117 | #include <linux/mutex.h> |
68 | #include <sound/ac97_codec.h> | 118 | #include <sound/ac97_codec.h> |
119 | #include <sound/asoundef.h> | ||
69 | #include <sound/control.h> | 120 | #include <sound/control.h> |
70 | #include <sound/core.h> | 121 | #include <sound/core.h> |
71 | #include <sound/initval.h> | 122 | #include <sound/initval.h> |
72 | #include <sound/pcm.h> | 123 | #include <sound/pcm.h> |
124 | #include <sound/pcm_params.h> | ||
73 | #include <sound/tlv.h> | 125 | #include <sound/tlv.h> |
74 | #include "oxygen.h" | 126 | #include "oxygen.h" |
75 | #include "cm9780.h" | 127 | #include "cm9780.h" |
@@ -98,12 +150,15 @@ enum { | |||
98 | MODEL_D2X, | 150 | MODEL_D2X, |
99 | MODEL_D1, | 151 | MODEL_D1, |
100 | MODEL_DX, | 152 | MODEL_DX, |
153 | MODEL_HDAV, /* without daughterboard */ | ||
154 | MODEL_HDAV_H6, /* with H6 daughterboard */ | ||
101 | }; | 155 | }; |
102 | 156 | ||
103 | static struct pci_device_id xonar_ids[] __devinitdata = { | 157 | static struct pci_device_id xonar_ids[] __devinitdata = { |
104 | { OXYGEN_PCI_SUBID(0x1043, 0x8269), .driver_data = MODEL_D2 }, | 158 | { OXYGEN_PCI_SUBID(0x1043, 0x8269), .driver_data = MODEL_D2 }, |
105 | { OXYGEN_PCI_SUBID(0x1043, 0x8275), .driver_data = MODEL_DX }, | 159 | { OXYGEN_PCI_SUBID(0x1043, 0x8275), .driver_data = MODEL_DX }, |
106 | { OXYGEN_PCI_SUBID(0x1043, 0x82b7), .driver_data = MODEL_D2X }, | 160 | { OXYGEN_PCI_SUBID(0x1043, 0x82b7), .driver_data = MODEL_D2X }, |
161 | { OXYGEN_PCI_SUBID(0x1043, 0x8314), .driver_data = MODEL_HDAV }, | ||
107 | { OXYGEN_PCI_SUBID(0x1043, 0x834f), .driver_data = MODEL_D1 }, | 162 | { OXYGEN_PCI_SUBID(0x1043, 0x834f), .driver_data = MODEL_D1 }, |
108 | { } | 163 | { } |
109 | }; | 164 | }; |
@@ -124,11 +179,18 @@ MODULE_DEVICE_TABLE(pci, xonar_ids); | |||
124 | #define GPIO_DX_FRONT_PANEL 0x0002 | 179 | #define GPIO_DX_FRONT_PANEL 0x0002 |
125 | #define GPIO_DX_INPUT_ROUTE 0x0100 | 180 | #define GPIO_DX_INPUT_ROUTE 0x0100 |
126 | 181 | ||
182 | #define GPIO_HDAV_DB_MASK 0x0030 | ||
183 | #define GPIO_HDAV_DB_H6 0x0000 | ||
184 | #define GPIO_HDAV_DB_XX 0x0020 | ||
185 | |||
186 | #define I2C_DEVICE_PCM1796(i) (0x98 + ((i) << 1)) /* 10011, ADx=i, /W=0 */ | ||
127 | #define I2C_DEVICE_CS4398 0x9e /* 10011, AD1=1, AD0=1, /W=0 */ | 187 | #define I2C_DEVICE_CS4398 0x9e /* 10011, AD1=1, AD0=1, /W=0 */ |
128 | #define I2C_DEVICE_CS4362A 0x30 /* 001100, AD0=0, /W=0 */ | 188 | #define I2C_DEVICE_CS4362A 0x30 /* 001100, AD0=0, /W=0 */ |
129 | 189 | ||
130 | struct xonar_data { | 190 | struct xonar_data { |
191 | unsigned int model; | ||
131 | unsigned int anti_pop_delay; | 192 | unsigned int anti_pop_delay; |
193 | unsigned int dacs; | ||
132 | u16 output_enable_bit; | 194 | u16 output_enable_bit; |
133 | u8 ext_power_reg; | 195 | u8 ext_power_reg; |
134 | u8 ext_power_int_reg; | 196 | u8 ext_power_int_reg; |
@@ -137,10 +199,13 @@ struct xonar_data { | |||
137 | u8 pcm1796_oversampling; | 199 | u8 pcm1796_oversampling; |
138 | u8 cs4398_fm; | 200 | u8 cs4398_fm; |
139 | u8 cs4362a_fm; | 201 | u8 cs4362a_fm; |
202 | u8 hdmi_params[5]; | ||
140 | }; | 203 | }; |
141 | 204 | ||
142 | static void pcm1796_write(struct oxygen *chip, unsigned int codec, | 205 | static void xonar_gpio_changed(struct oxygen *chip); |
143 | u8 reg, u8 value) | 206 | |
207 | static inline void pcm1796_write_spi(struct oxygen *chip, unsigned int codec, | ||
208 | u8 reg, u8 value) | ||
144 | { | 209 | { |
145 | /* maps ALSA channel pair number to SPI output */ | 210 | /* maps ALSA channel pair number to SPI output */ |
146 | static const u8 codec_map[4] = { | 211 | static const u8 codec_map[4] = { |
@@ -154,6 +219,22 @@ static void pcm1796_write(struct oxygen *chip, unsigned int codec, | |||
154 | (reg << 8) | value); | 219 | (reg << 8) | value); |
155 | } | 220 | } |
156 | 221 | ||
222 | static inline void pcm1796_write_i2c(struct oxygen *chip, unsigned int codec, | ||
223 | u8 reg, u8 value) | ||
224 | { | ||
225 | oxygen_write_i2c(chip, I2C_DEVICE_PCM1796(codec), reg, value); | ||
226 | } | ||
227 | |||
228 | static void pcm1796_write(struct oxygen *chip, unsigned int codec, | ||
229 | u8 reg, u8 value) | ||
230 | { | ||
231 | if ((chip->model.function_flags & OXYGEN_FUNCTION_2WIRE_SPI_MASK) == | ||
232 | OXYGEN_FUNCTION_SPI) | ||
233 | pcm1796_write_spi(chip, codec, reg, value); | ||
234 | else | ||
235 | pcm1796_write_i2c(chip, codec, reg, value); | ||
236 | } | ||
237 | |||
157 | static void cs4398_write(struct oxygen *chip, u8 reg, u8 value) | 238 | static void cs4398_write(struct oxygen *chip, u8 reg, u8 value) |
158 | { | 239 | { |
159 | oxygen_write_i2c(chip, I2C_DEVICE_CS4398, reg, value); | 240 | oxygen_write_i2c(chip, I2C_DEVICE_CS4398, reg, value); |
@@ -164,6 +245,24 @@ static void cs4362a_write(struct oxygen *chip, u8 reg, u8 value) | |||
164 | oxygen_write_i2c(chip, I2C_DEVICE_CS4362A, reg, value); | 245 | oxygen_write_i2c(chip, I2C_DEVICE_CS4362A, reg, value); |
165 | } | 246 | } |
166 | 247 | ||
248 | static void hdmi_write_command(struct oxygen *chip, u8 command, | ||
249 | unsigned int count, const u8 *params) | ||
250 | { | ||
251 | unsigned int i; | ||
252 | u8 checksum; | ||
253 | |||
254 | oxygen_write_uart(chip, 0xfb); | ||
255 | oxygen_write_uart(chip, 0xef); | ||
256 | oxygen_write_uart(chip, command); | ||
257 | oxygen_write_uart(chip, count); | ||
258 | for (i = 0; i < count; ++i) | ||
259 | oxygen_write_uart(chip, params[i]); | ||
260 | checksum = 0xfb + 0xef + command + count; | ||
261 | for (i = 0; i < count; ++i) | ||
262 | checksum += params[i]; | ||
263 | oxygen_write_uart(chip, checksum); | ||
264 | } | ||
265 | |||
167 | static void xonar_enable_output(struct oxygen *chip) | 266 | static void xonar_enable_output(struct oxygen *chip) |
168 | { | 267 | { |
169 | struct xonar_data *data = chip->model_data; | 268 | struct xonar_data *data = chip->model_data; |
@@ -180,6 +279,7 @@ static void xonar_common_init(struct oxygen *chip) | |||
180 | oxygen_set_bits8(chip, data->ext_power_int_reg, | 279 | oxygen_set_bits8(chip, data->ext_power_int_reg, |
181 | data->ext_power_bit); | 280 | data->ext_power_bit); |
182 | chip->interrupt_mask |= OXYGEN_INT_GPIO; | 281 | chip->interrupt_mask |= OXYGEN_INT_GPIO; |
282 | chip->model.gpio_changed = xonar_gpio_changed; | ||
183 | data->has_power = !!(oxygen_read8(chip, data->ext_power_reg) | 283 | data->has_power = !!(oxygen_read8(chip, data->ext_power_reg) |
184 | & data->ext_power_bit); | 284 | & data->ext_power_bit); |
185 | } | 285 | } |
@@ -193,9 +293,10 @@ static void xonar_common_init(struct oxygen *chip) | |||
193 | 293 | ||
194 | static void update_pcm1796_volume(struct oxygen *chip) | 294 | static void update_pcm1796_volume(struct oxygen *chip) |
195 | { | 295 | { |
296 | struct xonar_data *data = chip->model_data; | ||
196 | unsigned int i; | 297 | unsigned int i; |
197 | 298 | ||
198 | for (i = 0; i < 4; ++i) { | 299 | for (i = 0; i < data->dacs; ++i) { |
199 | pcm1796_write(chip, i, 16, chip->dac_volume[i * 2]); | 300 | pcm1796_write(chip, i, 16, chip->dac_volume[i * 2]); |
200 | pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]); | 301 | pcm1796_write(chip, i, 17, chip->dac_volume[i * 2 + 1]); |
201 | } | 302 | } |
@@ -203,13 +304,14 @@ static void update_pcm1796_volume(struct oxygen *chip) | |||
203 | 304 | ||
204 | static void update_pcm1796_mute(struct oxygen *chip) | 305 | static void update_pcm1796_mute(struct oxygen *chip) |
205 | { | 306 | { |
307 | struct xonar_data *data = chip->model_data; | ||
206 | unsigned int i; | 308 | unsigned int i; |
207 | u8 value; | 309 | u8 value; |
208 | 310 | ||
209 | value = PCM1796_DMF_DISABLED | PCM1796_FMT_24_LJUST | PCM1796_ATLD; | 311 | value = PCM1796_DMF_DISABLED | PCM1796_FMT_24_LJUST | PCM1796_ATLD; |
210 | if (chip->dac_mute) | 312 | if (chip->dac_mute) |
211 | value |= PCM1796_MUTE; | 313 | value |= PCM1796_MUTE; |
212 | for (i = 0; i < 4; ++i) | 314 | for (i = 0; i < data->dacs; ++i) |
213 | pcm1796_write(chip, i, 18, value); | 315 | pcm1796_write(chip, i, 18, value); |
214 | } | 316 | } |
215 | 317 | ||
@@ -218,7 +320,7 @@ static void pcm1796_init(struct oxygen *chip) | |||
218 | struct xonar_data *data = chip->model_data; | 320 | struct xonar_data *data = chip->model_data; |
219 | unsigned int i; | 321 | unsigned int i; |
220 | 322 | ||
221 | for (i = 0; i < 4; ++i) { | 323 | for (i = 0; i < data->dacs; ++i) { |
222 | pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); | 324 | pcm1796_write(chip, i, 19, PCM1796_FLT_SHARP | PCM1796_ATS_1); |
223 | pcm1796_write(chip, i, 20, data->pcm1796_oversampling); | 325 | pcm1796_write(chip, i, 20, data->pcm1796_oversampling); |
224 | pcm1796_write(chip, i, 21, 0); | 326 | pcm1796_write(chip, i, 21, 0); |
@@ -234,6 +336,13 @@ static void xonar_d2_init(struct oxygen *chip) | |||
234 | data->anti_pop_delay = 300; | 336 | data->anti_pop_delay = 300; |
235 | data->output_enable_bit = GPIO_D2_OUTPUT_ENABLE; | 337 | data->output_enable_bit = GPIO_D2_OUTPUT_ENABLE; |
236 | data->pcm1796_oversampling = PCM1796_OS_64; | 338 | data->pcm1796_oversampling = PCM1796_OS_64; |
339 | if (data->model == MODEL_D2X) { | ||
340 | data->ext_power_reg = OXYGEN_GPIO_DATA; | ||
341 | data->ext_power_int_reg = OXYGEN_GPIO_INTERRUPT_MASK; | ||
342 | data->ext_power_bit = GPIO_D2X_EXT_POWER; | ||
343 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, | ||
344 | GPIO_D2X_EXT_POWER); | ||
345 | } | ||
237 | 346 | ||
238 | pcm1796_init(chip); | 347 | pcm1796_init(chip); |
239 | 348 | ||
@@ -246,17 +355,6 @@ static void xonar_d2_init(struct oxygen *chip) | |||
246 | snd_component_add(chip->card, "CS5381"); | 355 | snd_component_add(chip->card, "CS5381"); |
247 | } | 356 | } |
248 | 357 | ||
249 | static void xonar_d2x_init(struct oxygen *chip) | ||
250 | { | ||
251 | struct xonar_data *data = chip->model_data; | ||
252 | |||
253 | data->ext_power_reg = OXYGEN_GPIO_DATA; | ||
254 | data->ext_power_int_reg = OXYGEN_GPIO_INTERRUPT_MASK; | ||
255 | data->ext_power_bit = GPIO_D2X_EXT_POWER; | ||
256 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_D2X_EXT_POWER); | ||
257 | xonar_d2_init(chip); | ||
258 | } | ||
259 | |||
260 | static void update_cs4362a_volumes(struct oxygen *chip) | 358 | static void update_cs4362a_volumes(struct oxygen *chip) |
261 | { | 359 | { |
262 | u8 mute; | 360 | u8 mute; |
@@ -324,6 +422,11 @@ static void xonar_d1_init(struct oxygen *chip) | |||
324 | data->cs4398_fm = CS4398_FM_SINGLE | CS4398_DEM_NONE | CS4398_DIF_LJUST; | 422 | data->cs4398_fm = CS4398_FM_SINGLE | CS4398_DEM_NONE | CS4398_DIF_LJUST; |
325 | data->cs4362a_fm = CS4362A_FM_SINGLE | | 423 | data->cs4362a_fm = CS4362A_FM_SINGLE | |
326 | CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L; | 424 | CS4362A_ATAPI_B_R | CS4362A_ATAPI_A_L; |
425 | if (data->model == MODEL_DX) { | ||
426 | data->ext_power_reg = OXYGEN_GPI_DATA; | ||
427 | data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; | ||
428 | data->ext_power_bit = GPI_DX_EXT_POWER; | ||
429 | } | ||
327 | 430 | ||
328 | oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, | 431 | oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, |
329 | OXYGEN_2WIRE_LENGTH_8 | | 432 | OXYGEN_2WIRE_LENGTH_8 | |
@@ -344,30 +447,86 @@ static void xonar_d1_init(struct oxygen *chip) | |||
344 | snd_component_add(chip->card, "CS5361"); | 447 | snd_component_add(chip->card, "CS5361"); |
345 | } | 448 | } |
346 | 449 | ||
347 | static void xonar_dx_init(struct oxygen *chip) | 450 | static void xonar_hdav_init(struct oxygen *chip) |
348 | { | 451 | { |
349 | struct xonar_data *data = chip->model_data; | 452 | struct xonar_data *data = chip->model_data; |
453 | u8 param; | ||
350 | 454 | ||
455 | oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS, | ||
456 | OXYGEN_2WIRE_LENGTH_8 | | ||
457 | OXYGEN_2WIRE_INTERRUPT_MASK | | ||
458 | OXYGEN_2WIRE_SPEED_FAST); | ||
459 | |||
460 | data->anti_pop_delay = 100; | ||
461 | data->output_enable_bit = GPIO_DX_OUTPUT_ENABLE; | ||
351 | data->ext_power_reg = OXYGEN_GPI_DATA; | 462 | data->ext_power_reg = OXYGEN_GPI_DATA; |
352 | data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; | 463 | data->ext_power_int_reg = OXYGEN_GPI_INTERRUPT_MASK; |
353 | data->ext_power_bit = GPI_DX_EXT_POWER; | 464 | data->ext_power_bit = GPI_DX_EXT_POWER; |
354 | xonar_d1_init(chip); | 465 | data->pcm1796_oversampling = PCM1796_OS_64; |
466 | |||
467 | pcm1796_init(chip); | ||
468 | |||
469 | oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_DX_INPUT_ROUTE); | ||
470 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, GPIO_DX_INPUT_ROUTE); | ||
471 | |||
472 | oxygen_reset_uart(chip); | ||
473 | param = 0; | ||
474 | hdmi_write_command(chip, 0x61, 1, ¶m); | ||
475 | param = 1; | ||
476 | hdmi_write_command(chip, 0x74, 1, ¶m); | ||
477 | data->hdmi_params[1] = IEC958_AES3_CON_FS_48000; | ||
478 | data->hdmi_params[4] = 1; | ||
479 | hdmi_write_command(chip, 0x54, 5, data->hdmi_params); | ||
480 | |||
481 | xonar_common_init(chip); | ||
482 | |||
483 | snd_component_add(chip->card, "PCM1796"); | ||
484 | snd_component_add(chip->card, "CS5381"); | ||
355 | } | 485 | } |
356 | 486 | ||
357 | static void xonar_cleanup(struct oxygen *chip) | 487 | static void xonar_disable_output(struct oxygen *chip) |
358 | { | 488 | { |
359 | struct xonar_data *data = chip->model_data; | 489 | struct xonar_data *data = chip->model_data; |
360 | 490 | ||
361 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit); | 491 | oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit); |
362 | } | 492 | } |
363 | 493 | ||
494 | static void xonar_d2_cleanup(struct oxygen *chip) | ||
495 | { | ||
496 | xonar_disable_output(chip); | ||
497 | } | ||
498 | |||
364 | static void xonar_d1_cleanup(struct oxygen *chip) | 499 | static void xonar_d1_cleanup(struct oxygen *chip) |
365 | { | 500 | { |
366 | xonar_cleanup(chip); | 501 | xonar_disable_output(chip); |
367 | cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN); | 502 | cs4362a_write(chip, 0x01, CS4362A_PDN | CS4362A_CPEN); |
368 | oxygen_clear_bits8(chip, OXYGEN_FUNCTION, OXYGEN_FUNCTION_RESET_CODEC); | 503 | oxygen_clear_bits8(chip, OXYGEN_FUNCTION, OXYGEN_FUNCTION_RESET_CODEC); |
369 | } | 504 | } |
370 | 505 | ||
506 | static void xonar_hdav_cleanup(struct oxygen *chip) | ||
507 | { | ||
508 | u8 param = 0; | ||
509 | |||
510 | hdmi_write_command(chip, 0x74, 1, ¶m); | ||
511 | xonar_disable_output(chip); | ||
512 | } | ||
513 | |||
514 | static void xonar_d2_suspend(struct oxygen *chip) | ||
515 | { | ||
516 | xonar_d2_cleanup(chip); | ||
517 | } | ||
518 | |||
519 | static void xonar_d1_suspend(struct oxygen *chip) | ||
520 | { | ||
521 | xonar_d1_cleanup(chip); | ||
522 | } | ||
523 | |||
524 | static void xonar_hdav_suspend(struct oxygen *chip) | ||
525 | { | ||
526 | xonar_hdav_cleanup(chip); | ||
527 | msleep(2); | ||
528 | } | ||
529 | |||
371 | static void xonar_d2_resume(struct oxygen *chip) | 530 | static void xonar_d2_resume(struct oxygen *chip) |
372 | { | 531 | { |
373 | pcm1796_init(chip); | 532 | pcm1796_init(chip); |
@@ -380,6 +539,33 @@ static void xonar_d1_resume(struct oxygen *chip) | |||
380 | xonar_enable_output(chip); | 539 | xonar_enable_output(chip); |
381 | } | 540 | } |
382 | 541 | ||
542 | static void xonar_hdav_resume(struct oxygen *chip) | ||
543 | { | ||
544 | struct xonar_data *data = chip->model_data; | ||
545 | u8 param; | ||
546 | |||
547 | oxygen_reset_uart(chip); | ||
548 | param = 0; | ||
549 | hdmi_write_command(chip, 0x61, 1, ¶m); | ||
550 | param = 1; | ||
551 | hdmi_write_command(chip, 0x74, 1, ¶m); | ||
552 | hdmi_write_command(chip, 0x54, 5, data->hdmi_params); | ||
553 | pcm1796_init(chip); | ||
554 | xonar_enable_output(chip); | ||
555 | } | ||
556 | |||
557 | static void xonar_hdav_pcm_hardware_filter(unsigned int channel, | ||
558 | struct snd_pcm_hardware *hardware) | ||
559 | { | ||
560 | if (channel == PCM_MULTICH) { | ||
561 | hardware->rates = SNDRV_PCM_RATE_44100 | | ||
562 | SNDRV_PCM_RATE_48000 | | ||
563 | SNDRV_PCM_RATE_96000 | | ||
564 | SNDRV_PCM_RATE_192000; | ||
565 | hardware->rate_min = 44100; | ||
566 | } | ||
567 | } | ||
568 | |||
383 | static void set_pcm1796_params(struct oxygen *chip, | 569 | static void set_pcm1796_params(struct oxygen *chip, |
384 | struct snd_pcm_hw_params *params) | 570 | struct snd_pcm_hw_params *params) |
385 | { | 571 | { |
@@ -388,7 +574,7 @@ static void set_pcm1796_params(struct oxygen *chip, | |||
388 | 574 | ||
389 | data->pcm1796_oversampling = | 575 | data->pcm1796_oversampling = |
390 | params_rate(params) >= 96000 ? PCM1796_OS_32 : PCM1796_OS_64; | 576 | params_rate(params) >= 96000 ? PCM1796_OS_32 : PCM1796_OS_64; |
391 | for (i = 0; i < 4; ++i) | 577 | for (i = 0; i < data->dacs; ++i) |
392 | pcm1796_write(chip, i, 20, data->pcm1796_oversampling); | 578 | pcm1796_write(chip, i, 20, data->pcm1796_oversampling); |
393 | } | 579 | } |
394 | 580 | ||
@@ -430,6 +616,42 @@ static void set_cs43xx_params(struct oxygen *chip, | |||
430 | cs4362a_write(chip, 0x0c, data->cs4362a_fm); | 616 | cs4362a_write(chip, 0x0c, data->cs4362a_fm); |
431 | } | 617 | } |
432 | 618 | ||
619 | static void set_hdmi_params(struct oxygen *chip, | ||
620 | struct snd_pcm_hw_params *params) | ||
621 | { | ||
622 | struct xonar_data *data = chip->model_data; | ||
623 | |||
624 | data->hdmi_params[0] = 0; /* 1 = non-audio */ | ||
625 | switch (params_rate(params)) { | ||
626 | case 44100: | ||
627 | data->hdmi_params[1] = IEC958_AES3_CON_FS_44100; | ||
628 | break; | ||
629 | case 48000: | ||
630 | data->hdmi_params[1] = IEC958_AES3_CON_FS_48000; | ||
631 | break; | ||
632 | default: /* 96000 */ | ||
633 | data->hdmi_params[1] = IEC958_AES3_CON_FS_96000; | ||
634 | break; | ||
635 | case 192000: | ||
636 | data->hdmi_params[1] = IEC958_AES3_CON_FS_192000; | ||
637 | break; | ||
638 | } | ||
639 | data->hdmi_params[2] = params_channels(params) / 2 - 1; | ||
640 | if (params_format(params) == SNDRV_PCM_FORMAT_S16_LE) | ||
641 | data->hdmi_params[3] = 0; | ||
642 | else | ||
643 | data->hdmi_params[3] = 0xc0; | ||
644 | data->hdmi_params[4] = 1; /* ? */ | ||
645 | hdmi_write_command(chip, 0x54, 5, data->hdmi_params); | ||
646 | } | ||
647 | |||
648 | static void set_hdav_params(struct oxygen *chip, | ||
649 | struct snd_pcm_hw_params *params) | ||
650 | { | ||
651 | set_pcm1796_params(chip, params); | ||
652 | set_hdmi_params(chip, params); | ||
653 | } | ||
654 | |||
433 | static void xonar_gpio_changed(struct oxygen *chip) | 655 | static void xonar_gpio_changed(struct oxygen *chip) |
434 | { | 656 | { |
435 | struct xonar_data *data = chip->model_data; | 657 | struct xonar_data *data = chip->model_data; |
@@ -449,29 +671,43 @@ static void xonar_gpio_changed(struct oxygen *chip) | |||
449 | } | 671 | } |
450 | } | 672 | } |
451 | 673 | ||
452 | static int alt_switch_get(struct snd_kcontrol *ctl, | 674 | static void xonar_hdav_uart_input(struct oxygen *chip) |
453 | struct snd_ctl_elem_value *value) | 675 | { |
676 | if (chip->uart_input_count >= 2 && | ||
677 | chip->uart_input[chip->uart_input_count - 2] == 'O' && | ||
678 | chip->uart_input[chip->uart_input_count - 1] == 'K') { | ||
679 | printk(KERN_DEBUG "message from Xonar HDAV HDMI chip received:"); | ||
680 | print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, | ||
681 | chip->uart_input, chip->uart_input_count); | ||
682 | chip->uart_input_count = 0; | ||
683 | } | ||
684 | } | ||
685 | |||
686 | static int gpio_bit_switch_get(struct snd_kcontrol *ctl, | ||
687 | struct snd_ctl_elem_value *value) | ||
454 | { | 688 | { |
455 | struct oxygen *chip = ctl->private_data; | 689 | struct oxygen *chip = ctl->private_data; |
690 | u16 bit = ctl->private_value; | ||
456 | 691 | ||
457 | value->value.integer.value[0] = | 692 | value->value.integer.value[0] = |
458 | !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_D2_ALT); | 693 | !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & bit); |
459 | return 0; | 694 | return 0; |
460 | } | 695 | } |
461 | 696 | ||
462 | static int alt_switch_put(struct snd_kcontrol *ctl, | 697 | static int gpio_bit_switch_put(struct snd_kcontrol *ctl, |
463 | struct snd_ctl_elem_value *value) | 698 | struct snd_ctl_elem_value *value) |
464 | { | 699 | { |
465 | struct oxygen *chip = ctl->private_data; | 700 | struct oxygen *chip = ctl->private_data; |
701 | u16 bit = ctl->private_value; | ||
466 | u16 old_bits, new_bits; | 702 | u16 old_bits, new_bits; |
467 | int changed; | 703 | int changed; |
468 | 704 | ||
469 | spin_lock_irq(&chip->reg_lock); | 705 | spin_lock_irq(&chip->reg_lock); |
470 | old_bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); | 706 | old_bits = oxygen_read16(chip, OXYGEN_GPIO_DATA); |
471 | if (value->value.integer.value[0]) | 707 | if (value->value.integer.value[0]) |
472 | new_bits = old_bits | GPIO_D2_ALT; | 708 | new_bits = old_bits | bit; |
473 | else | 709 | else |
474 | new_bits = old_bits & ~GPIO_D2_ALT; | 710 | new_bits = old_bits & ~bit; |
475 | changed = new_bits != old_bits; | 711 | changed = new_bits != old_bits; |
476 | if (changed) | 712 | if (changed) |
477 | oxygen_write16(chip, OXYGEN_GPIO_DATA, new_bits); | 713 | oxygen_write16(chip, OXYGEN_GPIO_DATA, new_bits); |
@@ -483,47 +719,22 @@ static const struct snd_kcontrol_new alt_switch = { | |||
483 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 719 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
484 | .name = "Analog Loopback Switch", | 720 | .name = "Analog Loopback Switch", |
485 | .info = snd_ctl_boolean_mono_info, | 721 | .info = snd_ctl_boolean_mono_info, |
486 | .get = alt_switch_get, | 722 | .get = gpio_bit_switch_get, |
487 | .put = alt_switch_put, | 723 | .put = gpio_bit_switch_put, |
724 | .private_value = GPIO_D2_ALT, | ||
488 | }; | 725 | }; |
489 | 726 | ||
490 | static int front_panel_get(struct snd_kcontrol *ctl, | ||
491 | struct snd_ctl_elem_value *value) | ||
492 | { | ||
493 | struct oxygen *chip = ctl->private_data; | ||
494 | |||
495 | value->value.integer.value[0] = | ||
496 | !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & GPIO_DX_FRONT_PANEL); | ||
497 | return 0; | ||
498 | } | ||
499 | |||
500 | static int front_panel_put(struct snd_kcontrol *ctl, | ||
501 | struct snd_ctl_elem_value *value) | ||
502 | { | ||
503 | struct oxygen *chip = ctl->private_data; | ||
504 | u16 old_reg, new_reg; | ||
505 | |||
506 | spin_lock_irq(&chip->reg_lock); | ||
507 | old_reg = oxygen_read16(chip, OXYGEN_GPIO_DATA); | ||
508 | if (value->value.integer.value[0]) | ||
509 | new_reg = old_reg | GPIO_DX_FRONT_PANEL; | ||
510 | else | ||
511 | new_reg = old_reg & ~GPIO_DX_FRONT_PANEL; | ||
512 | oxygen_write16(chip, OXYGEN_GPIO_DATA, new_reg); | ||
513 | spin_unlock_irq(&chip->reg_lock); | ||
514 | return old_reg != new_reg; | ||
515 | } | ||
516 | |||
517 | static const struct snd_kcontrol_new front_panel_switch = { | 727 | static const struct snd_kcontrol_new front_panel_switch = { |
518 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 728 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
519 | .name = "Front Panel Switch", | 729 | .name = "Front Panel Switch", |
520 | .info = snd_ctl_boolean_mono_info, | 730 | .info = snd_ctl_boolean_mono_info, |
521 | .get = front_panel_get, | 731 | .get = gpio_bit_switch_get, |
522 | .put = front_panel_put, | 732 | .put = gpio_bit_switch_put, |
733 | .private_value = GPIO_DX_FRONT_PANEL, | ||
523 | }; | 734 | }; |
524 | 735 | ||
525 | static void xonar_d1_ac97_switch(struct oxygen *chip, | 736 | static void xonar_line_mic_ac97_switch(struct oxygen *chip, |
526 | unsigned int reg, unsigned int mute) | 737 | unsigned int reg, unsigned int mute) |
527 | { | 738 | { |
528 | if (reg == AC97_LINE) { | 739 | if (reg == AC97_LINE) { |
529 | spin_lock_irq(&chip->reg_lock); | 740 | spin_lock_irq(&chip->reg_lock); |
@@ -552,7 +763,7 @@ static int xonar_d1_control_filter(struct snd_kcontrol_new *template) | |||
552 | return 0; | 763 | return 0; |
553 | } | 764 | } |
554 | 765 | ||
555 | static int xonar_mixer_init(struct oxygen *chip) | 766 | static int xonar_d2_mixer_init(struct oxygen *chip) |
556 | { | 767 | { |
557 | return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip)); | 768 | return snd_ctl_add(chip->card, snd_ctl_new1(&alt_switch, chip)); |
558 | } | 769 | } |
@@ -562,130 +773,147 @@ static int xonar_d1_mixer_init(struct oxygen *chip) | |||
562 | return snd_ctl_add(chip->card, snd_ctl_new1(&front_panel_switch, chip)); | 773 | return snd_ctl_add(chip->card, snd_ctl_new1(&front_panel_switch, chip)); |
563 | } | 774 | } |
564 | 775 | ||
565 | static const struct oxygen_model xonar_models[] = { | 776 | static int xonar_model_probe(struct oxygen *chip, unsigned long driver_data) |
566 | [MODEL_D2] = { | 777 | { |
567 | .shortname = "Xonar D2", | 778 | static const char *const names[] = { |
568 | .longname = "Asus Virtuoso 200", | 779 | [MODEL_D1] = "Xonar D1", |
569 | .chip = "AV200", | 780 | [MODEL_DX] = "Xonar DX", |
570 | .owner = THIS_MODULE, | 781 | [MODEL_D2] = "Xonar D2", |
571 | .init = xonar_d2_init, | 782 | [MODEL_D2X] = "Xonar D2X", |
572 | .control_filter = xonar_d2_control_filter, | 783 | [MODEL_HDAV] = "Xonar HDAV1.3", |
573 | .mixer_init = xonar_mixer_init, | 784 | [MODEL_HDAV_H6] = "Xonar HDAV1.3+H6", |
574 | .cleanup = xonar_cleanup, | 785 | }; |
575 | .suspend = xonar_cleanup, | 786 | static const u8 dacs[] = { |
576 | .resume = xonar_d2_resume, | 787 | [MODEL_D1] = 2, |
577 | .set_dac_params = set_pcm1796_params, | 788 | [MODEL_DX] = 2, |
578 | .set_adc_params = set_cs53x1_params, | 789 | [MODEL_D2] = 4, |
579 | .update_dac_volume = update_pcm1796_volume, | 790 | [MODEL_D2X] = 4, |
580 | .update_dac_mute = update_pcm1796_mute, | 791 | [MODEL_HDAV] = 1, |
581 | .dac_tlv = pcm1796_db_scale, | 792 | [MODEL_HDAV_H6] = 4, |
582 | .model_data_size = sizeof(struct xonar_data), | 793 | }; |
583 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | | 794 | struct xonar_data *data = chip->model_data; |
584 | PLAYBACK_1_TO_SPDIF | | 795 | |
585 | CAPTURE_0_FROM_I2S_2 | | 796 | data->model = driver_data; |
586 | CAPTURE_1_FROM_SPDIF, | 797 | if (data->model == MODEL_HDAV) { |
587 | .dac_channels = 8, | 798 | oxygen_clear_bits16(chip, OXYGEN_GPIO_CONTROL, |
588 | .dac_volume_min = 0x0f, | 799 | GPIO_HDAV_DB_MASK); |
589 | .dac_volume_max = 0xff, | 800 | switch (oxygen_read16(chip, OXYGEN_GPIO_DATA) & |
590 | .misc_flags = OXYGEN_MISC_MIDI, | 801 | GPIO_HDAV_DB_MASK) { |
591 | .function_flags = OXYGEN_FUNCTION_SPI | | 802 | case GPIO_HDAV_DB_H6: |
592 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, | 803 | data->model = MODEL_HDAV_H6; |
593 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 804 | break; |
594 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 805 | case GPIO_HDAV_DB_XX: |
595 | }, | 806 | snd_printk(KERN_ERR "unknown daughterboard\n"); |
596 | [MODEL_D2X] = { | 807 | return -ENODEV; |
597 | .shortname = "Xonar D2X", | 808 | } |
598 | .longname = "Asus Virtuoso 200", | 809 | } |
599 | .chip = "AV200", | 810 | |
600 | .owner = THIS_MODULE, | 811 | data->dacs = dacs[data->model]; |
601 | .init = xonar_d2x_init, | 812 | chip->model.shortname = names[data->model]; |
602 | .control_filter = xonar_d2_control_filter, | 813 | return 0; |
603 | .mixer_init = xonar_mixer_init, | 814 | } |
604 | .cleanup = xonar_cleanup, | 815 | |
605 | .suspend = xonar_cleanup, | 816 | static const struct oxygen_model model_xonar_d2 = { |
606 | .resume = xonar_d2_resume, | 817 | .longname = "Asus Virtuoso 200", |
607 | .set_dac_params = set_pcm1796_params, | 818 | .chip = "AV200", |
608 | .set_adc_params = set_cs53x1_params, | 819 | .owner = THIS_MODULE, |
609 | .update_dac_volume = update_pcm1796_volume, | 820 | .probe = xonar_model_probe, |
610 | .update_dac_mute = update_pcm1796_mute, | 821 | .init = xonar_d2_init, |
611 | .gpio_changed = xonar_gpio_changed, | 822 | .control_filter = xonar_d2_control_filter, |
612 | .dac_tlv = pcm1796_db_scale, | 823 | .mixer_init = xonar_d2_mixer_init, |
613 | .model_data_size = sizeof(struct xonar_data), | 824 | .cleanup = xonar_d2_cleanup, |
614 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | | 825 | .suspend = xonar_d2_suspend, |
615 | PLAYBACK_1_TO_SPDIF | | 826 | .resume = xonar_d2_resume, |
616 | CAPTURE_0_FROM_I2S_2 | | 827 | .set_dac_params = set_pcm1796_params, |
617 | CAPTURE_1_FROM_SPDIF, | 828 | .set_adc_params = set_cs53x1_params, |
618 | .dac_channels = 8, | 829 | .update_dac_volume = update_pcm1796_volume, |
619 | .dac_volume_min = 0x0f, | 830 | .update_dac_mute = update_pcm1796_mute, |
620 | .dac_volume_max = 0xff, | 831 | .dac_tlv = pcm1796_db_scale, |
621 | .misc_flags = OXYGEN_MISC_MIDI, | 832 | .model_data_size = sizeof(struct xonar_data), |
622 | .function_flags = OXYGEN_FUNCTION_SPI | | 833 | .device_config = PLAYBACK_0_TO_I2S | |
623 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, | 834 | PLAYBACK_1_TO_SPDIF | |
624 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 835 | CAPTURE_0_FROM_I2S_2 | |
625 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 836 | CAPTURE_1_FROM_SPDIF | |
626 | }, | 837 | MIDI_OUTPUT | |
627 | [MODEL_D1] = { | 838 | MIDI_INPUT, |
628 | .shortname = "Xonar D1", | 839 | .dac_channels = 8, |
629 | .longname = "Asus Virtuoso 100", | 840 | .dac_volume_min = 0x0f, |
630 | .chip = "AV200", | 841 | .dac_volume_max = 0xff, |
631 | .owner = THIS_MODULE, | 842 | .misc_flags = OXYGEN_MISC_MIDI, |
632 | .init = xonar_d1_init, | 843 | .function_flags = OXYGEN_FUNCTION_SPI | |
633 | .control_filter = xonar_d1_control_filter, | 844 | OXYGEN_FUNCTION_ENABLE_SPI_4_5, |
634 | .mixer_init = xonar_d1_mixer_init, | 845 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
635 | .cleanup = xonar_d1_cleanup, | 846 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
636 | .suspend = xonar_d1_cleanup, | 847 | }; |
637 | .resume = xonar_d1_resume, | 848 | |
638 | .set_dac_params = set_cs43xx_params, | 849 | static const struct oxygen_model model_xonar_d1 = { |
639 | .set_adc_params = set_cs53x1_params, | 850 | .longname = "Asus Virtuoso 100", |
640 | .update_dac_volume = update_cs43xx_volume, | 851 | .chip = "AV200", |
641 | .update_dac_mute = update_cs43xx_mute, | 852 | .owner = THIS_MODULE, |
642 | .ac97_switch = xonar_d1_ac97_switch, | 853 | .probe = xonar_model_probe, |
643 | .dac_tlv = cs4362a_db_scale, | 854 | .init = xonar_d1_init, |
644 | .model_data_size = sizeof(struct xonar_data), | 855 | .control_filter = xonar_d1_control_filter, |
645 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | | 856 | .mixer_init = xonar_d1_mixer_init, |
646 | PLAYBACK_1_TO_SPDIF | | 857 | .cleanup = xonar_d1_cleanup, |
647 | CAPTURE_0_FROM_I2S_2, | 858 | .suspend = xonar_d1_suspend, |
648 | .dac_channels = 8, | 859 | .resume = xonar_d1_resume, |
649 | .dac_volume_min = 0, | 860 | .set_dac_params = set_cs43xx_params, |
650 | .dac_volume_max = 127, | 861 | .set_adc_params = set_cs53x1_params, |
651 | .function_flags = OXYGEN_FUNCTION_2WIRE, | 862 | .update_dac_volume = update_cs43xx_volume, |
652 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 863 | .update_dac_mute = update_cs43xx_mute, |
653 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 864 | .ac97_switch = xonar_line_mic_ac97_switch, |
654 | }, | 865 | .dac_tlv = cs4362a_db_scale, |
655 | [MODEL_DX] = { | 866 | .model_data_size = sizeof(struct xonar_data), |
656 | .shortname = "Xonar DX", | 867 | .device_config = PLAYBACK_0_TO_I2S | |
657 | .longname = "Asus Virtuoso 100", | 868 | PLAYBACK_1_TO_SPDIF | |
658 | .chip = "AV200", | 869 | CAPTURE_0_FROM_I2S_2, |
659 | .owner = THIS_MODULE, | 870 | .dac_channels = 8, |
660 | .init = xonar_dx_init, | 871 | .dac_volume_min = 0, |
661 | .control_filter = xonar_d1_control_filter, | 872 | .dac_volume_max = 127, |
662 | .mixer_init = xonar_d1_mixer_init, | 873 | .function_flags = OXYGEN_FUNCTION_2WIRE, |
663 | .cleanup = xonar_d1_cleanup, | 874 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
664 | .suspend = xonar_d1_cleanup, | 875 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, |
665 | .resume = xonar_d1_resume, | 876 | }; |
666 | .set_dac_params = set_cs43xx_params, | 877 | |
667 | .set_adc_params = set_cs53x1_params, | 878 | static const struct oxygen_model model_xonar_hdav = { |
668 | .update_dac_volume = update_cs43xx_volume, | 879 | .longname = "Asus Virtuoso 200", |
669 | .update_dac_mute = update_cs43xx_mute, | 880 | .chip = "AV200", |
670 | .gpio_changed = xonar_gpio_changed, | 881 | .owner = THIS_MODULE, |
671 | .ac97_switch = xonar_d1_ac97_switch, | 882 | .probe = xonar_model_probe, |
672 | .dac_tlv = cs4362a_db_scale, | 883 | .init = xonar_hdav_init, |
673 | .model_data_size = sizeof(struct xonar_data), | 884 | .cleanup = xonar_hdav_cleanup, |
674 | .pcm_dev_cfg = PLAYBACK_0_TO_I2S | | 885 | .suspend = xonar_hdav_suspend, |
675 | PLAYBACK_1_TO_SPDIF | | 886 | .resume = xonar_hdav_resume, |
676 | CAPTURE_0_FROM_I2S_2, | 887 | .pcm_hardware_filter = xonar_hdav_pcm_hardware_filter, |
677 | .dac_channels = 8, | 888 | .set_dac_params = set_hdav_params, |
678 | .dac_volume_min = 0, | 889 | .set_adc_params = set_cs53x1_params, |
679 | .dac_volume_max = 127, | 890 | .update_dac_volume = update_pcm1796_volume, |
680 | .function_flags = OXYGEN_FUNCTION_2WIRE, | 891 | .update_dac_mute = update_pcm1796_mute, |
681 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 892 | .uart_input = xonar_hdav_uart_input, |
682 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | 893 | .ac97_switch = xonar_line_mic_ac97_switch, |
683 | }, | 894 | .dac_tlv = pcm1796_db_scale, |
895 | .model_data_size = sizeof(struct xonar_data), | ||
896 | .device_config = PLAYBACK_0_TO_I2S | | ||
897 | PLAYBACK_1_TO_SPDIF | | ||
898 | CAPTURE_0_FROM_I2S_2, | ||
899 | .dac_channels = 8, | ||
900 | .dac_volume_min = 0x0f, | ||
901 | .dac_volume_max = 0xff, | ||
902 | .function_flags = OXYGEN_FUNCTION_2WIRE, | ||
903 | .dac_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
904 | .adc_i2s_format = OXYGEN_I2S_FORMAT_LJUST, | ||
684 | }; | 905 | }; |
685 | 906 | ||
686 | static int __devinit xonar_probe(struct pci_dev *pci, | 907 | static int __devinit xonar_probe(struct pci_dev *pci, |
687 | const struct pci_device_id *pci_id) | 908 | const struct pci_device_id *pci_id) |
688 | { | 909 | { |
910 | static const struct oxygen_model *const models[] = { | ||
911 | [MODEL_D1] = &model_xonar_d1, | ||
912 | [MODEL_DX] = &model_xonar_d1, | ||
913 | [MODEL_D2] = &model_xonar_d2, | ||
914 | [MODEL_D2X] = &model_xonar_d2, | ||
915 | [MODEL_HDAV] = &model_xonar_hdav, | ||
916 | }; | ||
689 | static int dev; | 917 | static int dev; |
690 | int err; | 918 | int err; |
691 | 919 | ||
@@ -695,8 +923,10 @@ static int __devinit xonar_probe(struct pci_dev *pci, | |||
695 | ++dev; | 923 | ++dev; |
696 | return -ENOENT; | 924 | return -ENOENT; |
697 | } | 925 | } |
926 | BUG_ON(pci_id->driver_data >= ARRAY_SIZE(models)); | ||
698 | err = oxygen_pci_probe(pci, index[dev], id[dev], | 927 | err = oxygen_pci_probe(pci, index[dev], id[dev], |
699 | &xonar_models[pci_id->driver_data]); | 928 | models[pci_id->driver_data], |
929 | pci_id->driver_data); | ||
700 | if (err >= 0) | 930 | if (err >= 0) |
701 | ++dev; | 931 | ++dev; |
702 | return err; | 932 | return err; |