summaryrefslogtreecommitdiffstats
path: root/drivers/sound/adlib_card.c
blob: b21d7316eed71940ec06467cf0bc41dc4c1bae8a (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
/*
 * sound/adlib_card.c
 *
 * Detection routine for the AdLib card.
 *
 * Copyright (C) by Hannu Savolainen 1993-1997
 *
 * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
 * Version 2 (June 1991). See the "COPYING" file distributed with this software
 * for more info.
 */


#include <linux/config.h>
#include <linux/module.h>
#include "sound_config.h"
#include "soundmodule.h"

#ifdef CONFIG_YM3812

void attach_adlib_card(struct address_info *hw_config)
{
	hw_config->slots[0] = opl3_init(hw_config->io_base, hw_config->osp);
	request_region(hw_config->io_base, 4, "OPL3/OPL2");
}

int probe_adlib(struct address_info *hw_config)
{
	if (check_region(hw_config->io_base, 4)) 
	{
		DDB(printk("opl3.c: I/O port %x already in use\n", hw_config->io_base));
		return 0;
	}
	return opl3_detect(hw_config->io_base, hw_config->osp);
}

void unload_adlib(struct address_info *hw_config)
{
	release_region(hw_config->io_base, 4);
	sound_unload_synthdev(hw_config->slots[0]);
}

#ifdef MODULE

int io = -1;
MODULE_PARM(io, "i");

EXPORT_NO_SYMBOLS;

struct address_info cfg;

int init_module(void)
{
	if (io == -1) {
		printk(KERN_ERR "adlib: must specify I/O address.\n");
		return -EINVAL;
	}
	cfg.io_base = io;
	if (probe_adlib(&cfg) == 0)
		return -ENODEV;
	attach_adlib_card(&cfg);
	SOUND_LOCK;
	return 0;
}

void cleanup_module(void)
{
	unload_adlib(&cfg);
	SOUND_LOCK_END;
}

#endif
#endif