2
* This software module makes it possible to use Open Sound System for Linux
3
* (the _professional_ version) as a low level driver source for ALSA.
5
* Copyright (C) 2004-2009 Hannu Savolainen (hannu@opensound.com).
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
19
* !!!!!!!!!!!!!!!!!!!! Important !!!!!!!!!!!!!!!!!!
21
* If this file doesn't compile, you must not try to resolve the problem
22
* without perfect understanding of internals of Linux kernel, ALSA and
25
* Instead you need to check that you are using the version of this file
26
* that matches the versions of ALSA, OSS and Linux you are currently using.
29
#ifndef KBUILD_MODNAME
30
#define KBUILD_MODNAME cuckoo
35
#include "./checksum.h"
37
#ifdef VERMAGIC_STRING
38
static const char vermagic[] = VERMAGIC_STRING;
41
MODULE_AUTHOR ("Hannu Savolainen <hannu@opensound.com>");
42
MODULE_LICENSE ("GPL v2");
43
//MODULE_CLASSES("{sound}");
44
MODULE_DESCRIPTION ("OSS low level driver interface for ALSA");
46
#define CUCKOO_MAXCARD SNDRV_CARDS
47
static int index[CUCKOO_MAXCARD] = SNDRV_DEFAULT_IDX;
48
static char *id[CUCKOO_MAXCARD] = SNDRV_DEFAULT_STR;
49
static int enable[CUCKOO_MAXCARD] = SNDRV_DEFAULT_ENABLE_PNP;
52
snd_cuckoo_free (cuckoo_t * chip)
59
snd_cuckoo_dev_free (snd_device_t * device)
61
cuckoo_t *cuckoo = (cuckoo_t *) device->device_data;
62
return snd_cuckoo_free (cuckoo);
66
snd_cuckoo_create (snd_card_t * card, int osscard, cuckoo_t ** rchip)
71
static snd_device_ops_t ops = {
72
.dev_free = snd_cuckoo_dev_free
77
if ((chip = (cuckoo_t *) kmalloc (sizeof (cuckoo_t), GFP_KERNEL)) == NULL)
81
chip->osscard = osscard;
82
chip->ncapture = chip->nplay = chip->npcm = 0;
84
if ((err = snd_device_new (card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
86
snd_cuckoo_free (chip);
94
static snd_card_t *cards[SNDRV_CARDS];
95
static int ncards = 0;
107
if ((err = udi_connect (WRAPPER_VERSION)) < 0)
110
if (strcmp (oss_checksum, cuckoo_checksum) != 0)
113
("cuckoo: Error OSS incompatibility problem. Please recompile.\n");
118
for (pass = 0; pass < 2; pass++)
122
for (dev = 0; dev < num_audio_engines; dev++)
124
adev_p adev = audio_engines[dev];
126
snd_card_t *card = NULL;
130
// Ignore non-virtual devices
131
if (!(adev->flags & ADEV_VIRTUAL))
136
// Ignore virtual devices
137
if ((adev->flags & ADEV_VIRTUAL))
141
if (adev->card_number < 0)
143
printk ("cuckoo: Ignored audio device %d - %s\n", dev,
148
if (adev->card_number != cardno)
152
cardno = adev->card_number;
154
if (oss_get_cardinfo (cardno, &cd) < 0)
156
printk ("oss_get_cardinfo(%d) failed\n", cardno);
160
// printk("Card %d: %s/%s\n", cardno, cd.shortname, cd.longname);
161
printk ("Card %d: %s/%s\n", cardno, cd.shortname, cd.longname);
163
if (ncards >= CUCKOO_MAXCARD)
166
("Cuckoo: Too many audio devices (%d), only %d supported. by ALSA.\n",
167
num_audio_engines, CUCKOO_MAXCARD);
173
printk ("cuckoo: Device was not enabled (yet)\n");
177
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
179
snd_card_new (index[ncards], id[ncards], THIS_MODULE,
183
snd_card_create (index[ncards], id[ncards], THIS_MODULE,
187
printk ("cuckoo: Can't create a card instance\n");
191
if ((err = snd_cuckoo_create (card, cardno, &chip)) < 0)
193
printk ("cuckoo: Couldn't create a chip instance (%d)\n",
195
snd_card_free (card);
199
#define oss_version_string "v4.x" // TODO
200
sprintf (tmp, "OSS %s", oss_version_string);
201
strlcpy (card->driver, tmp);
202
strlcpy (card->shortname, cd.shortname);
203
strlcpy (card->longname, cd.longname);
205
if ((err = install_pcm_instances (chip, cardno)) < 0)
208
if ((err = install_mixer_instances (chip, cardno)) < 0)
211
// if ((err=install_midiport_instances(chip, cardno))<0)
214
if ((err = snd_card_register (card)) < 0)
216
printk ("cuckoo: Couldn't register card(%s) err=%d\n",
217
card->shortname, err);
218
continue; // TODO: Should handle this in more intelligent way
220
snd_card_free (card);
224
cards[ncards++] = card;
233
cleanup_module (void)
237
for (i = 0; i < ncards; i++)
238
snd_card_free (cards[i]);
241
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,5))
243
struct module __this_module
244
__attribute__ ((section (".gnu.linkonce.this_module"))) =
246
.name = __stringify (KBUILD_MODNAME),.init = init_module,
247
#ifdef CONFIG_MODULE_UNLOAD
248
.exit = cleanup_module