summaryrefslogtreecommitdiffstats
path: root/drivers/sound/via82cxxx_audio.c
blob: cee2e7b0ac9375a315560bff179ddd52825acc30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
/*
 * Support for VIA 82Cxxx Audio Codecs
 * Copyright 1999,2000 Jeff Garzik <jgarzik@mandrakesoft.com>
 *
 * Distributed under the GNU GENERAL PUBLIC LICENSE (GPL) Version 2.
 * See the "COPYING" file distributed with this software for more info.
 *
 * Documentation for this driver available as
 * linux/Documentation/sound/via82cxxx.txt.
 *
 * Since the mixer is called from the OSS glue the kernel lock is always held
 * on our AC97 mixing
 */
 

#define VIA_VERSION	"1.1.2.1"



#include <linux/module.h>
#include <linux/config.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/proc_fs.h>

#include <asm/io.h>

#include "sound_config.h"
#include "soundmodule.h"
#include "sb.h"
#include "ac97.h"

#ifndef SOUND_LOCK
#define SOUND_LOCK do {} while (0)
#define SOUND_LOCK_END do {} while (0)
#endif

#define VIA_DEBUG 0	/* define to 1 to enable debugging output and checks */
#if VIA_DEBUG
/* note: prints function name for you */
#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args)
#else
#define DPRINTK(fmt, args...)
#endif

#define VIA_NDEBUG 0	/* define to 1 to disable lightweight runtime checks */
#if VIA_NDEBUG
#define assert(expr)
#else
#define assert(expr) \
        if(!(expr)) {					\
        printk( "Assertion failed! %s,%s,%s,line=%d\n",	\
        #expr,__FILE__,__FUNCTION__,__LINE__);		\
        }
#endif

#define arraysize(x)            (sizeof(x)/sizeof(*(x)))

#define MAX_CARDS	2

#define	LINE_SIZE	10

#define VIA_CARD_NAME	"VIA 82Cxxx Audio driver " VIA_VERSION
#define VIA_MODULE_NAME "via_audio"
#define PFX		VIA_MODULE_NAME ": "

#define VIA_COUNTER_LIMIT	100000

/* 82C686 function 5 (audio codec) PCI configuration registers */
#define VIA_FUNC_ENABLE		0x42
#define VIA_PNP_CONTROL		0x43
#define VIA_AC97_CTRL		0x80

/* PCI configuration register bits and masks */
#define VIA_CR40_AC97_READY	0x01
#define VIA_CR40_AC97_LOW_POWER	0x02
#define VIA_CR40_SECONDARY_READY 0x04

#define VIA_CR41_ACLINK_ENABLE	0x80

#define VIA_CR42_SB_ENABLE	0x01
#define VIA_CR42_MIDI_ENABLE	0x02
#define VIA_CR42_FM_ENABLE	0x04
#define VIA_CR42_GAME_ENABLE	0x08

#define VIA_CR44_SECOND_CODEC_SUPPORT	(1 << 6)
#define VIA_CR44_AC_LINK_ACCESS		(1 << 7)

#define VIA_CR80_FIRST_CODEC		0
#define VIA_CR80_SECOND_CODEC		(1 << 30)
#define VIA_CR80_FIRST_CODEC_VALID	(1 << 25)
#define VIA_CR80_SECOND_CODEC_VALID	(1 << 27)
#define VIA_CR80_BUSY			(1 << 24)
#define VIA_CR80_READ_MODE		(1 << 23)
#define VIA_CR80_WRITE_MODE		0
#define VIA_CR80_REG_IDX(idx)		(((idx) & 0x7E) << 16)

struct via_info {
	struct address_info sb_data;
	struct address_info opl3_data;
	struct pci_dev *pdev;
	struct ac97_hwint ac97;
	int mixer_oss_dev;
	int have_ac97;
};
static struct via_info		cards [MAX_CARDS];
static unsigned			num_cards = 0;


static const struct {
	int revision;
	const char *rev_name;
} via_chip_revs[] __initdata = {
	{ 0x10, "A" },
	{ 0x11, "B" },
	{ 0x12, "C" },
	{ 0x13, "D" },
	{ 0x14, "E" },
	{ 0x20, "H" },
};

static inline void via_ac97_write32 (struct pci_dev *pdev, int port, u32 data)
{
	struct resource *rsrc = &pdev->resource[0];
	outw ((u16)data,rsrc->start+port);	
	outw ((u16)(data>>16),rsrc->start+port+2);	
}

static inline u32 via_ac97_read32 (struct pci_dev *pdev, int port)
{
	struct resource *rsrc = &pdev->resource[0];
	return
		((u32)inw (rsrc->start+port)) |
		(((u32)inw (rsrc->start+port+2)) << 16);
}

/****************************************************************
 *
 * Intel Audio Codec '97 interface
 *
 *
 */
 
static inline void via_ac97_wait_idle (struct pci_dev *pdev)
{
	u32 tmp;
	int counter = VIA_COUNTER_LIMIT;
	
	DPRINTK ("ENTER\n");

	assert (pdev != NULL);
	
	do {
		tmp = via_ac97_read32 (pdev,VIA_AC97_CTRL);
	} while ((tmp & VIA_CR80_BUSY) && (counter-- > 0));

	DPRINTK ("EXIT%s\n", counter > 0 ? "" : ", counter limit reached");
}


static int via_ac97_read_reg (struct ac97_hwint *dev, u8 reg)
{
	u32 data;
	struct via_info *card;
	struct pci_dev *pdev;
	
	DPRINTK ("ENTER\n");

	assert (dev != NULL);
	assert (dev->driver_private != NULL);

	card = (struct via_info *) dev->driver_private;
	pdev = card->pdev;
	assert (pdev != NULL);

	via_ac97_wait_idle (pdev);
	data =	VIA_CR80_FIRST_CODEC | VIA_CR80_FIRST_CODEC_VALID |
		VIA_CR80_READ_MODE | VIA_CR80_REG_IDX(reg);
	via_ac97_write32 (pdev,VIA_AC97_CTRL,data);
	via_ac97_wait_idle (pdev);
	data = via_ac97_read32 (pdev,VIA_AC97_CTRL);

#if 0
	if (! (data & VIA_CR80_FIRST_CODEC_VALID)) {
		DPRINTK ("EXIT, first codec not valid, returning -1\n");
		return -1;
	}
#endif

	DPRINTK ("EXIT, returning %d\n", data & 0xFFFF);
	return data & 0xFFFF;
}


static int via_ac97_write_reg (struct ac97_hwint *dev, u8 reg, u16 value)
{
	u32 data;
	struct via_info *card;
	struct pci_dev *pdev;
	
	DPRINTK ("ENTER\n");

	assert (dev != NULL);
	assert (dev->driver_private != NULL);

	card = (struct via_info *) dev->driver_private;
	pdev = card->pdev;
	assert (pdev != NULL);

	via_ac97_wait_idle (pdev);
	data =	VIA_CR80_FIRST_CODEC | VIA_CR80_FIRST_CODEC_VALID |
		VIA_CR80_WRITE_MODE | VIA_CR80_REG_IDX(reg) | value;
	via_ac97_write32 (pdev,VIA_AC97_CTRL,data);

#if 0
	if (! (data & VIA_CR80_FIRST_CODEC_VALID)) {
		DPRINTK ("EXIT, first codec invalid, returning -1\n");
		return -1;
	}
#endif

	DPRINTK ("EXIT, returning 0\n");
	return 0;
}


static int via_ac97_reset (struct ac97_hwint *dev)
{
	struct via_info *card;
	struct pci_dev *pdev;
	
	DPRINTK ("ENTER\n");

	assert (dev != NULL);
	assert (dev->driver_private != NULL);

	card = (struct via_info *) dev->driver_private;
	pdev = card->pdev;
	assert (pdev != NULL);
	
	pci_write_config_word (pdev, PCI_COMMAND, PCI_COMMAND_IO);

	DPRINTK ("EXIT, returning 0\n");
	return 0;
}


static struct via_info *via_ac97_find_card_for_mixer (int dev)
{
	int x;

	DPRINTK ("ENTER\n");

	for (x = 0; x < num_cards; x++)
		if (cards[x].mixer_oss_dev == dev) {
			DPRINTK ("EXIT, returning %p\n", cards + x);
			return cards + x;
		}

	DPRINTK ("EXIT, returning 0\n");
	return NULL;
}


static int
via_ac97_default_mixer_ioctl (int dev, unsigned int cmd, caddr_t arg)
{
	int rc;
	struct via_info *card = via_ac97_find_card_for_mixer (dev);

	DPRINTK ("ENTER\n");

	if (card != NULL) {
		rc = ac97_mixer_ioctl (&card->ac97, cmd, arg);
		DPRINTK ("EXIT, returning %d\n", rc);
		return rc;
	}
	
	DPRINTK ("EXIT, returning -ENODEV\n");
	return -ENODEV;

}

static struct mixer_operations via_ac97_mixer_operations =
{
	"VIA82Cxxx",
	"via82cxxxAC97Mixer",
	via_ac97_default_mixer_ioctl
};

static int __init via_attach_ac97 (struct via_info *card)
{
	int mixer;
	struct ac97_hwint *mdev;

	DPRINTK ("ENTER\n");

	assert (card != NULL);

	mdev = &card->ac97;

	memset (mdev, 0, sizeof (*mdev));
	mdev->reset_device = via_ac97_reset;
	mdev->read_reg = via_ac97_read_reg;
	mdev->write_reg = via_ac97_write_reg;
	mdev->driver_private = (void *) card;

	if (ac97_init (mdev)) {
		printk (KERN_ERR PFX "Unable to init AC97\n");
		DPRINTK ("EXIT, returning -1\n");
		return -1;
	}
	mixer = sound_alloc_mixerdev ();
	if (mixer < 0 || num_mixers >= MAX_MIXER_DEV) {
		printk (KERN_ERR PFX "Unable to alloc mixerdev\n");
		DPRINTK ("EXIT, returning -1\n");
		return -1;
	}
	mixer_devs[mixer] = &via_ac97_mixer_operations;
	card->mixer_oss_dev = mixer;

	/* Some reasonable default values.  */
	ac97_set_mixer (mdev, SOUND_MIXER_VOLUME, (85 << 8) | 85);
	ac97_set_mixer (mdev, SOUND_MIXER_SPEAKER, 100);
	ac97_set_mixer (mdev, SOUND_MIXER_PCM, (65 << 8) | 65);
	ac97_set_mixer (mdev, SOUND_MIXER_CD, (65 << 8) | 65);

	printk (KERN_INFO PFX "Initialized AC97 mixer\n");
	
	card->have_ac97 = mixer;
	
	DPRINTK ("EXIT, returning 0\n");
	return 0;
}


static void via_unload_ac97 (struct via_info *card)
{
	DPRINTK ("ENTER\n");

	assert (card != NULL);

	if (card->have_ac97 >= 0)
		sound_unload_mixerdev (card->have_ac97);

	DPRINTK ("EXIT\n");
}


#ifdef CONFIG_PROC_FS

/****************************************************************
 *
 * /proc/driver/via82cxxx/info
 *
 *
 */

static int via_info_read_proc (char *page, char **start, off_t off,
			       int count, int *eof, void *data)
{
#define YN(val,bit) (((val) & (bit)) ? "yes" : "no")

	int len = 0, i;
	u8 r40, r41, r42, r44;
	
	DPRINTK ("ENTER\n");

	len += sprintf (page+len, VIA_CARD_NAME "\n\n");
	
	for (i = 0; i < num_cards; i++) {
		pci_read_config_byte (cards[i].pdev, 0x40, &r40);
		pci_read_config_byte (cards[i].pdev, 0x42, &r41);
		pci_read_config_byte (cards[i].pdev, 0x42, &r42);
		pci_read_config_byte (cards[i].pdev, 0x44, &r44);
	
		len += sprintf (page+len,
			"40  AC97 Codec Ready: %s\n"
			"    AC97 Codec Low-power: %s\n"
			"    Secondary Codec Ready: %s\n"

			"41  AC-Link Interface Enable: %s\n"

			"42  Game port enabled: %s\n"
			"    SoundBlaster enabled: %s\n"
			"    FM enabled: %s\n"
			"    MIDI enabled: %s\n"
			
			"44  AC-Link Interface Access: %s\n"
			"    Secondary Codec Support: %s\n"
			
			"\n",
			
			YN (r40, VIA_CR40_AC97_READY),
			YN (r40, VIA_CR40_AC97_LOW_POWER),
			YN (r40, VIA_CR40_SECONDARY_READY),

			YN (r41, VIA_CR41_ACLINK_ENABLE),

			YN (r42, VIA_CR42_GAME_ENABLE),
			YN (r42, VIA_CR42_SB_ENABLE),
			YN (r42, VIA_CR42_FM_ENABLE),
			YN (r42, VIA_CR42_MIDI_ENABLE),

			YN (r44, VIA_CR44_AC_LINK_ACCESS),
			YN (r44, VIA_CR44_SECOND_CODEC_SUPPORT)
			
			);
	}
	
	DPRINTK("EXIT, returning %d\n", len);
	return len;

#undef YN
}


/****************************************************************
 *
 * /proc/driver/via82cxxx
 *
 *
 */

static int __init via_init_proc (void)
{
	DPRINTK ("ENTER\n");

	proc_mkdir ("driver/via_audio", 0);
	create_proc_read_entry ("driver/via_audio/info", 0, 0, via_info_read_proc, NULL);
	
	DPRINTK("EXIT\n");
	return 0;
}



static void __exit via_cleanup_proc (void)
{
	DPRINTK ("ENTER\n");
	remove_proc_entry ("driver/via_audio/info", NULL);
	remove_proc_entry ("driver/via_audio", NULL);
	DPRINTK("EXIT\n");
}


#else

static inline int via_init_proc (void) { return 0; }
static inline void via_cleanup_proc (void) {}

#endif /* CONFIG_PROC_FS */


/****************************************************************
 *
 * Legacy SoundBlaster Pro, FM support via OSS
 *
 *
 */

static void __init via_attach_sb(struct address_info *hw_config)
{
	DPRINTK ("ENTER\n");

	if(!sb_dsp_init(hw_config))
		hw_config->slots[0] = -1;

	DPRINTK("EXIT\n");
}


static int __init via_probe_sb(struct address_info *hw_config)
{
	DPRINTK ("ENTER\n");

	if (check_region(hw_config->io_base, 16))
	{
		printk(KERN_DEBUG PFX "SBPro port 0x%x is already in use\n",
		       hw_config->io_base);
		return 0;
	}
	DPRINTK("EXIT after sb_dsp_detect\n");
	return sb_dsp_detect(hw_config, 0, 0);
}


static void __exit via_unload_sb(struct address_info *hw_config)
{
	DPRINTK ("ENTER\n");

	if(hw_config->slots[0] != -1)
		sb_dsp_unload(hw_config, 1);

	DPRINTK("EXIT\n");
}


static const struct {
	int sb_irq,
	    sb_dma,
	    midi_base,
	    sb_io_base;
} via_pnp_data[] __initdata = {
	{ 5, 0, 0x300, 0x220 },
	{ 7, 1, 0x310, 0x240 },
	{ 9, 2, 0x320, 0x260 },
	{ 10,3, 0x330, 0x280 },
};


/****************************************************************
 *
 * Chip setup and kernel registration
 *
 *
 */

static int __init via82cxxx_install (struct pci_dev *pcidev)
{
	int sb_io_base;
	int sb_irq;
	int sb_dma;
	int midi_base, rc;
	u8 tmp8;
	struct via_info *card = &cards[num_cards];
	
	DPRINTK ("ENTER\n");

	card->pdev = pcidev;
	card->have_ac97 = -1;
	
	/* turn off legacy features, if not already */
	pci_read_config_byte (pcidev, VIA_FUNC_ENABLE, &tmp8);
	tmp8 &= ~(VIA_CR42_SB_ENABLE | VIA_CR42_MIDI_ENABLE |
		  VIA_CR42_FM_ENABLE);
	pci_write_config_byte (pcidev, VIA_FUNC_ENABLE, tmp8);

	/* 
	 * try to init AC97 mixer device
	 */
	rc = via_attach_ac97 (card);
	if (rc) {
		printk (KERN_WARNING PFX
			"AC97 init failed, SB legacy mode only\n");
	}
	
	/* turn on legacy features */
	pci_read_config_byte (pcidev, VIA_FUNC_ENABLE, &tmp8);
	tmp8 |= VIA_CR42_SB_ENABLE | VIA_CR42_MIDI_ENABLE |
		VIA_CR42_FM_ENABLE;
	pci_write_config_byte (pcidev, VIA_FUNC_ENABLE, tmp8);

	/* read legacy PNP info byte */
	pci_read_config_byte (pcidev, VIA_PNP_CONTROL, &tmp8);
	pci_write_config_byte (pcidev, VIA_PNP_CONTROL, tmp8);
	
	sb_irq = via_pnp_data[((tmp8 >> 6) & 0x03)].sb_irq;
	sb_dma = via_pnp_data[((tmp8 >> 4) & 0x03)].sb_dma;
	midi_base = via_pnp_data[((tmp8 >> 2) & 0x03)].midi_base;
	sb_io_base = via_pnp_data[(tmp8 & 0x03)].sb_io_base;

	udelay(100);
	
	printk(KERN_INFO PFX "legacy "
	       "MIDI: 0x%X, SB: 0x%X / %d IRQ / %d DMA\n",
		midi_base, sb_io_base, sb_irq, sb_dma);
		
	card->sb_data.name = VIA_CARD_NAME;
	card->sb_data.card_subtype = MDL_SBPRO;
	card->sb_data.io_base = sb_io_base;
	card->sb_data.irq = sb_irq;
	card->sb_data.dma = sb_dma;
	
	/* register legacy SoundBlaster Pro */
	if (!via_probe_sb (&card->sb_data)) {
		printk (KERN_ERR PFX
			"SB probe @ 0x%X failed, aborting\n",
			sb_io_base);
		DPRINTK ("EXIT, returning -1\n");
		return -1;
	}
	via_attach_sb (&card->sb_data);

	card->opl3_data.name = card->sb_data.name;
	card->opl3_data.io_base = midi_base;
	card->opl3_data.irq = -1;
	
	/* register legacy MIDI */
	if (!probe_uart401 (&card->opl3_data)) {
		printk (KERN_WARNING PFX
			"MIDI probe @ 0x%X failed, continuing\n",
			midi_base);
		card->opl3_data.io_base = 0;
	} else {
		attach_uart401 (&card->opl3_data);
	}

	num_cards++;	
	DPRINTK ("EXIT, returning 0\n");
	return 0;
}


/*
 * 	This loop walks the PCI configuration database and finds where
 *	the sound cards are.
 *
 *	Note - only a single PCI scan occurs, eliminating possibility
 *	of multiple audio chips
 *
 */
 
static int __init probe_via82cxxx (void)
{
	struct pci_dev *pcidev = NULL;

	DPRINTK ("ENTER\n");

	pcidev = pci_find_device (PCI_VENDOR_ID_VIA,
				  PCI_DEVICE_ID_VIA_82C686_5, NULL);

	if (!pcidev || via82cxxx_install (pcidev) != 0) {
		printk (KERN_ERR PFX "audio init failed\n");
		DPRINTK ("EXIT, returning -1\n");
		return -1;
	}

	DPRINTK ("EXIT, returning 0\n");
	return 0;
}


/*
 *	This function is called when the user or kernel loads the 
 *	module into memory.
 */


static int __init init_via82cxxx_module(void)
{
	u8 tmp;
	int i;
	const char *rev = "unknown!";
	
	memset (cards, 0, sizeof (cards));
	
	DPRINTK ("ENTER\n");

	if (!pci_present ()) {
		printk (KERN_DEBUG PFX "PCI not present, exiting\n");
		DPRINTK ("EXIT, returning -ENODEV\n");
		return -ENODEV;
	}

	if (probe_via82cxxx() != 0) {
		printk(KERN_ERR PFX "probe failed, aborting\n");
		/* XXX unload cards registered so far, if any */
		DPRINTK ("EXIT, returning -ENODEV\n");
		return -ENODEV;
	}

	pci_read_config_byte (cards[0].pdev, PCI_REVISION_ID, &tmp);
	for (i = 0; i < arraysize(via_chip_revs); i++)
		if (via_chip_revs[i].revision == tmp) {
			rev = via_chip_revs[i].rev_name;
			break;
		}
	printk (KERN_INFO PFX VIA_CARD_NAME " loaded\n");
	printk (KERN_INFO PFX "Chip rev %s.  Features: SBPro compat%s%s\n",
		rev,
		cards[0].opl3_data.io_base == 0 ? "" : ", MPU-401 MIDI",
		cards[0].have_ac97 == -1 ? "" : ", AC97 mixer");
	
	if (via_init_proc () != 0) {
		printk (KERN_WARNING PFX
			"Unable to init experimental /proc, ignoring\n");
	}

	/*
	 *	Binds us to the sound subsystem	
	 */
	SOUND_LOCK;
	DPRINTK ("EXIT, returning 0\n");
	return 0;
}

/*
 *	This is called when it is removed. It will only be removed 
 *	when its use count is 0. For sound the SOUND_LOCK/SOUND_UNLOCK
 *	macros hide the entire work for this.
 */
 
static void __exit cleanup_via82cxxx_module(void)
{
	DPRINTK("ENTER\n");
	
	if (cards[0].opl3_data.io_base)
		unload_uart401 (&cards[0].opl3_data);

	via_unload_sb (&cards[0].sb_data);
	
	via_unload_ac97 (&cards[0]);

	via_cleanup_proc ();
	
	/*
	 *	Final clean up with the sound layer
	 */
	SOUND_LOCK_END;

	DPRINTK("EXIT\n");
}

module_init(init_via82cxxx_module);
module_exit(cleanup_via82cxxx_module);