2
* Purpose: Template for OSS modules under Linux
4
* This file is included by the low level driver modules when they are
5
* compiled in the target system. In this way this file can be modified
6
* for non-standard kernels by the customer. Compiling in the target is
7
* necessary because the driver/module framework of Linux cannot support
8
* binary drivers. Another reason is that the kbuild mechanism used to build
9
* kernel modules under Linux is not compatible with the way how the source
10
* code of OSS is organized.
13
* Copyright (C) 4Front Technologies 2005-2007. Released under GPL2 license.
15
#define strcpy dummy_strcpy
16
#include <linux/version.h>
17
#include <linux/init.h>
18
#include <linux/module.h>
19
#include <linux/errno.h>
20
#include <linux/kernel.h>
21
#include <linux/pci.h>
22
#include "timestamp.h"
23
#include "oss_exports.h"
28
#define strcpy oss_strcpy
30
#define strlen oss_strlen
32
static int module_major = 0;
33
static int instance = 0;
35
MODULE_LICENSE ("GPL v2");
36
MODULE_DESCRIPTION ("Open Sound System '" DRIVER_PURPOSE "' driver module");
37
MODULE_AUTHOR ("4Front Technologies (support@opensound.com)");
39
extern int DRIVER_ATTACH (oss_device_t * osdev);
40
extern int DRIVER_DETACH (oss_device_t * osdev);
42
#if DRIVER_TYPE==DRV_PCI
43
#define DRIVER_TYPE_OK
45
#include "pci_wrapper.inc"
47
// MODULE_DEVICE_TABLE(pci, id_table);
48
static struct pci_driver osspci_driver = {
51
.probe = osspci_probe,
52
.remove = osspci_remove
60
if ((err = pci_register_driver (&osspci_driver)) < 0)
62
oss_register_module (THIS_MODULE);
71
oss_unregister_chrdev (module_major, DRIVER_NICK);
73
pci_unregister_driver (&osspci_driver);
74
oss_unregister_module (THIS_MODULE);
77
module_init (pcidrv_init);
78
module_exit (pcidrv_exit);
79
#endif /* PCI driver */
81
#if DRIVER_TYPE==DRV_VIRTUAL || DRIVER_TYPE==DRV_VMIX
82
#define DRIVER_TYPE_OK
83
static oss_device_t *osdev = NULL;
86
virtualdrv_init (void)
88
static int instance = 0, maj;
91
osdev_create (NULL, DRIVER_TYPE, instance++, DRIVER_NICK,
96
osdev_set_owner (osdev, THIS_MODULE);
97
maj = oss_request_major (osdev, 0, DRIVER_NICK);
98
osdev_set_major (osdev, maj);
99
if (!DRIVER_ATTACH (osdev))
101
oss_register_module (THIS_MODULE);
102
oss_audio_delayed_attach ();
107
virtualdrv_exit (void)
110
if (!DRIVER_DETACH (osdev))
111
printk (KERN_ALERT DRIVER_NICK ": Unloading busy device\n");
112
osdev_delete (osdev);
113
oss_unregister_module (THIS_MODULE);
116
module_init (virtualdrv_init);
117
module_exit (virtualdrv_exit);
118
#endif /* Virtual driver */
120
#if DRIVER_TYPE==DRV_USB
121
#define DRIVER_TYPE_OK
122
oss_device_t *osdev = NULL;
123
static int usb_major = 0;
125
#include "usb_wrapper.inc"
132
if (udi_usb_installed)
135
osdev_create (NULL, DRV_VIRTUAL, instance++, DRIVER_NICK,
140
osdev_set_owner (osdev, THIS_MODULE);
141
usb_major = oss_request_major (osdev, 0, DRIVER_NICK);
144
oss_cmn_err (CE_WARN, "Failed to allocate USB major (%d)\n", usb_major);
147
osdev_set_major (osdev, usb_major);
148
oss_register_device (osdev, "USB audio core services");
149
if (!DRIVER_ATTACH (osdev))
151
oss_register_module (THIS_MODULE);
152
oss_audio_delayed_attach ();
154
udi_usb_installed = 1;
156
if ((res = usb_register (&oss_usb)) < 0)
158
printk ("oss: usb_register failed, err=%d\n", res);
168
if (!udi_usb_installed)
170
if (!DRIVER_DETACH (osdev))
171
printk (KERN_ALERT DRIVER_NICK ": Unloading busy device\n");
172
usb_deregister (&oss_usb);
173
udi_usb_installed = 0;
174
known_devices = NULL;
175
osdev_delete (osdev);
177
oss_unregister_module (THIS_MODULE);
180
module_init (usbdrv_init);
181
module_exit (usbdrv_exit);
182
#endif /* USB driver */
184
#ifndef DRIVER_TYPE_OK
185
#error Unrecognized driver type
189
strcpy (char *s1, const char *s2)
200
oss_cmn_err (int level, const char *s, ...)
202
char tmp[1024], *a[6];
208
for (i = 0; i < strlen (s); i++)
212
for (i = 0; i < n && i < 6; i++)
214
a[i] = va_arg (ap, char *);
217
for (i = n; i < 6; i++)
220
if (level == CE_CONT)
222
sprintf (tmp, s, a[0], a[1], a[2], a[3], a[4], a[5], NULL,
228
strcpy (tmp, DRIVER_NICK ": ");
230
sprintf (tmp + strlen (tmp), s, a[0], a[1], a[2], a[3], a[4], a[5],
231
NULL, NULL, NULL, NULL);
232
if (level == CE_PANIC)
234
printk (KERN_ALERT "%s", tmp);
237
/* This may cause a crash under SMP */
245
#include "osscore_symbols.inc"