blob: d10cc6ee1a68a8537425df706b10313159320236 [file] [log] [blame]
Clemens Ladischd0ce9942007-12-23 19:50:57 +01001/*
2 * C-Media CMI8788 driver - main driver module
3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 *
6 *
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2.
9 *
10 * This driver is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this driver; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
Clemens Ladischd0ce9942007-12-23 19:50:57 +010020#include <linux/delay.h>
21#include <linux/interrupt.h>
22#include <linux/mutex.h>
23#include <linux/pci.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090024#include <linux/slab.h>
Clemens Ladischd0ce9942007-12-23 19:50:57 +010025#include <sound/ac97_codec.h>
26#include <sound/asoundef.h>
27#include <sound/core.h>
28#include <sound/info.h>
29#include <sound/mpu401.h>
30#include <sound/pcm.h>
31#include "oxygen.h"
Clemens Ladisch878ac3e2008-01-21 08:50:19 +010032#include "cm9780.h"
Clemens Ladischd0ce9942007-12-23 19:50:57 +010033
34MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
35MODULE_DESCRIPTION("C-Media CMI8788 helper library");
Clemens Ladischd023dc02008-05-13 09:18:27 +020036MODULE_LICENSE("GPL v2");
Clemens Ladischd0ce9942007-12-23 19:50:57 +010037
Clemens Ladischa69bb3c2009-02-19 08:38:55 +010038#define DRIVER "oxygen"
Clemens Ladischd0ce9942007-12-23 19:50:57 +010039
Clemens Ladisch397b1dc2008-09-22 09:04:43 +020040static inline int oxygen_uart_input_ready(struct oxygen *chip)
41{
42 return !(oxygen_read8(chip, OXYGEN_MPU401 + 1) & MPU401_RX_EMPTY);
43}
44
45static void oxygen_read_uart(struct oxygen *chip)
46{
47 if (unlikely(!oxygen_uart_input_ready(chip))) {
48 /* no data, but read it anyway to clear the interrupt */
49 oxygen_read8(chip, OXYGEN_MPU401);
50 return;
51 }
52 do {
53 u8 data = oxygen_read8(chip, OXYGEN_MPU401);
54 if (data == MPU401_ACK)
55 continue;
56 if (chip->uart_input_count >= ARRAY_SIZE(chip->uart_input))
57 chip->uart_input_count = 0;
58 chip->uart_input[chip->uart_input_count++] = data;
59 } while (oxygen_uart_input_ready(chip));
60 if (chip->model.uart_input)
61 chip->model.uart_input(chip);
62}
63
Clemens Ladischd0ce9942007-12-23 19:50:57 +010064static irqreturn_t oxygen_interrupt(int dummy, void *dev_id)
65{
66 struct oxygen *chip = dev_id;
67 unsigned int status, clear, elapsed_streams, i;
68
69 status = oxygen_read16(chip, OXYGEN_INTERRUPT_STATUS);
70 if (!status)
71 return IRQ_NONE;
72
73 spin_lock(&chip->reg_lock);
74
75 clear = status & (OXYGEN_CHANNEL_A |
76 OXYGEN_CHANNEL_B |
77 OXYGEN_CHANNEL_C |
78 OXYGEN_CHANNEL_SPDIF |
79 OXYGEN_CHANNEL_MULTICH |
80 OXYGEN_CHANNEL_AC97 |
Clemens Ladischc2353a02008-01-18 09:17:53 +010081 OXYGEN_INT_SPDIF_IN_DETECT |
Clemens Ladisch1e821dd2008-01-28 08:34:21 +010082 OXYGEN_INT_GPIO |
83 OXYGEN_INT_AC97);
Clemens Ladischd0ce9942007-12-23 19:50:57 +010084 if (clear) {
Clemens Ladischc2353a02008-01-18 09:17:53 +010085 if (clear & OXYGEN_INT_SPDIF_IN_DETECT)
86 chip->interrupt_mask &= ~OXYGEN_INT_SPDIF_IN_DETECT;
Clemens Ladischd0ce9942007-12-23 19:50:57 +010087 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK,
88 chip->interrupt_mask & ~clear);
89 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK,
90 chip->interrupt_mask);
91 }
92
93 elapsed_streams = status & chip->pcm_running;
94
95 spin_unlock(&chip->reg_lock);
96
97 for (i = 0; i < PCM_COUNT; ++i)
98 if ((elapsed_streams & (1 << i)) && chip->streams[i])
99 snd_pcm_period_elapsed(chip->streams[i]);
100
Clemens Ladischc2353a02008-01-18 09:17:53 +0100101 if (status & OXYGEN_INT_SPDIF_IN_DETECT) {
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100102 spin_lock(&chip->reg_lock);
103 i = oxygen_read32(chip, OXYGEN_SPDIF_CONTROL);
Clemens Ladisch7f0b8942008-01-21 08:53:30 +0100104 if (i & (OXYGEN_SPDIF_SENSE_INT | OXYGEN_SPDIF_LOCK_INT |
105 OXYGEN_SPDIF_RATE_INT)) {
106 /* write the interrupt bit(s) to clear */
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100107 oxygen_write32(chip, OXYGEN_SPDIF_CONTROL, i);
108 schedule_work(&chip->spdif_input_bits_work);
109 }
110 spin_unlock(&chip->reg_lock);
111 }
112
113 if (status & OXYGEN_INT_GPIO)
Clemens Ladisch7c014152008-01-28 08:36:55 +0100114 schedule_work(&chip->gpio_work);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100115
Clemens Ladisch397b1dc2008-09-22 09:04:43 +0200116 if (status & OXYGEN_INT_MIDI) {
117 if (chip->midi)
118 snd_mpu401_uart_interrupt(0, chip->midi->private_data);
119 else
120 oxygen_read_uart(chip);
121 }
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100122
Clemens Ladisch1e821dd2008-01-28 08:34:21 +0100123 if (status & OXYGEN_INT_AC97)
124 wake_up(&chip->ac97_waitqueue);
125
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100126 return IRQ_HANDLED;
127}
128
129static void oxygen_spdif_input_bits_changed(struct work_struct *work)
130{
131 struct oxygen *chip = container_of(work, struct oxygen,
132 spdif_input_bits_work);
Clemens Ladisch7f0b8942008-01-21 08:53:30 +0100133 u32 reg;
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100134
Clemens Ladisch7f0b8942008-01-21 08:53:30 +0100135 /*
136 * This function gets called when there is new activity on the SPDIF
137 * input, or when we lose lock on the input signal, or when the rate
138 * changes.
139 */
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100140 msleep(1);
Clemens Ladisch7f0b8942008-01-21 08:53:30 +0100141 spin_lock_irq(&chip->reg_lock);
142 reg = oxygen_read32(chip, OXYGEN_SPDIF_CONTROL);
143 if ((reg & (OXYGEN_SPDIF_SENSE_STATUS |
144 OXYGEN_SPDIF_LOCK_STATUS))
145 == OXYGEN_SPDIF_SENSE_STATUS) {
146 /*
147 * If we detect activity on the SPDIF input but cannot lock to
148 * a signal, the clock bit is likely to be wrong.
149 */
150 reg ^= OXYGEN_SPDIF_IN_CLOCK_MASK;
151 oxygen_write32(chip, OXYGEN_SPDIF_CONTROL, reg);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100152 spin_unlock_irq(&chip->reg_lock);
153 msleep(1);
Clemens Ladisch7f0b8942008-01-21 08:53:30 +0100154 spin_lock_irq(&chip->reg_lock);
155 reg = oxygen_read32(chip, OXYGEN_SPDIF_CONTROL);
156 if ((reg & (OXYGEN_SPDIF_SENSE_STATUS |
157 OXYGEN_SPDIF_LOCK_STATUS))
158 == OXYGEN_SPDIF_SENSE_STATUS) {
159 /* nothing detected with either clock; give up */
160 if ((reg & OXYGEN_SPDIF_IN_CLOCK_MASK)
161 == OXYGEN_SPDIF_IN_CLOCK_192) {
162 /*
163 * Reset clock to <= 96 kHz because this is
164 * more likely to be received next time.
165 */
166 reg &= ~OXYGEN_SPDIF_IN_CLOCK_MASK;
167 reg |= OXYGEN_SPDIF_IN_CLOCK_96;
168 oxygen_write32(chip, OXYGEN_SPDIF_CONTROL, reg);
169 }
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100170 }
171 }
Clemens Ladisch7f0b8942008-01-21 08:53:30 +0100172 spin_unlock_irq(&chip->reg_lock);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100173
Clemens Ladisch01a3aff2008-01-14 08:56:01 +0100174 if (chip->controls[CONTROL_SPDIF_INPUT_BITS]) {
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100175 spin_lock_irq(&chip->reg_lock);
Clemens Ladischc2353a02008-01-18 09:17:53 +0100176 chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT;
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100177 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK,
178 chip->interrupt_mask);
179 spin_unlock_irq(&chip->reg_lock);
180
Clemens Ladisch7f0b8942008-01-21 08:53:30 +0100181 /*
182 * We don't actually know that any channel status bits have
183 * changed, but let's send a notification just to be sure.
184 */
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100185 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE,
Clemens Ladisch01a3aff2008-01-14 08:56:01 +0100186 &chip->controls[CONTROL_SPDIF_INPUT_BITS]->id);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100187 }
188}
189
Clemens Ladisch7c014152008-01-28 08:36:55 +0100190static void oxygen_gpio_changed(struct work_struct *work)
191{
192 struct oxygen *chip = container_of(work, struct oxygen, gpio_work);
193
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200194 if (chip->model.gpio_changed)
195 chip->model.gpio_changed(chip);
Clemens Ladisch7c014152008-01-28 08:36:55 +0100196}
197
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100198#ifdef CONFIG_PROC_FS
199static void oxygen_proc_read(struct snd_info_entry *entry,
200 struct snd_info_buffer *buffer)
201{
202 struct oxygen *chip = entry->private_data;
203 int i, j;
204
205 snd_iprintf(buffer, "CMI8788\n\n");
Clemens Ladischc1365002008-05-13 09:19:53 +0200206 for (i = 0; i < OXYGEN_IO_SIZE; i += 0x10) {
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100207 snd_iprintf(buffer, "%02x:", i);
208 for (j = 0; j < 0x10; ++j)
209 snd_iprintf(buffer, " %02x", oxygen_read8(chip, i + j));
210 snd_iprintf(buffer, "\n");
211 }
212 if (mutex_lock_interruptible(&chip->mutex) < 0)
213 return;
Clemens Ladisch31c77642008-01-16 08:28:17 +0100214 if (chip->has_ac97_0) {
215 snd_iprintf(buffer, "\nAC97\n");
216 for (i = 0; i < 0x80; i += 0x10) {
217 snd_iprintf(buffer, "%02x:", i);
218 for (j = 0; j < 0x10; j += 2)
219 snd_iprintf(buffer, " %04x",
220 oxygen_read_ac97(chip, 0, i + j));
221 snd_iprintf(buffer, "\n");
222 }
223 }
224 if (chip->has_ac97_1) {
225 snd_iprintf(buffer, "\nAC97 2\n");
226 for (i = 0; i < 0x80; i += 0x10) {
227 snd_iprintf(buffer, "%02x:", i);
228 for (j = 0; j < 0x10; j += 2)
229 snd_iprintf(buffer, " %04x",
230 oxygen_read_ac97(chip, 1, i + j));
231 snd_iprintf(buffer, "\n");
232 }
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100233 }
234 mutex_unlock(&chip->mutex);
235}
236
Takashi Iwaif007dc02008-02-22 18:35:22 +0100237static void oxygen_proc_init(struct oxygen *chip)
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100238{
239 struct snd_info_entry *entry;
240
241 if (!snd_card_proc_new(chip->card, "cmi8788", &entry))
242 snd_info_set_text_ops(entry, chip, oxygen_proc_read);
243}
244#else
245#define oxygen_proc_init(chip)
246#endif
247
Clemens Ladisch30459d72009-02-19 08:42:44 +0100248static const struct pci_device_id *
249oxygen_search_pci_id(struct oxygen *chip, const struct pci_device_id ids[])
250{
251 u16 subdevice;
252
253 /*
254 * Make sure the EEPROM pins are available, i.e., not used for SPI.
255 * (This function is called before we initialize or use SPI.)
256 */
257 oxygen_clear_bits8(chip, OXYGEN_FUNCTION,
258 OXYGEN_FUNCTION_ENABLE_SPI_4_5);
259 /*
260 * Read the subsystem device ID directly from the EEPROM, because the
261 * chip didn't if the first EEPROM word was overwritten.
262 */
263 subdevice = oxygen_read_eeprom(chip, 2);
Clemens Ladisch92653452009-09-02 18:25:39 +0200264 /* use default ID if EEPROM is missing */
265 if (subdevice == 0xffff)
266 subdevice = 0x8788;
Clemens Ladisch30459d72009-02-19 08:42:44 +0100267 /*
268 * We use only the subsystem device ID for searching because it is
269 * unique even without the subsystem vendor ID, which may have been
270 * overwritten in the EEPROM.
271 */
272 for (; ids->vendor; ++ids)
273 if (ids->subdevice == subdevice &&
274 ids->driver_data != BROKEN_EEPROM_DRIVER_DATA)
275 return ids;
276 return NULL;
277}
278
Clemens Ladisch1275d6f2009-02-19 08:44:12 +0100279static void oxygen_restore_eeprom(struct oxygen *chip,
280 const struct pci_device_id *id)
281{
Clemens Ladisch87b61902009-09-28 11:05:18 +0200282 u16 eeprom_id;
283
284 eeprom_id = oxygen_read_eeprom(chip, 0);
285 if (eeprom_id != OXYGEN_EEPROM_ID &&
286 (eeprom_id != 0xffff || id->subdevice != 0x8788)) {
Clemens Ladisch1275d6f2009-02-19 08:44:12 +0100287 /*
288 * This function gets called only when a known card model has
289 * been detected, i.e., we know there is a valid subsystem
290 * product ID at index 2 in the EEPROM. Therefore, we have
291 * been able to deduce the correct subsystem vendor ID, and
292 * this is enough information to restore the original EEPROM
293 * contents.
294 */
295 oxygen_write_eeprom(chip, 1, id->subvendor);
296 oxygen_write_eeprom(chip, 0, OXYGEN_EEPROM_ID);
297
298 oxygen_set_bits8(chip, OXYGEN_MISC,
299 OXYGEN_MISC_WRITE_PCI_SUBID);
300 pci_write_config_word(chip->pci, PCI_SUBSYSTEM_VENDOR_ID,
301 id->subvendor);
302 pci_write_config_word(chip->pci, PCI_SUBSYSTEM_ID,
303 id->subdevice);
304 oxygen_clear_bits8(chip, OXYGEN_MISC,
305 OXYGEN_MISC_WRITE_PCI_SUBID);
306
307 snd_printk(KERN_INFO "EEPROM ID restored\n");
308 }
309}
310
Clemens Ladisch7cb4ced2010-10-06 10:57:50 +0200311static void configure_pcie_bridge(struct pci_dev *pci)
Clemens Ladisch362bc242009-09-28 11:05:58 +0200312{
Clemens Ladisch7cb4ced2010-10-06 10:57:50 +0200313 enum { PI7C9X110 };
314 static const struct pci_device_id bridge_ids[] = {
315 { PCI_DEVICE(0x12d8, 0xe110), .driver_data = PI7C9X110 },
316 { }
317 };
318 struct pci_dev *bridge;
319 const struct pci_device_id *id;
Clemens Ladisch362bc242009-09-28 11:05:58 +0200320 u32 tmp;
321
Clemens Ladisch7cb4ced2010-10-06 10:57:50 +0200322 if (!pci->bus || !pci->bus->self)
323 return;
324 bridge = pci->bus->self;
325
326 id = pci_match_id(bridge_ids, bridge);
327 if (!id)
328 return;
329
330 switch (id->driver_data) {
331 case PI7C9X110: /* Pericom PI7C9X110 PCIe/PCI bridge */
332 pci_read_config_dword(bridge, 0x40, &tmp);
333 tmp |= 1; /* park the PCI arbiter to the sound chip */
334 pci_write_config_dword(bridge, 0x40, tmp);
335 break;
Clemens Ladisch362bc242009-09-28 11:05:58 +0200336 }
337}
338
Takashi Iwaif007dc02008-02-22 18:35:22 +0100339static void oxygen_init(struct oxygen *chip)
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100340{
341 unsigned int i;
342
343 chip->dac_routing = 1;
344 for (i = 0; i < 8; ++i)
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200345 chip->dac_volume[i] = chip->model.dac_volume_min;
Clemens Ladische9835322008-04-16 09:14:30 +0200346 chip->dac_mute = 1;
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100347 chip->spdif_playback_enable = 1;
348 chip->spdif_bits = OXYGEN_SPDIF_C | OXYGEN_SPDIF_ORIGINAL |
349 (IEC958_AES1_CON_PCM_CODER << OXYGEN_SPDIF_CATEGORY_SHIFT);
350 chip->spdif_pcm_bits = chip->spdif_bits;
351
352 if (oxygen_read8(chip, OXYGEN_REVISION) & OXYGEN_REVISION_2)
353 chip->revision = 2;
354 else
355 chip->revision = 1;
356
357 if (chip->revision == 1)
Clemens Ladischc2353a02008-01-18 09:17:53 +0100358 oxygen_set_bits8(chip, OXYGEN_MISC,
359 OXYGEN_MISC_PCI_MEM_W_1_CLOCK);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100360
Clemens Ladisch31c77642008-01-16 08:28:17 +0100361 i = oxygen_read16(chip, OXYGEN_AC97_CONTROL);
362 chip->has_ac97_0 = (i & OXYGEN_AC97_CODEC_0) != 0;
363 chip->has_ac97_1 = (i & OXYGEN_AC97_CODEC_1) != 0;
364
Clemens Ladischb78e3db2008-01-25 08:39:26 +0100365 oxygen_write8_masked(chip, OXYGEN_FUNCTION,
Clemens Ladisch87eedd22008-03-19 08:20:13 +0100366 OXYGEN_FUNCTION_RESET_CODEC |
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200367 chip->model.function_flags,
Clemens Ladisch87eedd22008-03-19 08:20:13 +0100368 OXYGEN_FUNCTION_RESET_CODEC |
369 OXYGEN_FUNCTION_2WIRE_SPI_MASK |
370 OXYGEN_FUNCTION_ENABLE_SPI_4_5);
Clemens Ladischb78e3db2008-01-25 08:39:26 +0100371 oxygen_write8(chip, OXYGEN_DMA_STATUS, 0);
372 oxygen_write8(chip, OXYGEN_DMA_PAUSE, 0);
373 oxygen_write8(chip, OXYGEN_PLAY_CHANNELS,
374 OXYGEN_PLAY_CHANNELS_2 |
375 OXYGEN_DMA_A_BURST_8 |
376 OXYGEN_DMA_MULTICH_BURST_8);
377 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
Clemens Ladischdb12b8e2008-03-19 08:20:59 +0100378 oxygen_write8_masked(chip, OXYGEN_MISC,
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200379 chip->model.misc_flags,
Clemens Ladischb78e3db2008-01-25 08:39:26 +0100380 OXYGEN_MISC_WRITE_PCI_SUBID |
381 OXYGEN_MISC_REC_C_FROM_SPDIF |
382 OXYGEN_MISC_REC_B_FROM_AC97 |
Clemens Ladischdb12b8e2008-03-19 08:20:59 +0100383 OXYGEN_MISC_REC_A_FROM_MULTICH |
384 OXYGEN_MISC_MIDI);
Clemens Ladischb78e3db2008-01-25 08:39:26 +0100385 oxygen_write8(chip, OXYGEN_REC_FORMAT,
386 (OXYGEN_FORMAT_16 << OXYGEN_REC_FORMAT_A_SHIFT) |
387 (OXYGEN_FORMAT_16 << OXYGEN_REC_FORMAT_B_SHIFT) |
388 (OXYGEN_FORMAT_16 << OXYGEN_REC_FORMAT_C_SHIFT));
389 oxygen_write8(chip, OXYGEN_PLAY_FORMAT,
390 (OXYGEN_FORMAT_16 << OXYGEN_SPDIF_FORMAT_SHIFT) |
391 (OXYGEN_FORMAT_16 << OXYGEN_MULTICH_FORMAT_SHIFT));
392 oxygen_write8(chip, OXYGEN_REC_CHANNELS, OXYGEN_REC_CHANNELS_2_2_2);
Clemens Ladischc9946b22008-01-21 08:44:24 +0100393 oxygen_write16(chip, OXYGEN_I2S_MULTICH_FORMAT,
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200394 OXYGEN_RATE_48000 | chip->model.dac_i2s_format |
Clemens Ladischfa5d8102008-03-19 08:17:33 +0100395 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
Clemens Ladischc9946b22008-01-21 08:44:24 +0100396 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
Clemens Ladischd76596b2008-09-22 09:02:08 +0200397 if (chip->model.device_config & CAPTURE_0_FROM_I2S_1)
Clemens Ladisch43dd89c2008-03-19 08:21:32 +0100398 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200399 OXYGEN_RATE_48000 | chip->model.adc_i2s_format |
Clemens Ladisch43dd89c2008-03-19 08:21:32 +0100400 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
401 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
402 else
403 oxygen_write16(chip, OXYGEN_I2S_A_FORMAT,
404 OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
Clemens Ladischd76596b2008-09-22 09:02:08 +0200405 if (chip->model.device_config & (CAPTURE_0_FROM_I2S_2 |
406 CAPTURE_2_FROM_I2S_2))
Clemens Ladisch43dd89c2008-03-19 08:21:32 +0100407 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200408 OXYGEN_RATE_48000 | chip->model.adc_i2s_format |
Clemens Ladisch43dd89c2008-03-19 08:21:32 +0100409 OXYGEN_I2S_MCLK_256 | OXYGEN_I2S_BITS_16 |
410 OXYGEN_I2S_MASTER | OXYGEN_I2S_BCLK_64);
411 else
412 oxygen_write16(chip, OXYGEN_I2S_B_FORMAT,
413 OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
Clemens Ladischc9946b22008-01-21 08:44:24 +0100414 oxygen_write16(chip, OXYGEN_I2S_C_FORMAT,
Clemens Ladisch43dd89c2008-03-19 08:21:32 +0100415 OXYGEN_I2S_MASTER | OXYGEN_I2S_MUTE_MCLK);
Clemens Ladisch1d98c7d2008-04-09 09:16:33 +0200416 oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
417 OXYGEN_SPDIF_OUT_ENABLE |
418 OXYGEN_SPDIF_LOOPBACK);
Clemens Ladischd76596b2008-09-22 09:02:08 +0200419 if (chip->model.device_config & CAPTURE_1_FROM_SPDIF)
Clemens Ladisch1d98c7d2008-04-09 09:16:33 +0200420 oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL,
421 OXYGEN_SPDIF_SENSE_MASK |
422 OXYGEN_SPDIF_LOCK_MASK |
423 OXYGEN_SPDIF_RATE_MASK |
424 OXYGEN_SPDIF_LOCK_PAR |
425 OXYGEN_SPDIF_IN_CLOCK_96,
426 OXYGEN_SPDIF_SENSE_MASK |
427 OXYGEN_SPDIF_LOCK_MASK |
428 OXYGEN_SPDIF_RATE_MASK |
429 OXYGEN_SPDIF_SENSE_PAR |
430 OXYGEN_SPDIF_LOCK_PAR |
431 OXYGEN_SPDIF_IN_CLOCK_MASK);
432 else
433 oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
434 OXYGEN_SPDIF_SENSE_MASK |
435 OXYGEN_SPDIF_LOCK_MASK |
436 OXYGEN_SPDIF_RATE_MASK);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100437 oxygen_write32(chip, OXYGEN_SPDIF_OUTPUT_BITS, chip->spdif_bits);
Clemens Ladisch4a4bc532008-05-13 09:24:39 +0200438 oxygen_write16(chip, OXYGEN_2WIRE_BUS_STATUS,
439 OXYGEN_2WIRE_LENGTH_8 |
440 OXYGEN_2WIRE_INTERRUPT_MASK |
441 OXYGEN_2WIRE_SPEED_STANDARD);
Clemens Ladischb78e3db2008-01-25 08:39:26 +0100442 oxygen_clear_bits8(chip, OXYGEN_MPU401_CONTROL, OXYGEN_MPU401_LOOPBACK);
443 oxygen_write8(chip, OXYGEN_GPI_INTERRUPT_MASK, 0);
444 oxygen_write16(chip, OXYGEN_GPIO_INTERRUPT_MASK, 0);
Clemens Ladischc9946b22008-01-21 08:44:24 +0100445 oxygen_write16(chip, OXYGEN_PLAY_ROUTING,
Clemens Ladischb78e3db2008-01-25 08:39:26 +0100446 OXYGEN_PLAY_MULTICH_I2S_DAC |
447 OXYGEN_PLAY_SPDIF_SPDIF |
Clemens Ladischc9946b22008-01-21 08:44:24 +0100448 (0 << OXYGEN_PLAY_DAC0_SOURCE_SHIFT) |
449 (1 << OXYGEN_PLAY_DAC1_SOURCE_SHIFT) |
450 (2 << OXYGEN_PLAY_DAC2_SOURCE_SHIFT) |
451 (3 << OXYGEN_PLAY_DAC3_SOURCE_SHIFT));
452 oxygen_write8(chip, OXYGEN_REC_ROUTING,
453 OXYGEN_REC_A_ROUTE_I2S_ADC_1 |
Clemens Ladischb78e3db2008-01-25 08:39:26 +0100454 OXYGEN_REC_B_ROUTE_I2S_ADC_2 |
Clemens Ladischc9946b22008-01-21 08:44:24 +0100455 OXYGEN_REC_C_ROUTE_SPDIF);
456 oxygen_write8(chip, OXYGEN_ADC_MONITOR, 0);
457 oxygen_write8(chip, OXYGEN_A_MONITOR_ROUTING,
458 (0 << OXYGEN_A_MONITOR_ROUTE_0_SHIFT) |
459 (1 << OXYGEN_A_MONITOR_ROUTE_1_SHIFT) |
460 (2 << OXYGEN_A_MONITOR_ROUTE_2_SHIFT) |
461 (3 << OXYGEN_A_MONITOR_ROUTE_3_SHIFT));
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100462
Clemens Ladisch1d98c7d2008-04-09 09:16:33 +0200463 if (chip->has_ac97_0 | chip->has_ac97_1)
464 oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK,
465 OXYGEN_AC97_INT_READ_DONE |
466 OXYGEN_AC97_INT_WRITE_DONE);
467 else
468 oxygen_write8(chip, OXYGEN_AC97_INTERRUPT_MASK, 0);
Clemens Ladischb78e3db2008-01-25 08:39:26 +0100469 oxygen_write32(chip, OXYGEN_AC97_OUT_CONFIG, 0);
470 oxygen_write32(chip, OXYGEN_AC97_IN_CONFIG, 0);
471 if (!(chip->has_ac97_0 | chip->has_ac97_1))
472 oxygen_set_bits16(chip, OXYGEN_AC97_CONTROL,
473 OXYGEN_AC97_CLOCK_DISABLE);
474 if (!chip->has_ac97_0) {
475 oxygen_set_bits16(chip, OXYGEN_AC97_CONTROL,
476 OXYGEN_AC97_NO_CODEC_0);
477 } else {
Clemens Ladisch31c77642008-01-16 08:28:17 +0100478 oxygen_write_ac97(chip, 0, AC97_RESET, 0);
479 msleep(1);
Clemens Ladisch878ac3e2008-01-21 08:50:19 +0100480 oxygen_ac97_set_bits(chip, 0, CM9780_GPIO_SETUP,
481 CM9780_GPIO0IO | CM9780_GPIO1IO);
482 oxygen_ac97_set_bits(chip, 0, CM9780_MIXER,
483 CM9780_BSTSEL | CM9780_STRO_MIC |
484 CM9780_MIX2FR | CM9780_PCBSW);
485 oxygen_ac97_set_bits(chip, 0, CM9780_JACK,
486 CM9780_RSOE | CM9780_CBOE |
487 CM9780_SSOE | CM9780_FROE |
488 CM9780_MIC2MIC | CM9780_LI2LI);
Clemens Ladisch31c77642008-01-16 08:28:17 +0100489 oxygen_write_ac97(chip, 0, AC97_MASTER, 0x0000);
490 oxygen_write_ac97(chip, 0, AC97_PC_BEEP, 0x8000);
491 oxygen_write_ac97(chip, 0, AC97_MIC, 0x8808);
492 oxygen_write_ac97(chip, 0, AC97_LINE, 0x0808);
493 oxygen_write_ac97(chip, 0, AC97_CD, 0x8808);
494 oxygen_write_ac97(chip, 0, AC97_VIDEO, 0x8808);
495 oxygen_write_ac97(chip, 0, AC97_AUX, 0x8808);
496 oxygen_write_ac97(chip, 0, AC97_REC_GAIN, 0x8000);
497 oxygen_write_ac97(chip, 0, AC97_CENTER_LFE_MASTER, 0x8080);
498 oxygen_write_ac97(chip, 0, AC97_SURROUND_MASTER, 0x8080);
Clemens Ladische97f7992008-04-01 10:02:18 +0200499 oxygen_ac97_clear_bits(chip, 0, CM9780_GPIO_STATUS,
500 CM9780_GPO0);
Clemens Ladisch31c77642008-01-16 08:28:17 +0100501 /* power down unused ADCs and DACs */
502 oxygen_ac97_set_bits(chip, 0, AC97_POWERDOWN,
503 AC97_PD_PR0 | AC97_PD_PR1);
504 oxygen_ac97_set_bits(chip, 0, AC97_EXTENDED_STATUS,
505 AC97_EA_PRI | AC97_EA_PRJ | AC97_EA_PRK);
506 }
Clemens Ladischb78e3db2008-01-25 08:39:26 +0100507 if (chip->has_ac97_1) {
508 oxygen_set_bits32(chip, OXYGEN_AC97_OUT_CONFIG,
509 OXYGEN_AC97_CODEC1_SLOT3 |
510 OXYGEN_AC97_CODEC1_SLOT4);
511 oxygen_write_ac97(chip, 1, AC97_RESET, 0);
512 msleep(1);
513 oxygen_write_ac97(chip, 1, AC97_MASTER, 0x0000);
514 oxygen_write_ac97(chip, 1, AC97_HEADPHONE, 0x8000);
515 oxygen_write_ac97(chip, 1, AC97_PC_BEEP, 0x8000);
516 oxygen_write_ac97(chip, 1, AC97_MIC, 0x8808);
517 oxygen_write_ac97(chip, 1, AC97_LINE, 0x8808);
518 oxygen_write_ac97(chip, 1, AC97_CD, 0x8808);
519 oxygen_write_ac97(chip, 1, AC97_VIDEO, 0x8808);
520 oxygen_write_ac97(chip, 1, AC97_AUX, 0x8808);
521 oxygen_write_ac97(chip, 1, AC97_PCM, 0x0808);
522 oxygen_write_ac97(chip, 1, AC97_REC_SEL, 0x0000);
Clemens Ladischa3601562008-01-28 08:35:20 +0100523 oxygen_write_ac97(chip, 1, AC97_REC_GAIN, 0x0000);
Clemens Ladischb78e3db2008-01-25 08:39:26 +0100524 oxygen_ac97_set_bits(chip, 1, 0x6a, 0x0040);
525 }
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100526}
527
Clemens Ladisch4c25b932010-09-07 13:37:10 +0200528static void oxygen_shutdown(struct oxygen *chip)
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100529{
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100530 spin_lock_irq(&chip->reg_lock);
531 chip->interrupt_mask = 0;
532 chip->pcm_running = 0;
533 oxygen_write16(chip, OXYGEN_DMA_STATUS, 0);
534 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
535 spin_unlock_irq(&chip->reg_lock);
Clemens Ladisch4c25b932010-09-07 13:37:10 +0200536}
537
538static void oxygen_card_free(struct snd_card *card)
539{
540 struct oxygen *chip = card->private_data;
541
542 oxygen_shutdown(chip);
Jeff Garzikf000fd82008-04-22 13:50:34 +0200543 if (chip->irq >= 0)
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100544 free_irq(chip->irq, chip);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100545 flush_scheduled_work();
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200546 chip->model.cleanup(chip);
Clemens Ladisch6ed91152009-02-19 08:38:25 +0100547 kfree(chip->model_data);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100548 mutex_destroy(&chip->mutex);
549 pci_release_regions(chip->pci);
550 pci_disable_device(chip->pci);
551}
552
Takashi Iwaif007dc02008-02-22 18:35:22 +0100553int oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
Clemens Ladischbb718582009-02-19 08:37:13 +0100554 struct module *owner,
Clemens Ladisch30459d72009-02-19 08:42:44 +0100555 const struct pci_device_id *ids,
556 int (*get_model)(struct oxygen *chip,
557 const struct pci_device_id *id
558 )
559 )
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100560{
561 struct snd_card *card;
562 struct oxygen *chip;
Clemens Ladisch30459d72009-02-19 08:42:44 +0100563 const struct pci_device_id *pci_id;
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100564 int err;
565
Clemens Ladisch6ed91152009-02-19 08:38:25 +0100566 err = snd_card_create(index, id, owner, sizeof(*chip), &card);
Takashi Iwaie58de7b2008-12-28 16:44:30 +0100567 if (err < 0)
568 return err;
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100569
570 chip = card->private_data;
571 chip->card = card;
572 chip->pci = pci;
573 chip->irq = -1;
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100574 spin_lock_init(&chip->reg_lock);
575 mutex_init(&chip->mutex);
576 INIT_WORK(&chip->spdif_input_bits_work,
577 oxygen_spdif_input_bits_changed);
Clemens Ladisch7c014152008-01-28 08:36:55 +0100578 INIT_WORK(&chip->gpio_work, oxygen_gpio_changed);
Clemens Ladisch1e821dd2008-01-28 08:34:21 +0100579 init_waitqueue_head(&chip->ac97_waitqueue);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100580
581 err = pci_enable_device(pci);
582 if (err < 0)
583 goto err_card;
584
Clemens Ladischa69bb3c2009-02-19 08:38:55 +0100585 err = pci_request_regions(pci, DRIVER);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100586 if (err < 0) {
587 snd_printk(KERN_ERR "cannot reserve PCI resources\n");
588 goto err_pci_enable;
589 }
590
591 if (!(pci_resource_flags(pci, 0) & IORESOURCE_IO) ||
Clemens Ladischc1365002008-05-13 09:19:53 +0200592 pci_resource_len(pci, 0) < OXYGEN_IO_SIZE) {
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100593 snd_printk(KERN_ERR "invalid PCI I/O range\n");
594 err = -ENXIO;
595 goto err_pci_regions;
596 }
597 chip->addr = pci_resource_start(pci, 0);
598
Clemens Ladisch30459d72009-02-19 08:42:44 +0100599 pci_id = oxygen_search_pci_id(chip, ids);
600 if (!pci_id) {
601 err = -ENODEV;
602 goto err_pci_regions;
603 }
Clemens Ladisch1275d6f2009-02-19 08:44:12 +0100604 oxygen_restore_eeprom(chip, pci_id);
Clemens Ladisch30459d72009-02-19 08:42:44 +0100605 err = get_model(chip, pci_id);
606 if (err < 0)
607 goto err_pci_regions;
608
Clemens Ladisch6ed91152009-02-19 08:38:25 +0100609 if (chip->model.model_data_size) {
Clemens Ladisch82af3082009-02-27 09:27:44 +0100610 chip->model_data = kzalloc(chip->model.model_data_size,
Clemens Ladisch6ed91152009-02-19 08:38:25 +0100611 GFP_KERNEL);
612 if (!chip->model_data) {
613 err = -ENOMEM;
614 goto err_pci_regions;
615 }
616 }
617
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100618 pci_set_master(pci);
619 snd_card_set_dev(card, &pci->dev);
620 card->private_free = oxygen_card_free;
621
Clemens Ladisch7cb4ced2010-10-06 10:57:50 +0200622 configure_pcie_bridge(pci);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100623 oxygen_init(chip);
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200624 chip->model.init(chip);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100625
626 err = request_irq(pci->irq, oxygen_interrupt, IRQF_SHARED,
Clemens Ladischa69bb3c2009-02-19 08:38:55 +0100627 DRIVER, chip);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100628 if (err < 0) {
629 snd_printk(KERN_ERR "cannot grab interrupt %d\n", pci->irq);
630 goto err_card;
631 }
632 chip->irq = pci->irq;
633
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200634 strcpy(card->driver, chip->model.chip);
635 strcpy(card->shortname, chip->model.shortname);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100636 sprintf(card->longname, "%s (rev %u) at %#lx, irq %i",
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200637 chip->model.longname, chip->revision, chip->addr, chip->irq);
638 strcpy(card->mixername, chip->model.chip);
639 snd_component_add(card, chip->model.chip);
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100640
641 err = oxygen_pcm_init(chip);
642 if (err < 0)
643 goto err_card;
644
645 err = oxygen_mixer_init(chip);
646 if (err < 0)
647 goto err_card;
648
Clemens Ladischdbbbd672008-09-22 09:03:42 +0200649 if (chip->model.device_config & (MIDI_OUTPUT | MIDI_INPUT)) {
650 unsigned int info_flags = MPU401_INFO_INTEGRATED;
651 if (chip->model.device_config & MIDI_OUTPUT)
652 info_flags |= MPU401_INFO_OUTPUT;
653 if (chip->model.device_config & MIDI_INPUT)
654 info_flags |= MPU401_INFO_INPUT;
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100655 err = snd_mpu401_uart_new(card, 0, MPU401_HW_CMIPCI,
656 chip->addr + OXYGEN_MPU401,
Clemens Ladischdbbbd672008-09-22 09:03:42 +0200657 info_flags, 0, 0,
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100658 &chip->midi);
659 if (err < 0)
660 goto err_card;
661 }
662
663 oxygen_proc_init(chip);
664
665 spin_lock_irq(&chip->reg_lock);
Clemens Ladischd76596b2008-09-22 09:02:08 +0200666 if (chip->model.device_config & CAPTURE_1_FROM_SPDIF)
Clemens Ladisch1d98c7d2008-04-09 09:16:33 +0200667 chip->interrupt_mask |= OXYGEN_INT_SPDIF_IN_DETECT;
668 if (chip->has_ac97_0 | chip->has_ac97_1)
669 chip->interrupt_mask |= OXYGEN_INT_AC97;
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100670 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
671 spin_unlock_irq(&chip->reg_lock);
672
673 err = snd_card_register(card);
674 if (err < 0)
675 goto err_card;
676
677 pci_set_drvdata(pci, card);
678 return 0;
679
680err_pci_regions:
681 pci_release_regions(pci);
682err_pci_enable:
683 pci_disable_device(pci);
684err_card:
685 snd_card_free(card);
686 return err;
687}
688EXPORT_SYMBOL(oxygen_pci_probe);
689
Takashi Iwaif007dc02008-02-22 18:35:22 +0100690void oxygen_pci_remove(struct pci_dev *pci)
Clemens Ladischd0ce9942007-12-23 19:50:57 +0100691{
692 snd_card_free(pci_get_drvdata(pci));
693 pci_set_drvdata(pci, NULL);
694}
695EXPORT_SYMBOL(oxygen_pci_remove);
Clemens Ladisch4a4bc532008-05-13 09:24:39 +0200696
697#ifdef CONFIG_PM
698int oxygen_pci_suspend(struct pci_dev *pci, pm_message_t state)
699{
700 struct snd_card *card = pci_get_drvdata(pci);
701 struct oxygen *chip = card->private_data;
702 unsigned int i, saved_interrupt_mask;
703
704 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
705
706 for (i = 0; i < PCM_COUNT; ++i)
707 if (chip->streams[i])
708 snd_pcm_suspend(chip->streams[i]);
709
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200710 if (chip->model.suspend)
711 chip->model.suspend(chip);
Clemens Ladisch4a4bc532008-05-13 09:24:39 +0200712
713 spin_lock_irq(&chip->reg_lock);
714 saved_interrupt_mask = chip->interrupt_mask;
715 chip->interrupt_mask = 0;
716 oxygen_write16(chip, OXYGEN_DMA_STATUS, 0);
717 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
718 spin_unlock_irq(&chip->reg_lock);
719
720 synchronize_irq(chip->irq);
721 flush_scheduled_work();
722 chip->interrupt_mask = saved_interrupt_mask;
723
724 pci_disable_device(pci);
725 pci_save_state(pci);
726 pci_set_power_state(pci, pci_choose_state(pci, state));
727 return 0;
728}
729EXPORT_SYMBOL(oxygen_pci_suspend);
730
731static const u32 registers_to_restore[OXYGEN_IO_SIZE / 32] = {
732 0xffffffff, 0x00ff077f, 0x00011d08, 0x007f00ff,
733 0x00300000, 0x00000fe4, 0x0ff7001f, 0x00000000
734};
735static const u32 ac97_registers_to_restore[2][0x40 / 32] = {
736 { 0x18284fa2, 0x03060000 },
737 { 0x00007fa6, 0x00200000 }
738};
739
740static inline int is_bit_set(const u32 *bitmap, unsigned int bit)
741{
742 return bitmap[bit / 32] & (1 << (bit & 31));
743}
744
745static void oxygen_restore_ac97(struct oxygen *chip, unsigned int codec)
746{
747 unsigned int i;
748
749 oxygen_write_ac97(chip, codec, AC97_RESET, 0);
750 msleep(1);
751 for (i = 1; i < 0x40; ++i)
752 if (is_bit_set(ac97_registers_to_restore[codec], i))
753 oxygen_write_ac97(chip, codec, i * 2,
754 chip->saved_ac97_registers[codec][i]);
755}
756
757int oxygen_pci_resume(struct pci_dev *pci)
758{
759 struct snd_card *card = pci_get_drvdata(pci);
760 struct oxygen *chip = card->private_data;
761 unsigned int i;
762
763 pci_set_power_state(pci, PCI_D0);
764 pci_restore_state(pci);
765 if (pci_enable_device(pci) < 0) {
766 snd_printk(KERN_ERR "cannot reenable device");
767 snd_card_disconnect(card);
768 return -EIO;
769 }
770 pci_set_master(pci);
771
772 oxygen_write16(chip, OXYGEN_DMA_STATUS, 0);
773 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, 0);
774 for (i = 0; i < OXYGEN_IO_SIZE; ++i)
775 if (is_bit_set(registers_to_restore, i))
776 oxygen_write8(chip, i, chip->saved_registers._8[i]);
777 if (chip->has_ac97_0)
778 oxygen_restore_ac97(chip, 0);
779 if (chip->has_ac97_1)
780 oxygen_restore_ac97(chip, 1);
781
Clemens Ladisch9bd6a732008-09-22 08:55:19 +0200782 if (chip->model.resume)
783 chip->model.resume(chip);
Clemens Ladisch4a4bc532008-05-13 09:24:39 +0200784
785 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
786
787 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
788 return 0;
789}
790EXPORT_SYMBOL(oxygen_pci_resume);
791#endif /* CONFIG_PM */
Clemens Ladisch4c25b932010-09-07 13:37:10 +0200792
793void oxygen_pci_shutdown(struct pci_dev *pci)
794{
795 struct snd_card *card = pci_get_drvdata(pci);
796 struct oxygen *chip = card->private_data;
797
798 oxygen_shutdown(chip);
799 chip->model.cleanup(chip);
800}
801EXPORT_SYMBOL(oxygen_pci_shutdown);