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

« back to all changes in this revision

Viewing changes to kernel/OS/SunOS/module.inc

  • 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
 * Purpose: OSS module wrapper for Solaris
 
3
 *
 
4
 * This file will be included from the auto-generated drv_cfg.c files. Under
 
5
 * Solaris this file will be compiled in the development system.
 
6
 */
 
7
/*
 
8
 *
 
9
 * This file is part of Open Sound System.
 
10
 *
 
11
 * Copyright (C) 4Front Technologies 1996-2008.
 
12
 *
 
13
 * This this source file is released under GPL v2 license (no other versions).
 
14
 * See the COPYING file included in the main directory of this source
 
15
 * distribution for the license terms and conditions.
 
16
 *
 
17
 */
 
18
#include <sys/types.h>
 
19
#include <sys/modctl.h>
 
20
#include <sys/kmem.h>
 
21
#include <sys/conf.h>
 
22
#include <sys/ddi.h>
 
23
#include <sys/sunddi.h>
 
24
 
 
25
static int ossdrv_getinfo (dev_info_t *, ddi_info_cmd_t, void *, void **);
 
26
static int ossdrv_attach (dev_info_t *, ddi_attach_cmd_t);
 
27
static int ossdrv_detach (dev_info_t *, ddi_detach_cmd_t);
 
28
 
 
29
#ifdef OSS_POWER_MANAGE
 
30
static int ossdrv_power (dev_info_t *, int component, int level);
 
31
#endif
 
32
 
 
33
/* Entry points structure */
 
34
#if DRIVER_TYPE!=DRV_STREAMS
 
35
 
 
36
static struct cb_ops ossdrv_cb_ops = {
 
37
  oss_open,
 
38
  oss_close,
 
39
  nodev,                        /* not a block driver   */
 
40
  nodev,                        /* no print routine     */
 
41
  nodev,                        /* no dump routine      */
 
42
  oss_read,
 
43
  oss_write,
 
44
  oss_ioctl,
 
45
#ifdef ALLOW_BUFFER_MAPPING
 
46
  oss_devmap,
 
47
#else
 
48
  nodev,                        /* no devmap routine    */
 
49
#endif
 
50
  nodev,
 
51
  nodev,                        /* no segmap routine    */
 
52
  oss_chpoll,                   /* no chpoll routine    */
 
53
  ddi_prop_op,
 
54
  0,                            /* not a STREAMS driver */
 
55
  D_NEW | D_MP | D_64BIT,       /* safe for multi-thread/multi-processor */
 
56
  CB_REV
 
57
};
 
58
#else
 
59
extern struct streamtab DRIVER_STR_INFO;
 
60
 
 
61
struct cb_ops ossdrv_streams_cb_ops = {
 
62
  nulldev,
 
63
  nulldev,
 
64
  nodev,                        /* not a block driver   */
 
65
  nodev,                        /* no print routine     */
 
66
  nodev,                        /* no dump routine      */
 
67
  nodev,
 
68
  nodev,
 
69
  nodev,
 
70
  nodev,                        /* no devmap routine    */
 
71
  nodev,
 
72
  nodev,                        /* no segmap routine    */
 
73
  nochpoll,                     /* no chpoll routine    */
 
74
  ddi_prop_op,
 
75
  &DRIVER_STR_INFO,             /* cb_str */
 
76
  D_NEW | D_MP | D_64BIT,       /* safe for multi-thread/multi-processor */
 
77
  CB_REV,
 
78
  nodev,                        /* cb_aread */
 
79
  nodev,                        /* cb_awrite */
 
80
};
 
81
#endif
 
82
 
 
83
static struct dev_ops ossdrv_dev_ops = {
 
84
  DEVO_REV,                     /* devo_rev */
 
85
  0,                            /* devo_refcnt */
 
86
  ossdrv_getinfo,               /* devo_getinfo */
 
87
  nulldev,                      /* devo_identify - obsolete */
 
88
#if DRIVER_TYPE==DRV_ISA
 
89
  ossdrv_probe,
 
90
#else
 
91
  nulldev,                      /* devo_probe */
 
92
#endif
 
93
  ossdrv_attach,                /* devo_attach */
 
94
  ossdrv_detach,                /* devo_detach */
 
95
  nodev,                        /* devo_reset */
 
96
#if DRIVER_TYPE==DRV_STREAMS
 
97
  &ossdrv_streams_cb_ops,       /* devi_cb_ops */
 
98
#else
 
99
  &ossdrv_cb_ops,               /* devi_cb_ops */
 
100
#endif
 
101
  NULL,                         /* devo_bus_ops */
 
102
#ifdef OSS_POWER_MANAGE
 
103
  ossdrv_power
 
104
#else
 
105
  NULL                          /* devo_power */
 
106
#endif
 
107
};
 
108
 
 
109
static struct modldrv ossdrv_modldrv = {
 
110
  &mod_driverops,               /* drv_modops */
 
111
  "OSS " OSS_VERSION_STRING,
 
112
  &ossdrv_dev_ops,              /* drv_dev_ops */
 
113
};
 
114
 
 
115
static struct modlinkage ossdrv_modlinkage = {
 
116
  MODREV_1,                     /* ml_rev */
 
117
  (void *) &ossdrv_modldrv,     /* ml_linkage */
 
118
  NULL                          /* NULL terminates the list */
 
119
};
 
120
 
 
121
/*
 
122
 * _init, _info, and _fini support loading and unloading the driver.
 
123
 */
 
124
int
 
125
_init (void)
 
126
{
 
127
  int error;
 
128
 
 
129
  error = mod_install (&ossdrv_modlinkage);
 
130
 
 
131
  return error;
 
132
}
 
133
 
 
134
int
 
135
_fini (void)
 
136
{
 
137
  int error;
 
138
 
 
139
  error = mod_remove (&ossdrv_modlinkage);
 
140
  return error;
 
141
}
 
142
 
 
143
int
 
144
_info (struct modinfo *modinfop)
 
145
{
 
146
  int error;
 
147
 
 
148
  error = mod_info (&ossdrv_modlinkage, modinfop);
 
149
 
 
150
  return error;
 
151
}
 
152
 
 
153
/*ARGSUSED*/
 
154
static int
 
155
ossdrv_getinfo (dev_info_t * dontcare_dip, ddi_info_cmd_t cmd, void *arg,
 
156
                void **result)
 
157
{
 
158
  dev_t dev;
 
159
  register int error;
 
160
  int instance;
 
161
  dev_info_t *dip;
 
162
#ifndef SOL9
 
163
  oss_cdev_t *cdev;
 
164
  int minor;
 
165
 
 
166
  dev = (dev_t) arg;
 
167
 
 
168
  minor = getminor (dev);
 
169
 
 
170
  if (minor >= oss_num_cdevs)
 
171
   {
 
172
        *result = NULL;
 
173
        return DDI_FAILURE;
 
174
   }
 
175
 
 
176
  if ((cdev = oss_cdevs[minor]) == NULL || cdev->osdev == NULL)
 
177
   {
 
178
        *result = NULL;
 
179
        return DDI_FAILURE;
 
180
   }
 
181
 
 
182
  dip = cdev->osdev->dip;
 
183
#else
 
184
  dip = dontcare_dip;
 
185
#endif
 
186
 
 
187
  if (dip == NULL)
 
188
    {
 
189
      /* cmn_err (CE_WARN, "ossdrv_getinfo: dip==NULL\n"); */
 
190
      return DDI_FAILURE;
 
191
    }
 
192
 
 
193
  instance = ddi_get_instance (dip);
 
194
 
 
195
  switch (cmd)
 
196
    {
 
197
    case DDI_INFO_DEVT2DEVINFO:
 
198
      *result = dip;
 
199
      error = DDI_SUCCESS;
 
200
      break;
 
201
    case DDI_INFO_DEVT2INSTANCE:
 
202
      *result = (void *) (long)instance;
 
203
      error = DDI_SUCCESS;
 
204
      break;
 
205
    default:
 
206
      *result = NULL;
 
207
      error = DDI_FAILURE;
 
208
    }
 
209
 
 
210
  DDB (cmn_err (CE_CONT,
 
211
                "oss_getinfo: returns %d, result=%lx instance=%d dev=%x\n",
 
212
                error, (unsigned long)*result, instance, (unsigned int)dev));
 
213
  return error;
 
214
}
 
215
 
 
216
static int
 
217
ossdrv_attach (dev_info_t * dip, ddi_attach_cmd_t cmd)
 
218
{
 
219
  int instance;
 
220
  oss_device_t *osdev;
 
221
 
 
222
#ifdef OSS_SUSPEND_RESUME
 
223
  if (cmd != DDI_RESUME) /* Allow resume */
 
224
#endif
 
225
  if (cmd != DDI_ATTACH)
 
226
    {
 
227
      cmn_err (CE_WARN, "bad attach cmd %d\n", cmd);
 
228
      return 0;
 
229
    }
 
230
 
 
231
  if (dip == NULL)
 
232
    {
 
233
      cmn_err (CE_WARN, "ossdrv_attach: dip==NULL\n");
 
234
      return DDI_FAILURE;
 
235
    }
 
236
 
 
237
#ifdef OSS_SUSPEND_RESUME
 
238
  if (cmd == DDI_RESUME)
 
239
     {
 
240
          if ((osdev = (oss_device_t *) ddi_get_driver_private (dip)) == NULL)
 
241
            {
 
242
              cmn_err (CE_WARN, "ddi_get_driver_private() failed\n");
 
243
              return DDI_SUCCESS;
 
244
            }
 
245
        if (!DRIVER_RESUME(osdev))
 
246
           return DDI_FAILURE;
 
247
 
 
248
        return DDI_SUCCESS;
 
249
     }
 
250
#endif
 
251
 
 
252
  instance = ddi_get_instance (dip);
 
253
  DDB (cmn_err
 
254
       (CE_CONT, "Attach started " DRIVER_NICK "%d (%s)\n", instance,
 
255
        ddi_get_name (dip)));
 
256
 
 
257
  if ((osdev =
 
258
       osdev_create (dip, DRIVER_TYPE, instance, DRIVER_NICK, NULL)) == NULL)
 
259
    {
 
260
      return DDI_FAILURE;
 
261
    }
 
262
 
 
263
  oss_load_options (osdev, oss_global_options);
 
264
  oss_load_options (osdev, local_driver_options);
 
265
 
 
266
#if DRIVER_TYPE==DRV_PCI || DRIVER_TYPE == DRV_ISA
 
267
  {
 
268
  int err;
 
269
  if ((err =
 
270
       ddi_get_iblock_cookie (dip, 0, &osdev->iblock_cookie)) != DDI_SUCCESS)
 
271
    {
 
272
      cmn_err (CE_WARN, "Cannot get iblock cookie (%d)\n", err);
 
273
      return DDI_FAILURE;
 
274
    }
 
275
  }
 
276
#else
 
277
/* NOTE! The USB driver (actually udi.c) will call usb_get_data() to obtain */
 
278
/*       the iblock_cookie. There is no need to do that here. */
 
279
  osdev->iblock_cookie = 0;
 
280
#endif
 
281
 
 
282
  if (!DRIVER_ATTACH (osdev))
 
283
    {
 
284
      cmn_err (CE_WARN, "Attach failed\n");
 
285
      osdev_delete (osdev);
 
286
      return DDI_FAILURE;
 
287
    }
 
288
 
 
289
  ddi_set_driver_private (dip, (caddr_t) osdev);
 
290
  ddi_report_dev (dip);
 
291
#if DRIVER_TYPE != DRV_USB
 
292
  oss_audio_delayed_attach ();
 
293
#endif
 
294
 
 
295
  DDB (cmn_err (CE_CONT, "Attach done " DRIVER_NICK "%d\n", instance));
 
296
 
 
297
  return DDI_SUCCESS;
 
298
}
 
299
 
 
300
static int
 
301
ossdrv_detach (dev_info_t * dip, ddi_detach_cmd_t cmd)
 
302
{
 
303
  oss_device_t *osdev;
 
304
 
 
305
#ifdef OSS_SUSPEND_RESUME
 
306
  if (cmd != DDI_SUSPEND) /* Allow suspend */
 
307
#endif
 
308
  if (cmd != DDI_DETACH)
 
309
    {
 
310
      cmn_err (CE_WARN, "bad detach cmd %d\n", cmd);
 
311
      return 0;
 
312
    }
 
313
 
 
314
  if (dip == NULL)
 
315
    {
 
316
      cmn_err (CE_WARN, "ossdrv_detach: dip==NULL\n");
 
317
      return DDI_FAILURE;
 
318
    }
 
319
//cmn_err(CE_CONT, "Detach started " DRIVER_NICK "\n");
 
320
 
 
321
  DDB (cmn_err
 
322
       (CE_CONT, "Detach started " DRIVER_NICK "(%s)\n", ddi_get_name (dip)));
 
323
  if ((osdev = (oss_device_t *) ddi_get_driver_private (dip)) == NULL)
 
324
    {
 
325
      cmn_err (CE_WARN, "ddi_get_driver_private() failed\n");
 
326
      return DDI_SUCCESS;
 
327
    }
 
328
 
 
329
  if (osdev==NULL)
 
330
    {
 
331
      cmn_err (CE_WARN, "Driver osdev==NULL - cannot detach\n");
 
332
      return DDI_FAILURE;
 
333
    }
 
334
 
 
335
#ifdef OSS_SUSPEND_RESUME
 
336
  if (cmd == DDI_SUSPEND)
 
337
  {
 
338
     if (!DRIVER_SUSPEND(osdev))
 
339
        return DDI_FAILURE;
 
340
     return DDI_SUCCESS;
 
341
  }
 
342
#endif
 
343
 
 
344
  if (DRIVER_DETACH (osdev) <= 0)
 
345
    {
 
346
      cmn_err (CE_WARN, "Driver busy - cannot detach\n");
 
347
      return DDI_FAILURE;
 
348
    }
 
349
 
 
350
#if DRIVER_TYPE!=DRV_VMIX
 
351
  osdev_delete (osdev);
 
352
#endif
 
353
 
 
354
  DDB (cmn_err (CE_CONT, "Detach done " DRIVER_NICK "\n"));
 
355
  return DDI_SUCCESS;
 
356
}
 
357
 
 
358
#ifdef OSS_POWER_MANAGE
 
359
static int
 
360
ossdrv_power (dev_info_t *dip, int component, int level)
 
361
{
 
362
  oss_device_t *osdev;
 
363
 
 
364
  if (dip == NULL)
 
365
    {
 
366
      cmn_err (CE_WARN, "ossdrv_detach: dip==NULL\n");
 
367
      return DDI_FAILURE;
 
368
    }
 
369
 
 
370
  DDB (cmn_err
 
371
       (CE_CONT, "ossdrv_power " DRIVER_NICK "(%s, %d, %d)\n", ddi_get_name (dip), component, level));
 
372
  if ((osdev = (oss_device_t *) ddi_get_driver_private (dip)) == NULL)
 
373
    {
 
374
      cmn_err (CE_WARN, "ddi_get_driver_private() failed\n");
 
375
      return DDI_SUCCESS;
 
376
    }
 
377
 
 
378
  if (osdev==NULL)
 
379
    {
 
380
      cmn_err (CE_WARN, "Driver osdev==NULL - cannot detach\n");
 
381
      return DDI_FAILURE;
 
382
    }
 
383
 
 
384
        if (!DRIVER_POWER(osdev, component, level))
 
385
           return DDI_FAILURE;
 
386
 
 
387
        return DDI_SUCCESS;
 
388
}
 
389
#endif