~ubuntu-branches/ubuntu/vivid/oss4/vivid-proposed

« back to all changes in this revision

Viewing changes to setup/Linux/oss/cuckoo/cuckoo.c

  • Committer: Bazaar Package Importer
  • Author(s): Romain Beauxis, Samuel Thibault, Romain Beauxis, Sebastien NOEL
  • Date: 2011-06-14 10:06:56 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110614100656-cx4oc7u426zn812z
Tags: 4.2-build2004-1
[ Samuel Thibault ]
* debian/control: Add liboss4-salsa2, liboss4-salsa-dev and
  liboss4-salsa-asound2 packages, equivalent to (and will replace) those from
  the oss-libsalsa package (Closes: #589127).
* debian/patches/liboss4-salsa.patch: New patch to rename libsalsa into
  liboss4-salsa to avoid conflicts in the archive for no good reason.
* debian/rules: Make in libOSSlib and libsalsa.
* debian/liboss4-salsa-dev.install, debian/liboss4-salsa2.install,
  debian/liboss4-salsa-asound2.links, debian/liboss4-salsa-dev.links:
  Install liboss4-salsa libraries like was done in the oss-libsalsa package.
* include-alsa: Add a copy of ALSA 1.0.5 headers: Cf ALSA_1.0.* symbols in
  libsalsa, this is the roughly supported version.
* debian/copyright: Update for new include-alsa files.
* alsa.pc: New file for compatibility with libasound-dev.
* debian/control:
  - Add Vcs-Browser and Vcs-Svn fields.
  - Use linux-any instead of the list of Linux archs (Closes: #604679).
  - Make dkms dependency linux-any only.
* debian/patches/hurd_iot.patch: New patch to fix soundcard.h usage in
  libsalsa on hurd-i386.
* debian/patches/libsalsa_fixes.patch: New patch to fix some printf usages
  and ioctl declaration in libsalsa.
* debian/patches/no_EBADE.patch: New patch to cope with hurd-i386 not having
  EBADE.
* debian/patches/CFLAGS.patch: New patch to make oss4 take debian/rules
  CFLAGS into account.
* debian/patches/snd_asoundlib_version.patch: New patch to add
  snd_asoundlib_version().
* debian/patches/generic_srccconf.patch: New patch to fix source
  configuration on unknown archs.

[ Romain Beauxis ]
* Fixed README.Debian to only mention dkms' modules.
* Switch to dpkg-source 3.0 (quilt) format
* Added DM-Upload-Allowed: yes

[ Sebastien NOEL ]
* New upstream release (Closes: #595298, #619272).
* Fix typo in initscript (Closes: #627149).
* debian/control: adjust linux-headers dependencies (Closes: #628879).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
4
 *
 
5
 * Copyright (C) 2004-2009 Hannu Savolainen (hannu@opensound.com).
 
6
 *
 
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.
 
11
 *
 
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.
 
16
 */
 
17
 
 
18
/*
 
19
 * !!!!!!!!!!!!!!!!!!!! Important  !!!!!!!!!!!!!!!!!!
 
20
 *
 
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
 
23
 * Open Sound System.
 
24
 *
 
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.
 
27
 */
 
28
 
 
29
#ifndef KBUILD_MODNAME
 
30
#define KBUILD_MODNAME cuckoo
 
31
#endif
 
32
 
 
33
#include "cuckoo.h"
 
34
 
 
35
#include "./checksum.h"
 
36
 
 
37
#ifdef VERMAGIC_STRING
 
38
static const char vermagic[] = VERMAGIC_STRING;
 
39
#endif
 
40
 
 
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");
 
45
 
 
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;
 
50
 
 
51
static int
 
52
snd_cuckoo_free (cuckoo_t * chip)
 
53
{
 
54
  // TODO
 
55
  return 0;
 
56
}
 
57
 
 
58
static int
 
59
snd_cuckoo_dev_free (snd_device_t * device)
 
60
{
 
61
  cuckoo_t *cuckoo = (cuckoo_t *) device->device_data;
 
62
  return snd_cuckoo_free (cuckoo);
 
63
}
 
64
 
 
65
static int
 
66
snd_cuckoo_create (snd_card_t * card, int osscard, cuckoo_t ** rchip)
 
67
{
 
68
  cuckoo_t *chip;
 
69
  int err;
 
70
 
 
71
  static snd_device_ops_t ops = {
 
72
    .dev_free = snd_cuckoo_dev_free
 
73
  };
 
74
 
 
75
  *rchip = NULL;
 
76
 
 
77
  if ((chip = (cuckoo_t *) kmalloc (sizeof (cuckoo_t), GFP_KERNEL)) == NULL)
 
78
    return -ENOMEM;
 
79
 
 
80
  chip->card = card;
 
81
  chip->osscard = osscard;
 
82
  chip->ncapture = chip->nplay = chip->npcm = 0;
 
83
 
 
84
  if ((err = snd_device_new (card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
 
85
    {
 
86
      snd_cuckoo_free (chip);
 
87
      return err;
 
88
    }
 
89
 
 
90
  *rchip = chip;
 
91
  return 0;
 
92
}
 
93
 
 
94
static snd_card_t *cards[SNDRV_CARDS];
 
95
static int ncards = 0;
 
96
 
 
97
int
 
98
init_module (void)
 
99
{
 
100
  int err;
 
101
  int dev, cardno;
 
102
  char tmp[100];
 
103
  int pass;
 
104
 
 
105
#if 0
 
106
  // TODO
 
107
  if ((err = udi_connect (WRAPPER_VERSION)) < 0)
 
108
    return err;
 
109
 
 
110
  if (strcmp (oss_checksum, cuckoo_checksum) != 0)
 
111
    {
 
112
      printk
 
113
        ("cuckoo: Error OSS incompatibility problem. Please recompile.\n");
 
114
      return -EIO;
 
115
    }
 
116
#endif
 
117
 
 
118
  for (pass = 0; pass < 2; pass++)
 
119
    {
 
120
      cardno = -1;
 
121
 
 
122
      for (dev = 0; dev < num_audio_engines; dev++)
 
123
        {
 
124
          adev_p adev = audio_engines[dev];
 
125
          cuckoo_t *chip;
 
126
          snd_card_t *card = NULL;
 
127
 
 
128
          if (pass == 0)
 
129
            {
 
130
              // Ignore non-virtual devices
 
131
              if (!(adev->flags & ADEV_VIRTUAL))
 
132
                continue;
 
133
            }
 
134
          else
 
135
            {
 
136
              // Ignore virtual devices
 
137
              if ((adev->flags & ADEV_VIRTUAL))
 
138
                continue;
 
139
            }
 
140
 
 
141
          if (adev->card_number < 0)
 
142
            {
 
143
              printk ("cuckoo: Ignored audio device %d - %s\n", dev,
 
144
                      adev->name);
 
145
              continue;
 
146
            }
 
147
 
 
148
          if (adev->card_number != cardno)
 
149
            {
 
150
              oss_card_info cd;
 
151
 
 
152
              cardno = adev->card_number;
 
153
 
 
154
              if (oss_get_cardinfo (cardno, &cd) < 0)
 
155
                {
 
156
                  printk ("oss_get_cardinfo(%d) failed\n", cardno);
 
157
                  continue;
 
158
                }
 
159
 
 
160
              // printk("Card %d: %s/%s\n", cardno, cd.shortname, cd.longname);
 
161
              printk ("Card %d: %s/%s\n", cardno, cd.shortname, cd.longname);
 
162
 
 
163
              if (ncards >= CUCKOO_MAXCARD)
 
164
                {
 
165
                  printk
 
166
                    ("Cuckoo: Too many audio devices (%d), only %d supported. by ALSA.\n",
 
167
                     num_audio_engines, CUCKOO_MAXCARD);
 
168
                  return -EIO;
 
169
                }
 
170
 
 
171
              if (!enable[ncards])
 
172
                {
 
173
                  printk ("cuckoo: Device was not enabled (yet)\n");
 
174
                  return -EIO;
 
175
                }
 
176
 
 
177
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
 
178
              if ((card =
 
179
                   snd_card_new (index[ncards], id[ncards], THIS_MODULE,
 
180
                                 0)) == NULL)
 
181
#else
 
182
              if (
 
183
                   snd_card_create (index[ncards], id[ncards], THIS_MODULE,
 
184
                                 0, &card) != 0)
 
185
#endif
 
186
                {
 
187
                  printk ("cuckoo: Can't create a card instance\n");
 
188
                  return -EIO;
 
189
                }
 
190
 
 
191
              if ((err = snd_cuckoo_create (card, cardno, &chip)) < 0)
 
192
                {
 
193
                  printk ("cuckoo: Couldn't create a chip instance (%d)\n",
 
194
                          err);
 
195
                  snd_card_free (card);
 
196
                  return err;
 
197
                }
 
198
 
 
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);
 
204
 
 
205
              if ((err = install_pcm_instances (chip, cardno)) < 0)
 
206
                return err;
 
207
 
 
208
              if ((err = install_mixer_instances (chip, cardno)) < 0)
 
209
                return err;
 
210
 
 
211
              //              if ((err=install_midiport_instances(chip, cardno))<0)
 
212
              //                 return err;
 
213
 
 
214
              if ((err = snd_card_register (card)) < 0)
 
215
                {
 
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
 
219
 
 
220
                  snd_card_free (card);
 
221
                  return err;
 
222
                }
 
223
 
 
224
              cards[ncards++] = card;
 
225
            }
 
226
        }
 
227
    }
 
228
 
 
229
  return 0;
 
230
}
 
231
 
 
232
void
 
233
cleanup_module (void)
 
234
{
 
235
  int i;
 
236
 
 
237
  for (i = 0; i < ncards; i++)
 
238
    snd_card_free (cards[i]);
 
239
}
 
240
 
 
241
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,5))
 
242
#undef unix
 
243
struct module __this_module
 
244
  __attribute__ ((section (".gnu.linkonce.this_module"))) =
 
245
{
 
246
  .name = __stringify (KBUILD_MODNAME),.init = init_module,
 
247
#ifdef CONFIG_MODULE_UNLOAD
 
248
    .exit = cleanup_module
 
249
#endif
 
250
};
 
251
#endif