
|
[openbeos]
||
[Date Prev]
[06-2007 Date Index]
[Date Next]
||
[Thread Prev]
[06-2007 Thread Index]
[Thread Next]
[openbeos] Announcing OpenSound System port to BeOS/Haiku
- From: "François Revol" <revol@xxxxxxx>
- To: oss-devel@xxxxxxxxxxxxxxxxxxxxx
- Date: Wed, 27 Jun 2007 18:06:34 +0200 CEST
Hi there,
I have the pleasure to announce I have ported OSSv4.1test to BeOS.
It's not finished yet, but it runs and plays some sound.
The goal is to use its drivers to get wider audio support for Haiku,
the FreeSoftware rewrite (under BSD/MIT) of BeOS.
BeOS, and Haiku, have a high level C++ API for media, so we won't port
OSS apps (but some have been ported to use our Media Kit), but rather
use OSS from the Media Kit, either by writing an OSSMediaNode plugin to
support the existing ioctls, or port the drivers to implement the so
called "multi audio" ioctls used by the Media Kit to talk to some
existing lower level drivers. (some older drivers use a different ioctl
set already, publishing under /dev/audio/old/).
Current limitations:
- built as a single binary due to limitation in cross-module symbol
referencing (our kernel enforces a clean API to each module by forcing
others to use a defined list of pointers to functions, which is nice to
maintain compatibility but doesn't help there). Next phase should fix
it.
- Locking isn't correct yet, it seems other OSes don't need much
locking, how don't they even crash ? :p It seems devices become busy
after several uses, so ref counting is broken.
- it currently pollutes our clean hierarchical devfs, which we had way
before linux... should later publish stuff under /dev/audio/oss/.
- no usb support (yet), but usb support in BeOS is rough anyway and
Haiku's is underway. all PCI devices should work though. Tested with
both an ATI IXP and Ich Sis.
- it doesn't load under Haiku yet, due to a missing __ucmpdi2 symbol in
the kernel. Seems to be some runtime stuff to be fixed soon.
- mixer control doesn't seem to be working (ossmix vol 2 does set to 2
when read back but doesn't change actual output).
Attached is the patch against 20070624.
It's probably not ready for official inclusion yet.
People wanting to build it should follow the official way after
patching:
mkdir build
cd build
/path/to/configure
make build
This puts binaries in prototype/...
When installing to test, the oss_core binary must be both copied as:
/boot/home/config/add-ons/kernel/drivers/bin/oss_core
and:
/boot/home/config/add-ons/kernel/media/oss
because the driver loads itself as a module.
Attached is the output of some commands to serve as "screenshot" :)
A test binary is available:
wget http://revolf.free.fr/beos/oss-beos-v4.1test-bin.zip
unzip oss-beos-v4.1test-bin.zip -d /boot
rescan oss_core
osstest
Make sure you quit media_server and media_addon_server first, they
might be using the card.
Cheers,
François.
diff -urN oss-v4.1test0-070624-src-gpl.org/devlists/BeOS
oss-v4.1test0-070624-src-gpl/devlists/BeOS
--- oss-v4.1test0-070624-src-gpl.org/devlists/BeOS Thu Jan 1 01:00:00 1970
+++ oss-v4.1test0-070624-src-gpl/devlists/BeOS Tue Jun 26 22:19:33 2007
@@ -0,0 +1,119 @@
+ali5455 pci10b9,5455 ALI M5455
+allegro pci125d,1988 ESS Allegro ES1988
+allegro pci125d,1990 ESS Canyon 3D ES1990
+allegro pci125d,1992 ESS Canyon 3D-2 ES1992
+allegro pci125d,1998 ESS Maestro3 ES1998
+allegro pci125d,199a ESS Maestro3 ES199A
+als300 pci4005,300 Avance Logic ALS300
+als300 pci4005,308 Avance Logic ALS300+
+als4000 pci4005,4000 Avance Logic ALS4000
+apci97 pci1102,8938 Creative Ectiva EV1938
+apci97 pci1274,1371 Creative AudioPCI97 (ES1371/ES1373)
+apci97 pci1274,5880 Creative Sound Blaster PCI128 (5880B)
+apci97 pci1274,8001 Creative Sound Blaster PCI128 (CT5880)
+apci97 pci1274,8002 Creative Sound Blaster PCI128 (5880A)
+atiaudio pci1002,4341 ATI IXP200
+atiaudio pci1002,4361 ATI IXP300
+atiaudio pci1002,4370 ATI IXP400
+audigyls pci1102,7 Sound Blaster Audigy LS / Live7.1
+audioloop AUDIOLOOP OSS loopback audio driver (BETA)
+audiopci pci1274,5000 Creative AudioPCI (ES1370)
+cmi8788 pci13f6,8788 CMedia CMI8788
+cmpci pci13f6,100 CMedia CM8338A
+cmpci pci13f6,100 MIDIMan DiO 2448
+cmpci pci13f6,101 CMedia CM8338B
+cmpci pci13f6,111 CMedia CM8738/CM8768
+cmpci pci14af,20 Guillemot Maxi Sound MUSE
+cs4280 pci1013,6001 Crystal CS4610
+cs4280 pci1013,6003 Crystal CS4280
+cs4280 pci1013,6004 Crystal CS4615
+cs4280 pcs153b,112e Terratec DMX Xfire 1024
+cs4280 pcs1681,50 Hercules Game Theater XP
+cs4280 pcs1681,51 Hercules Game Theater XP+
+cs4280 pcs5053,3357 TurtleBeach SantaCruz / VideoLogic SonicFury
+cs4281 pci1013,6005 Crystal CS4281
+digi32 pciea60,9896 RME Digi32
+digi32 pciea60,9897 RME Digi32 Pro
+digi32 pciea60,9898 RME Digi32/8
+digi96 pci10ee,3fc0 RME Digi96
+digi96 pci10ee,3fc1 RME Digi96/8
+digi96 pci10ee,3fc2 RME Digi96/8 PRO
+digi96 pci10ee,3fc3 RME Digi96/8 PAD
+emu10k1x pci1102,6 Creative Sound Blaster 5.1 (Dell)
+fm801 pci1319,801 ForteMedia FM 801
+fm801 pcs1489,7008 Genius Sound Maker Live
+geode pci100b,503 National Semiconductor Geode SC1200
+geode pci1078,103 National Semiconductor Geode CS5530
+hdaudio pci8086,2668 Intel High Definition Audio (ICH6)
+hdaudio pci8086,27d8 Intel High Definition Audio (ICH7)
+hdaudio pci8086,269a Intel High Definition Audio (ESB2)
+hdaudio pci8086,284b Intel High Definition Audio (ICH8)
+hdaudio pci8086,293f Intel High Definition Audio (ICH9)
+hdaudio pci10de,26c Nvidia High Definition Audio (MCP51)
+hdaudio pci10de,371 Nvidia High Definition Audio (MCP55)
+hdaudio pci10de,3e4 Nvidia High Definition Audio (MCP61)
+hdaudio pci10de,3f0 Nvidia High Definition Audio (MCP61)
+hdaudio pci10de,44a Nvidia High Definition Audio (MCP65)
+hdaudio pci10de,55c Nvidia High Definition Audio (MCP67)
+hdaudio pci1002,437b ATI High Definition Audio (SB450)
+hdaudio pci1002,4383 ATI High Definition Audio (SB600)
+hdaudio pci1106,3288 VIA High Definition Audio
+hdaudio pci1039,7502 SiS High Definition Audio
+hdaudio pci10b9,5461 ULI High Definition Audio
+ich pci1022,7445 AMD 786
+ich pci1022,746d AMD 8111
+ich pci1039,7012 SiS 7012
+ich pci10de,1b1 Nvidia nForce
+ich pci10de,6a Nvidia nForce2
+ich pci10de,8a Nvidia CK8
+ich pci10de,da Nvidia nForce3
+ich pci10de,ea Nvidia CK8S
+ich pci10de,59 Nvidia nForce4
+ich pci10de,26b Nvidia MCP51
+ich pci8086,2415 Intel AC97 (ICH)
+ich pci8086,2425 Intel AC97 (ICH1)
+ich pci8086,2445 Intel AC97 (ICH2)
+ich pci8086,2485 Intel AC97 (ICH3)
+ich pci8086,24c5 Intel AC97 (ICH4)
+ich pci8086,24d5 Intel AC97 (ICH5)
+ich pci8086,25a6 Intel AC97 (ESB)
+ich pci8086,266e Intel AC97 (ICH6)
+ich pci8086,27de Intel AC97 (ICH7)
+ich pci8086,7195 Intel 440MX (440MX)
+imux IMUX OSS Input Multiplexer
+maestro pci125d,1968 ESS Maestro-2
+maestro pci125d,1978 ESS Maestro-2E
+maestro pci1285,100 ESS Maestro-1
+neomagic pci10c8,8005 Neomagic NM2200AV
+s3vibes pci5333,ca00 S3 Sonic Vibes
+sblive pcs1102,21 Creative Sound Blaster Live
+sblive pci1102,2 Creative Sound Blaster Live family
+sblive pcs1102,8040 Creative Sound Blaster Live 1024/Platinum
+sblive pcs1102,8061 Creative Sound Blaster Live 5.1/Platinum IR
+sblive pci1102,4 Creative Sound Blaster Audigy/Audigy2
+sblive pcs1102,51 Creative Sound Blaster Audigy Platinum
+sblive pci1102,8 Creative Sound Blaster Audigy2 Value/Audigy4
+sblive pci1102,2001 Creative Sound Blaster Audigy2 ZS Notebook
+softoss SOFTOSS OSS Virtual mixer/synth driver
+solo pci125d,1969 ESS Solo-1
+trident pci1023,2000 Trident 4DWave-DX
+trident pci1023,2001 Trident 4DWave-NX
+trident pci1023,2002 Trident 4DWave-CX
+trident pci1039,7018 SiS 7018
+trident pci10b9,5451 ALI M5451
+via8233 pci1106,3059 VIA VT8233/8235/8237
+via8233 pci1106,4551 VIA VT5432B
+via8233 pci1106,7059 VIA VT8233A
+via8233 pcs1462,3800 MSI K7T266
+via8233 pcs1462,4720 MSI KT3 Ultra
+via97 pci1106,3058 VIA VT82C686
+vortex pci12eb,1 Aureal Vortex (AU8820)
+vortex pci12eb,2 Aureal Vortex2 (AU8830)
+vortex AU8810 Aureal Vortex Advantage (AU8810) *** NOT SUPPORTED ***
+ymf7xx pci1073,10 Yamaha DS-XG YMF744
+ymf7xx pci1073,12 Yamaha DS-XG YMF754
+ymf7xx pci1073,4 Yamaha DS-XG YMF724
+ymf7xx pci1073,5 Yamaha DS-XG YMF734
+ymf7xx pci1073,a Yamaha DS-XG YMF740
+ymf7xx pci1073,c Yamaha DS-XG YMF740C
+ymf7xx pci1073,d Yamaha DS-XG YMF724F
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/.config
oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/.config
--- oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/.config Thu Jan 1
01:00:00 1970
+++ oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/.config Tue Jun 26 22:19:33 2007
@@ -0,0 +1 @@
+mode=kernel
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/core.inc
oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/core.inc
--- oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/core.inc Thu Jan 1
01:00:00 1970
+++ oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/core.inc Tue Jun 26
22:19:33 2007
@@ -0,0 +1,315 @@
+/* -*- c -*-
+ * Purpose: OSS module wrapper for BeOS/Haiku
+ *
+ * This file will be included from the auto-generated drv_cfg.c files. Under
+ * UnixWare and OpenServer this will will be compiled during the initial build
+ * of OSS (in the development system).
+ */
+/*
+ *
+ * This file is part of Open Sound System.
+ *
+ * Copyright (C) 4Front Technologies 1996-2007.
+ *
+ * This this source file is released under GPL v2 license (no other versions).
+ * See the COPYING file included in the main directory of this source
+ * distribution. Please contact sales@xxxxxxxxxxxxx for further info.
+ *
+ */
+
+#include <PCI.h>
+
+pci_module_info *gPCI = NULL;
+
+//#if DRIVER_TYPE==DRV_PCI ?
+
+status_t
+init_hardware(void)
+{
+ status_t err;
+ err = get_module(B_PCI_MODULE_NAME, &gPCI);
+ if (err < B_OK)
+ return err;
+
+ put_module(B_PCI_MODULE_NAME);
+ return B_OK;
+}
+
+status_t
+init_driver(void)
+{
+ status_t err;
+ err = get_module(B_PCI_MODULE_NAME, &gPCI);
+ if (err < B_OK)
+ return err;
+
+
+ return B_OK;
+}
+
+void
+uninit_driver(void)
+{
+ status_t err;
+
+ put_module(B_PCI_MODULE_NAME);
+}
+
+#ifdef SCO
+static int ossdrv_config (cfg_func_t func, void *idata, rm_key_t key);
+#if DRIVER_TYPE==DRV_VIRTUAL
+oss_device_t *osdev = NULL;
+#endif
+/*
+ * Driver information structures, for drv_attach().
+ */
+static const drvops_t oss_ops = {
+ ossdrv_config,
+ oss_open,
+ oss_close,
+ oss_devinfo,
+ oss_biostart,
+ oss_ioctl,
+ NULL, /* drvctl */
+ NULL /* mmap */
+};
+
+static const drvinfo_t oss_drvinfo = {
+ &oss_ops,
+ DRIVER_NICK,
+ D_MP, /* MP-safe */
+ NULL, /* Not a STREAMS driver */
+ 256 /* Must match $maxchan in Node file */
+};
+
+static int
+rd_hex (char *s)
+{
+/*
+ * Convert a 4 digit hexadecimal string to integer value
+ */
+ int v = 0;
+ int i;
+
+ for (i = 0; i < 4; i++)
+ {
+ char c = *s++;
+
+ if (c >= '0' && c <= '9')
+ {
+ v = (v << 4) | (c - '0');
+ continue;
+ }
+
+ if (c >= 'A' && c <= 'F')
+ {
+ v = (v << 4) | (c - 'A' + 10);
+ continue;
+ }
+
+ if (c >= 'a' && c <= 'f')
+ {
+ v = (v << 4) | (c - 'a' + 10);
+ continue;
+ }
+ }
+
+ return v;
+}
+
+static int
+cfg_add (void *idata, rm_key_t key)
+{
+ int err;
+ cm_args_t cma;
+ cm_num_t btype;
+ char id[32];
+ int vendor, product;
+ static int instance = 0;
+ oss_device_t *osdev;
+
+ cm_begin_trans (key, RM_READ);
+ cma.cm_key = key;
+ cma.cm_param = CM_BRDBUSTYPE;
+ cma.cm_val = &btype;
+ cma.cm_vallen = sizeof (btype);
+ cma.cm_n = 0;
+ err = cm_getval (&cma);
+ cm_end_trans (key);
+
+ if (err != 0 || btype != CM_BUS_PCI)
+ {
+ cmn_err (CE_WARN, "Bad BUS type %d\n", btype);
+ return ENODEV;
+ }
+
+ if ((osdev =
+ osdev_create (&key, DRIVER_TYPE, instance, DRIVER_NICK, NULL)) == NULL)
+ {
+ return EIO;
+ }
+
+ cm_begin_trans (key, RM_READ);
+ cma.cm_key = key;
+ cma.cm_param = CM_BRDID;
+ cma.cm_val = id;
+ cma.cm_vallen = sizeof (id);
+ cma.cm_n = 0;
+ err = cm_getval (&cma);
+ cm_end_trans (key);
+
+ vendor = rd_hex (id + 2);
+ product = rd_hex (id + 6);
+
+ osdev->vendor = vendor;
+ osdev->product = product;
+ osdev->drvinfo = (drvinfo_t *) & oss_drvinfo;
+ osdev->key = key;
+
+ if (!DRIVER_ATTACH (osdev))
+ {
+ cmn_err (CE_WARN, "Attach failed\n");
+ osdev_delete (osdev);
+ return EIO;
+ }
+
+ *(void **) idata = osdev;
+ oss_audio_delayed_attach ();
+
+ instance++;
+
+ return 0;
+}
+
+static int
+cfg_remove (void *idata)
+{
+ oss_device_t *osdev = idata;
+
+ if (idata == NULL)
+ {
+ cmn_err (CE_WARN, DRIVER_NICK ": ossdrv_detach: dip==NULL\n");
+ return EIO;
+ }
+
+ if (osdev == NULL)
+ {
+ cmn_err (CE_WARN, DRIVER_NICK ": Bad idatata\n");
+ return 0;
+ }
+
+ if (DRIVER_DETACH (osdev) <= 0)
+ {
+ DDB (cmn_err (CE_WARN, "Driver busy - cannot detach\n"));
+ return EBUSY;
+ }
+
+ osdev_delete (osdev);
+
+ DDB (cmn_err (CE_CONT, "Detach done " DRIVER_NICK, "\n"));
+ return 0;
+}
+
+#if DRIVER_TYPE==DRV_VIRTUAL
+static int
+attach_virtual (void)
+{
+ DDB (cmn_err (CE_CONT, "Attach started " DRIVER_NICK "\n"));
+ if ((osdev =
+ osdev_create (NULL, DRIVER_TYPE, 0, DRIVER_NICK, NULL)) == NULL)
+ {
+ return EIO;
+ }
+
+ osdev->drvinfo = &oss_drvinfo;
+
+ if (!DRIVER_ATTACH (osdev))
+ {
+ cmn_err (CE_WARN, "Attach failed\n");
+ osdev_delete (osdev);
+ return EIO;
+ }
+
+ return 0;
+}
+
+static int
+detach_virtual (void)
+{
+ if (osdev == NULL)
+ {
+ return 0;
+ }
+
+ if (DRIVER_DETACH (osdev) <= 0)
+ {
+ DDB (cmn_err (CE_WARN, "Driver busy - cannot detach\n"));
+ return EBUSY;
+ }
+
+ osdev_delete (osdev);
+
+ return 0;
+}
+#endif
+
+static int
+ossdrv_config (cfg_func_t func, void *idata, rm_key_t key)
+{
+ switch (func)
+ {
+ case CFG_ADD:
+ return cfg_add (idata, key);
+ break;
+
+ case CFG_REMOVE:
+ return cfg_remove (idata);
+ break;
+
+ case CFG_VERIFY:
+ return 0;
+ break;
+
+ }
+
+ return EOPNOTSUPP;
+}
+
+/*
+ * Driver entry point routines
+ */
+
+int
+_load ()
+{
+ int err;
+
+ if ((err = drv_attach (&oss_drvinfo)) != 0)
+ {
+ cmn_err (CE_WARN, "drv_attach failed %d\n", err);
+ return err;
+ }
+
+#if DRIVER_TYPE==DRV_VIRTUAL
+ attach_virtual ();
+#endif
+
+ return 0;
+}
+
+int
+_unload ()
+{
+ extern volatile int oss_open_devices;
+
+ if (oss_open_devices > 0)
+ return EBUSY;
+
+#if DRIVER_TYPE==DRV_VIRTUAL
+ detach_virtual ();
+#endif
+
+ drv_detach (&oss_drvinfo);
+ return 0;
+}
+#endif
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/driver_beos.c
oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/driver_beos.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/driver_beos.c Thu Jan
1 01:00:00 1970
+++ oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/driver_beos.c Tue Jun 26
22:19:33 2007
@@ -0,0 +1,103 @@
+/*
+ * Purpose: devfs interface for BeOS/Haiku
+ */
+/*
+ *
+ * This file is part of Open Sound System.
+ *
+ * Copyright (C) 4Front Technologies 1996-2007.
+ *
+ * This this source file is released under GPL v2 license (no other versions).
+ * See the COPYING file included in the main directory of this source
+ * distribution. Please contact sales@xxxxxxxxxxxxx for further info.
+ *
+ */
+
+#include "oss_config.h"
+#include "midi_core.h"
+#include <oss_pci.h>
+#include <KernelExport.h>
+#include <Drivers.h>
+
+#define DRIVER_NAME "ossdrv"
+
+int32 api_version = B_CUR_DRIVER_API_VERSION;
+
+oss_core_module_info *gOSSCore = NULL;
+
+// #pragma mark -
+
+// XXX: malloc it + update it from device list
+
+const char **
+publish_devices(void)
+{
+ return gOSSCore->oss_publish_devices();
+}
+
+
+device_hooks *
+find_device(const char *name)
+{
+ FENTRYA("%s", name);
+
+ FEXIT();
+ return gOSSCore->oss_get_driver_hooks();
+}
+
+// #pragma mark -
+
+status_t
+init_hardware(void)
+{
+ status_t err;
+ FENTRY();
+
+ err = get_module(OSS_CORE_MODULE_NAME, (module_info **)&gOSSCore);
+ if (err < B_OK) {
+ FEXIT();
+ return err;
+ }
+
+ put_module(OSS_CORE_MODULE_NAME);
+ FEXIT();
+ return B_OK;
+}
+
+status_t
+init_driver(void)
+{
+ status_t err = ENOMEM;
+ FENTRY();
+
+ err = get_module(OSS_CORE_MODULE_NAME, (module_info **)&gOSSCore);
+ if (err < B_OK)
+ goto err1;
+ err = gOSSCore->init_osscore();
+ dprintf("oss:init_osscore: 0x%08lx\n", err);
+ if (err < B_OK)
+ goto err2;
+ err = gOSSCore->oss_load_drivers();
+ err = B_OK;
+ FEXITR(err);
+ return err;
+
+err2:
+ put_module(OSS_CORE_MODULE_NAME);
+err1:
+ FEXITR(err);
+ return err;
+}
+
+void
+uninit_driver(void)
+{
+ status_t err;
+ FENTRY();
+
+ err = gOSSCore->oss_unload_all_drivers();
+ err = gOSSCore->uninit_osscore();
+ dprintf("oss:uninit_osscore: 0x%08lx\n", err);
+ put_module(OSS_CORE_MODULE_NAME);
+ FEXIT();
+}
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/module.inc
oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/module.inc
--- oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/module.inc Thu Jan 1
01:00:00 1970
+++ oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/module.inc Tue Jun 26
23:02:21 2007
@@ -0,0 +1,445 @@
+/* -*- c -*-
+ * Purpose: OSS module wrapper for BeOS/Haiku
+ *
+ * This file will be included from the auto-generated drv_cfg.c files. Under
+ * UnixWare and OpenServer this will will be compiled during the initial build
+ * of OSS (in the development system).
+ */
+/*
+ *
+ * This file is part of Open Sound System.
+ *
+ * Copyright (C) 4Front Technologies 1996-2007.
+ *
+ * This this source file is released under GPL v2 license (no other versions).
+ * See the COPYING file included in the main directory of this source
+ * distribution. Please contact sales@xxxxxxxxxxxxx for further info.
+ *
+ */
+
+#include <PCI.h>
+
+//pci_module_info *gPCI = NULL;
+extern pci_module_info *gPCI;
+
+#if DRIVER_TYPE==DRV_VIRTUAL
+static oss_device_t *osdev = NULL;
+#endif
+
+#if DRIVER_TYPE==DRV_PCI
+int DRIVER_PROBE()
+{
+ oss_device_t *osdev;
+ pci_info pcii;
+ uint32 pci_index = 0;
+ uint32 count = 0;
+ int err = ENOENT;
+ static int instance = 0;
+ FENTRY();
+
+ /* while there are more pci devices */
+ while ((*gPCI->get_nth_pci_info)(pci_index, &pcii) == B_NO_ERROR)
+ {
+ int vendor = 0;
+
+ /* if we match a supported vendor */
+ while (id_table[vendor].vendor)
+ {
+ if (id_table[vendor].vendor == pcii.vendor_id &&
+ id_table[vendor].product == pcii.device_id)
+ {
+ dev_info_t *di;
+ dprintf("oss: matching pci %04x,%04x\n", pcii.vendor_id,
pcii.device_id);
+ di = PMALLOC(NULL, sizeof(dev_info_t));
+ if (!di)
+ break;
+ memcpy(di, &pcii, sizeof(pcii));
+ if ((osdev =
+ osdev_create (di, DRIVER_TYPE, instance, DRIVER_NICK,
NULL)) == NULL)
+ {
+ break;
+ }
+
+ if (!DRIVER_ATTACH (osdev))
+ {
+ cmn_err (CE_WARN, "Attach failed\n");
+ osdev_delete (osdev);
+ break;
+ }
+
+ instance++;
+ count++;
+ break;
+ }
+ vendor++;
+ }
+ /* next pci_info struct, please */
+ pci_index++;
+ }
+
+ oss_audio_delayed_attach ();
+
+ if (count)
+ err = 0;
+err:
+ FEXITR(err);
+ return err;
+}
+#endif
+
+#if DRIVER_TYPE==DRV_VIRTUAL
+int DRIVER_PROBE()
+{
+ int err = EIO;
+ FENTRY();
+ if ((osdev =
+ osdev_create (NULL, DRIVER_TYPE, 0, DRIVER_NICK, NULL)) == NULL)
+ {
+ goto err;
+ }
+
+ if (!DRIVER_ATTACH (osdev))
+ {
+ cmn_err (CE_WARN, "Attach failed\n");
+ osdev_delete (osdev);
+ goto err;
+ }
+
+ err = 0;
+err:
+ FEXITR(err);
+ return err;
+}
+#endif
+
+
+
+
+
+
+static status_t
+stdops(int32 op, ...)
+{
+ status_t err;
+ switch (op)
+ {
+ case B_MODULE_INIT:
+ err = get_module(B_PCI_MODULE_NAME, (module_info **)&gPCI);
+ return err;
+
+ case B_MODULE_UNINIT:
+ //err = unload_driver(DRIVER_NICK);
+ //if (err < B_OK)
+ // return err;
+ put_module(B_PCI_MODULE_NAME);
+ return B_OK;
+
+ }
+ return B_ERROR;
+}
+
+oss_drv_module_info DRIVER_MODULE_OBJECT = {
+ {
+ OSS_MAKE_DRV_MOD_NAME(DRIVER_NICK),
+ 0,
+ stdops,
+ },
+ DRIVER_PROBE,
+ DRIVER_ATTACH,
+ DRIVER_DETACH
+};
+
+
+//#if DRIVER_TYPE==DRV_PCI ?
+#if 0
+status_t
+init_hardware(void)
+{
+ status_t err;
+ err = get_module(B_PCI_MODULE_NAME, &gPCI);
+ if (err < B_OK)
+ return err;
+
+ put_module(B_PCI_MODULE_NAME);
+ return B_OK;
+}
+
+status_t
+init_driver(void)
+{
+ status_t err;
+ err = get_module(B_PCI_MODULE_NAME, &gPCI);
+ if (err < B_OK)
+ return err;
+
+
+ return B_OK;
+}
+
+void
+uninit_driver(void)
+{
+ status_t err;
+
+ put_module(B_PCI_MODULE_NAME);
+}
+#endif
+
+#ifdef SCO
+static int ossdrv_config (cfg_func_t func, void *idata, rm_key_t key);
+#if DRIVER_TYPE==DRV_VIRTUAL
+oss_device_t *osdev = NULL;
+#endif
+/*
+ * Driver information structures, for drv_attach().
+ */
+static const drvops_t oss_ops = {
+ ossdrv_config,
+ oss_open,
+ oss_close,
+ oss_devinfo,
+ oss_biostart,
+ oss_ioctl,
+ NULL, /* drvctl */
+ NULL /* mmap */
+};
+
+static const drvinfo_t oss_drvinfo = {
+ &oss_ops,
+ DRIVER_NICK,
+ D_MP, /* MP-safe */
+ NULL, /* Not a STREAMS driver */
+ 256 /* Must match $maxchan in Node file */
+};
+
+static int
+rd_hex (char *s)
+{
+/*
+ * Convert a 4 digit hexadecimal string to integer value
+ */
+ int v = 0;
+ int i;
+
+ for (i = 0; i < 4; i++)
+ {
+ char c = *s++;
+
+ if (c >= '0' && c <= '9')
+ {
+ v = (v << 4) | (c - '0');
+ continue;
+ }
+
+ if (c >= 'A' && c <= 'F')
+ {
+ v = (v << 4) | (c - 'A' + 10);
+ continue;
+ }
+
+ if (c >= 'a' && c <= 'f')
+ {
+ v = (v << 4) | (c - 'a' + 10);
+ continue;
+ }
+ }
+
+ return v;
+}
+
+static int
+cfg_add (void *idata, rm_key_t key)
+{
+ int err;
+ cm_args_t cma;
+ cm_num_t btype;
+ char id[32];
+ int vendor, product;
+ static int instance = 0;
+ oss_device_t *osdev;
+
+ cm_begin_trans (key, RM_READ);
+ cma.cm_key = key;
+ cma.cm_param = CM_BRDBUSTYPE;
+ cma.cm_val = &btype;
+ cma.cm_vallen = sizeof (btype);
+ cma.cm_n = 0;
+ err = cm_getval (&cma);
+ cm_end_trans (key);
+
+ if (err != 0 || btype != CM_BUS_PCI)
+ {
+ cmn_err (CE_WARN, "Bad BUS type %d\n", btype);
+ return ENODEV;
+ }
+
+ if ((osdev =
+ osdev_create (&key, DRIVER_TYPE, instance, DRIVER_NICK, NULL)) == NULL)
+ {
+ return EIO;
+ }
+
+ cm_begin_trans (key, RM_READ);
+ cma.cm_key = key;
+ cma.cm_param = CM_BRDID;
+ cma.cm_val = id;
+ cma.cm_vallen = sizeof (id);
+ cma.cm_n = 0;
+ err = cm_getval (&cma);
+ cm_end_trans (key);
+
+ vendor = rd_hex (id + 2);
+ product = rd_hex (id + 6);
+
+ osdev->vendor = vendor;
+ osdev->product = product;
+ osdev->drvinfo = (drvinfo_t *) & oss_drvinfo;
+ osdev->key = key;
+
+ if (!DRIVER_ATTACH (osdev))
+ {
+ cmn_err (CE_WARN, "Attach failed\n");
+ osdev_delete (osdev);
+ return EIO;
+ }
+
+ *(void **) idata = osdev;
+ oss_audio_delayed_attach ();
+
+ instance++;
+
+ return 0;
+}
+
+static int
+cfg_remove (void *idata)
+{
+ oss_device_t *osdev = idata;
+
+ if (idata == NULL)
+ {
+ cmn_err (CE_WARN, DRIVER_NICK ": ossdrv_detach: dip==NULL\n");
+ return EIO;
+ }
+
+ if (osdev == NULL)
+ {
+ cmn_err (CE_WARN, DRIVER_NICK ": Bad idatata\n");
+ return 0;
+ }
+
+ if (DRIVER_DETACH (osdev) <= 0)
+ {
+ DDB (cmn_err (CE_WARN, "Driver busy - cannot detach\n"));
+ return EBUSY;
+ }
+
+ osdev_delete (osdev);
+
+ DDB (cmn_err (CE_CONT, "Detach done " DRIVER_NICK, "\n"));
+ return 0;
+}
+
+#if DRIVER_TYPE==DRV_VIRTUAL
+static int
+attach_virtual (void)
+{
+ DDB (cmn_err (CE_CONT, "Attach started " DRIVER_NICK "\n"));
+ if ((osdev =
+ osdev_create (NULL, DRIVER_TYPE, 0, DRIVER_NICK, NULL)) == NULL)
+ {
+ return EIO;
+ }
+
+ osdev->drvinfo = &oss_drvinfo;
+
+ if (!DRIVER_ATTACH (osdev))
+ {
+ cmn_err (CE_WARN, "Attach failed\n");
+ osdev_delete (osdev);
+ return EIO;
+ }
+
+ return 0;
+}
+
+static int
+detach_virtual (void)
+{
+ if (osdev == NULL)
+ {
+ return 0;
+ }
+
+ if (DRIVER_DETACH (osdev) <= 0)
+ {
+ DDB (cmn_err (CE_WARN, "Driver busy - cannot detach\n"));
+ return EBUSY;
+ }
+
+ osdev_delete (osdev);
+
+ return 0;
+}
+#endif
+
+static int
+ossdrv_config (cfg_func_t func, void *idata, rm_key_t key)
+{
+ switch (func)
+ {
+ case CFG_ADD:
+ return cfg_add (idata, key);
+ break;
+
+ case CFG_REMOVE:
+ return cfg_remove (idata);
+ break;
+
+ case CFG_VERIFY:
+ return 0;
+ break;
+
+ }
+
+ return EOPNOTSUPP;
+}
+
+/*
+ * Driver entry point routines
+ */
+
+int
+_load ()
+{
+ int err;
+
+ if ((err = drv_attach (&oss_drvinfo)) != 0)
+ {
+ cmn_err (CE_WARN, "drv_attach failed %d\n", err);
+ return err;
+ }
+
+#if DRIVER_TYPE==DRV_VIRTUAL
+ attach_virtual ();
+#endif
+
+ return 0;
+}
+
+int
+_unload ()
+{
+ extern volatile int oss_open_devices;
+
+ if (oss_open_devices > 0)
+ return EBUSY;
+
+#if DRIVER_TYPE==DRV_VIRTUAL
+ detach_virtual ();
+#endif
+
+ drv_detach (&oss_drvinfo);
+ return 0;
+}
+#endif
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/os_beos.c
oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/os_beos.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/os_beos.c Thu Jan 1
01:00:00 1970
+++ oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/os_beos.c Wed Jun 27
03:10:02 2007
@@ -0,0 +1,1836 @@
+/*
+ * Purpose: Operating system abstraction functions for BeOS/Haiku
+ */
+/*
+ *
+ * This file is part of Open Sound System.
+ *
+ * Copyright (C) 4Front Technologies 1996-2007.
+ *
+ * This this source file is released under GPL v2 license (no other versions).
+ * See the COPYING file included in the main directory of this source
+ * distribution. Please contact sales@xxxxxxxxxxxxx for further info.
+ *
+ */
+
+#include "oss_config.h"
+#include "midi_core.h"
+#include <oss_pci.h>
+#include <Drivers.h>
+#include <KernelExport.h>
+
+volatile int oss_open_devices = 0;
+#define MAX_CARDS 16
+int oss_num_cards = 0;
+static oss_device_t *cards[MAX_CARDS];
+static int oss_expired = 0;
+
+static oss_mutex_t osscore_mutex;
+
+//static struct fileinfo files[OSS_MAX_CDEVS];
+static volatile int open_count[OSS_MAX_CDEVS] = { 0 };
+static volatile int open_devices = 0;
+
+pci_module_info *gPCI = NULL;
+
+static char *gDevnames; // buffer for all names
+
+device_hooks oss_driver_hooks;
+
+/*
+ * Table for permanently allocated memory (to be freed by std_op(UNLOAD))
+ */
+#define MAX_MEMBLOCKS 4096
+static void *memblocks[MAX_MEMBLOCKS];
+static int nmemblocks = 0;
+
+void *
+oss_contig_malloc (oss_device_t * osdev, int size, oss_uint64_t memlimit,
+ oss_native_word * phaddr)
+{
+ status_t err;
+ area_id id;
+ void *p = NULL;
+ uint32 lock = B_CONTIGUOUS;
+ physical_entry pent[1];
+
+ *phaddr = 0;
+
+ switch (memlimit)
+ {
+ case MEMLIMIT_ISA:
+ case MEMLIMIT_28BITS:
+ case MEMLIMIT_30BITS:
+ case MEMLIMIT_31BITS:
+ /* no known way to force a physical address limit other than <16M */
+ lock = B_LOMEM;
+ break;
+ case MEMLIMIT_32BITS:
+ lock = B_CONTIGUOUS;
+ break;
+
+ default:
+ cmn_err (CE_WARN, "Bad DMA memlimit for %s\n", osdev->nick);
+ }
+
+ /* round up to page size */
+ size += B_PAGE_SIZE - 1;
+ size &= ~(B_PAGE_SIZE - 1);
+
+ if ((err = id = create_area(OSS_CONTIG_AREA_NAME, &p, B_ANY_KERNEL_ADDRESS,
+ size, lock, 0)) < B_OK)
+ {
+ cmn_err (CE_WARN, "create_area() failed\n");
+ return NULL;
+ }
+
+ if ((err = get_memory_map(p, size, pent, 1)) < B_OK)
+ {
+ cmn_err (CE_WARN, "get_memory_map() failed\n");
+ delete_area(id);
+ return NULL;
+ }
+ *phaddr = (oss_native_word)pent[0].address;
+ return p;
+}
+
+void
+oss_contig_free (oss_device_t * osdev, void *p, int sz)
+{
+ area_id id;
+ if (p == NULL)
+ return;
+ id = area_for(p);
+ if (id < B_OK)
+ return;
+#ifdef MEMDEBUG
+ {
+ area_info ai;
+ if ((get_area_info(id, &ai) < B_OK) || strncmp(ai.name,
OSS_CONTIG_AREA_NAME))
+ {
+ cmn_err (CE_NOTE, "oss_contig_free: bad area (%ld)!\n", id);
+ return;
+ }
+ }
+#endif
+ delete_area(id);
+}
+
+int
+__oss_alloc_dmabuf (int dev, dmap_p dmap, unsigned int alloc_flags,
+ oss_uint64_t maxaddr, int direction)
+{
+ void *tmpbuf;
+ oss_native_word phaddr;
+ int size = 64 * 1024;
+ extern int dma_buffsize;
+
+ if (dma_buffsize > 16 && dma_buffsize <= 128)
+ size = dma_buffsize * 1024;
+
+ if (dmap->dmabuf != NULL)
+ return 0;
+
+/*
+ * Some applications and virtual drivers need shorter buffer.
+ */
+ if (dmap->flags & DMAP_SMALLBUF)
+ {
+ size = SMALL_DMABUF_SIZE;
+ }
+ else if (dmap->flags & DMAP_MEDIUMBUF)
+ {
+ size = MEDIUM_DMABUF_SIZE;
+ }
+
+ if ((alloc_flags & DMABUF_SIZE_16BITS) && size > 32 * 1024)
+ size = 32 * 1024;
+
+ tmpbuf = CONTIG_MALLOC (dmap->osdev, size, maxaddr, &phaddr);
+ if (tmpbuf == NULL)
+ return RETERR(ENOMEM);
+ dmap->dmabuf = tmpbuf;
+ dmap->buffsize = size;
+ dmap->dmabuf_phys = phaddr;
+
+ return 0;
+}
+
+void
+oss_free_dmabuf (int dev, dmap_p dmap)
+{
+ if (dmap->dmabuf == NULL)
+ return;
+
+ CONTIG_FREE (dmap->osdev, dmap->dmabuf, dmap->buffsize);
+ dmap->dmabuf = NULL;
+ dmap->buffsize = 0;
+ dmap->dmabuf_phys = 0;
+}
+
+
+oss_native_word
+oss_virt_to_bus (void *addr)
+{
+ physical_entry pent[2];
+ status_t err;
+
+ if (addr == NULL)
+ return 0;
+
+ /* XXX: ROUNDUP(B_PAGE_SIZE) ? */
+ if ((err = get_memory_map(addr, 1, pent, 2)) < 1)
+ {
+ cmn_err (CE_WARN, "Virtual address %x not mapped\n", (int) addr);
+ return 0;
+ }
+ //XXX:which???
+ //return (oss_native_word)pent[0].address;
+ return (oss_native_word)(gPCI->ram_address(pent[0].address));
+}
+
+
+void *
+oss_pmalloc (size_t sz)
+{
+ void *tmp;
+
+ tmp = KERNEL_MALLOC (sz);
+
+ if (nmemblocks < MAX_MEMBLOCKS)
+ memblocks[nmemblocks++] = tmp;
+
+ return tmp;
+}
+
+int
+oss_create_uio (uio_t * uio, char *buf, size_t count, uio_rw_t rw,
+ int is_kernel)
+{
+ memset (uio, 0, sizeof (*uio));
+
+ if (is_kernel)
+ {
+ oss_cmn_err (CE_CONT,
+ "oss_create_uio: Kernel space buffers not supported\n");
+ return RETERR(EIO);
+ }
+
+ uio->ptr = buf;
+ uio->resid = count;
+ uio->kernel_space = is_kernel;
+ uio->rw = rw;
+
+ return 0;
+}
+
+int
+oss_uiomove (void *address, size_t nbytes, enum uio_rw rwflag, uio_t * uio)
+{
+ int err = EFAULT;
+ FENTRY();
+
+ if (rwflag != uio->rw)
+ {
+ oss_cmn_err (CE_WARN, "uiomove: Bad direction\n");
+ goto err;
+ }
+
+ if (uio->resid < nbytes)
+ {
+ oss_cmn_err (CE_WARN, "uiomove: Bad count %d (%d)\n", nbytes,
+ uio->resid);
+ goto err;
+ }
+
+ if (uio->kernel_space)
+ goto err;
+
+ switch (rwflag)
+ {
+ case UIO_READ:
+ //XXX:user_memcpy...
+ memcpy (uio->ptr, address, nbytes);
+ break;
+
+ case UIO_WRITE:
+ //XXX:user_memcpy...
+ memcpy (address, uio->ptr, nbytes);
+ break;
+ }
+
+ uio->resid -= nbytes;
+ uio->ptr += nbytes;
+
+ err = B_OK;
+err:
+ FEXITR(err);
+ return err;
+}
+
+
+void
+oss_cmn_err (int level, char *s, ...)
+{
+ char tmp[1024], *a[6];
+ va_list ap;
+ int i, n = 0;
+
+ va_start (ap, s);
+
+ for (i = 0; i < strlen (s); i++)
+ if (s[i] == '%')
+ n++;
+
+ for (i = 0; i < n && i < 6; i++)
+ a[i] = va_arg (ap, char *);
+
+ for (i = n; i < 6; i++)
+ a[i] = NULL;
+
+ if (level == CE_CONT)
+ {
+ sprintf (tmp, s, a[0], a[1], a[2], a[3], a[4], a[5], NULL,
+ NULL, NULL, NULL);
+ dprintf ("%s", tmp);
+ }
+ else
+ {
+ strcpy (tmp, "osscore: ");
+ sprintf (tmp + strlen (tmp), s, a[0], a[1], a[2], a[3], a[4], a[5],
+ NULL, NULL, NULL, NULL);
+ if (level == CE_PANIC)
+ panic (tmp);
+
+ dprintf ("%s", tmp);
+ }
+ va_end (ap);
+}
+
+
+/*
+ * Sleep/wakeup
+ */
+
+struct oss_wait_queue *
+oss_create_wait_queue (oss_device_t * osdev, const char *name)
+{
+ struct oss_wait_queue *wq;
+ status_t err;
+ FENTRYA(", %s", name);
+
+ if ((wq = malloc (sizeof (*wq))) == NULL)
+ {
+ oss_cmn_err (CE_WARN, "malloc(%d) failed (wq)\n", sizeof (*wq));
+ return NULL;
+ }
+ sprintf(wq->name, OSS_WQ_SEM_NAME "%.20s", name);
+ err = wq->sem = create_sem(0, wq->name);
+ if (err < B_OK)
+ {
+ free(wq);
+ oss_cmn_err (CE_WARN, "create_sem() failed (wq)\n");
+ return NULL;
+ }
+
+ return wq;
+}
+
+void
+oss_reset_wait_queue (struct oss_wait_queue *wq)
+{
+ sem_info si;
+ status_t err;
+ FENTRY();
+
+ wq->flags = 0;
+ err = create_sem(0, wq->name);
+ if (err >= 0) {
+ /* replace with the new one */
+ delete_sem(wq->sem);
+ wq->sem = err;
+ }
+
+ FEXIT();
+}
+
+void
+oss_remove_wait_queue (struct oss_wait_queue *wq)
+{
+ FENTRY();
+ delete_sem(wq->sem);
+ free (wq);
+}
+
+int
+oss_sleep (struct oss_wait_queue *wq, oss_mutex_t * mutex, int ticks,
+ oss_native_word * flags, unsigned int *status)
+{
+ bigtime_t timeout = B_INFINITE_TIMEOUT;
+ uint32 semflags = B_CAN_INTERRUPT | B_RELATIVE_TIMEOUT;
+ int result = 0;
+ FENTRYA("(%s), , %d, , ", wq->name, ticks);
+ *status = 0;
+
+ if (wq == NULL)
+ return 0;
+
+#ifdef B_WAKE_ON_TIMEOUT
+ // Dano only; sure it's what we want ?
+ if (wq->flags & WK_WAKEUP)
+ flags |= B_WAKE_ON_TIMEOUT;
+#endif
+
+ wq->flags = 0;
+ MUTEX_EXIT_IRQRESTORE(*mutex, *flags);
+
+ if (ticks > 0)
+ timeout = ticks * 1000000LL / OSS_HZ;
+ result = acquire_sem_etc (wq->sem, 1, semflags, timeout);
+ //dprintf("oss_sleep:acquire_sem(s:%ld, 1, %x, %Ld): 0x%08lx\n", wq->sem,
semflags, timeout, result);
+
+ MUTEX_ENTER_IRQDISABLE (*mutex, *flags);
+
+ if (result == EINTR) /* Signal received */
+ {
+ *status |= WK_SIGNAL;
+ return 1;
+ }
+
+//if (result == B_TIMED_OUT)
+ if (!(wq->flags & WK_WAKEUP)) /* Timeout */
+ {
+ return 0;
+ }
+
+ return 1;
+}
+
+int
+oss_register_poll (struct oss_wait_queue *wq, oss_mutex_t * mutex,
+ oss_native_word * flags, oss_poll_event_t * ev)
+{
+ FENTRYA("(%s), , , , ", wq->name);
+ dprintf("oss:UNIMPLEMENTED:%s\n", __FUNCTION__);
+ MUTEX_EXIT_IRQRESTORE(*mutex, *flags);
+ //poll_wait ((struct file *) ev->file, &wq->wq, (struct wait *) ev->wait);
+ MUTEX_ENTER_IRQDISABLE (*mutex, *flags);
+ return 0;
+}
+
+void
+oss_wakeup (struct oss_wait_queue *wq, oss_mutex_t * mutex,
+ oss_native_word * flags, short events)
+{
+ FENTRYA("(%s), , %x, , ", wq->name, events);
+ if (wq == NULL)
+ return;
+
+ wq->flags |= WK_WAKEUP;
+ MUTEX_EXIT_IRQRESTORE(*mutex, *flags);
+
+ //dprintf("oss_wakeup:release_sem(s:%ld)\n", wq->sem);
+ release_sem_etc (wq->sem, 1, B_DO_NOT_RESCHEDULE);
+ //XXX:handle select here
+
+ MUTEX_ENTER_IRQDISABLE (*mutex, *flags);
+}
+
+unsigned long
+oss_get_time (void)
+{
+ return (unsigned long) (system_time() / (1000000 / OSS_HZ));
+}
+
+typedef struct tmout_desc
+{
+ struct timer timer; /* MUST be first */
+
+ volatile int active;
+ int timestamp;
+ void (*func) (void *);
+ void *arg;
+} tmout_desc_t;
+
+static volatile int next_id = 0;
+#define MAX_TMOUTS 128
+
+tmout_desc_t tmouts[MAX_TMOUTS] = { {0} };
+
+int timeout_random = 0x12123400;
+
+int32
+oss_timer_callback (struct timer *timer)
+{
+ tmout_desc_t *tmout = (tmout_desc_t *)timer;
+ int ix;
+ void *arg;
+
+ timeout_random++;
+
+ if (!tmout->active)
+ return;
+
+ arg = tmout->arg;
+ tmout->active = 0;
+ tmout->timestamp = 0;
+
+ tmout->func (arg);
+ return B_HANDLED_INTERRUPT;//B_INVOKE_SCHEDULER ?;
+}
+
+timeout_id_t
+oss_timeout (void (*func) (void *), void *arg, unsigned long long ticks)
+{
+ tmout_desc_t *tmout = NULL;
+ bigtime_t period;
+ int id, n;
+
+ timeout_random++;
+
+ n = 0;
+ id = -1;
+
+ while (id == -1 && n < MAX_TMOUTS)
+ {
+ if (!tmouts[next_id].active)
+ {
+ tmouts[next_id].active = 1;
+ id = next_id++;
+ tmout = &tmouts[id];
+ break;
+ }
+
+ next_id = (next_id + 1) % MAX_TMOUTS;
+ }
+
+ if (id == -1) /* No timer slots available */
+ {
+ oss_cmn_err (CE_WARN, "Timeout table full\n");
+ return 0;
+ }
+
+ tmout->func = func;
+ tmout->arg = arg;
+ tmout->timestamp = id | (timeout_random & ~0xff);
+
+ period = ticks * 1000000LL / OSS_HZ;
+ add_timer (&tmout->timer, oss_timer_callback, period,
B_ONE_SHOT_RELATIVE_TIMER);
+
+ return id | (timeout_random & ~0xff);
+}
+
+void
+oss_untimeout (timeout_id_t id)
+{
+ tmout_desc_t *tmout;
+ int ix;
+
+ ix = id & 0xff;
+ if (ix < 0 || ix >= MAX_TMOUTS)
+ return;
+
+ timeout_random++;
+ tmout = &tmouts[ix];
+
+ if (tmout->timestamp != id) /* Expired timer */
+ return;
+ if (tmout->active)
+ cancel_timer (&tmout->timer);
+ tmout->active = 0;
+ tmout->timestamp = 0;
+}
+
+
+caddr_t
+oss_map_pci_mem (oss_device_t * osdev, int nr, int phaddr, int size)
+{
+ status_t err;
+ void *va = NULL;
+ FENTRYA("%p,%d,%d,%d", osdev, nr, phaddr, size);
+ //XXX:align phaddr ?
+ /* round up to page size */
+ size += B_PAGE_SIZE - 1;
+ size &= ~(B_PAGE_SIZE - 1);
+
+ err = map_physical_memory(OSS_PCI_AREA_NAME, (void *)phaddr, size,
+ B_ANY_KERNEL_BLOCK_ADDRESS, 0, &va);
+ if (err < B_OK)
+ va = NULL;
+ FEXITR((uint32)va);
+ return (caddr_t)va;
+}
+
+void
+oss_unmap_pci_mem (void *addr)
+{
+ area_id id;
+ if (addr == NULL)
+ return;
+ id = area_for(addr);
+ if (id < B_OK)
+ return;
+#ifdef MEMDEBUG
+ {
+ area_info ai;
+ if ((get_area_info(id, &ai) < B_OK) || strncmp(ai.name, OSS_PCI_AREA_NAME))
+ {
+ cmn_err (CE_NOTE, "oss_unmap_pci_mem: bad area (%ld)!\n", id);
+ return;
+ }
+ }
+#endif
+ delete_area(id);
+}
+
+void
+oss_pci_byteswap (oss_device_t * osdev, int mode)
+{
+ // NOP
+}
+
+int
+pci_read_config_byte (oss_device_t * osdev, offset_t where,
+ unsigned char *val)
+{
+ if (osdev->dev_type != DRV_PCI || osdev->dip == NULL)
+ return PCIBIOS_FAILED;
+ *val = (unsigned char)gPCI->read_pci_config (osdev->dip->pciinfo.bus,
+ osdev->dip->pciinfo.device,
+ osdev->dip->pciinfo.function,
+ (uchar)where, 1);
+ return PCIBIOS_SUCCESSFUL;
+}
+
+int
+pci_read_config_irq (oss_device_t * osdev, offset_t where, unsigned char *val)
+{
+ int ret;
+
+ if (osdev->dev_type != DRV_PCI)
+ return PCIBIOS_FAILED;
+ ret = pci_read_config_byte (osdev, where, val);
+ return ret;
+}
+
+
+int
+pci_read_config_word (oss_device_t * osdev, offset_t where,
+ unsigned short *val)
+{
+ if (osdev->dev_type != DRV_PCI || osdev->dip == NULL)
+ return PCIBIOS_FAILED;
+ *val = (unsigned short)gPCI->read_pci_config (osdev->dip->pciinfo.bus,
+ osdev->dip->pciinfo.device,
+ osdev->dip->pciinfo.function,
+ (uchar)where, 2);
+ return PCIBIOS_SUCCESSFUL;
+}
+
+int
+pci_read_config_dword (oss_device_t * osdev, offset_t where,
+ unsigned int *val)
+{
+ if (osdev->dev_type != DRV_PCI || osdev->dip == NULL)
+ return PCIBIOS_FAILED;
+ *val = (unsigned int)gPCI->read_pci_config (osdev->dip->pciinfo.bus,
+ osdev->dip->pciinfo.device,
+ osdev->dip->pciinfo.function,
+ (uchar)where, 4);
+ return PCIBIOS_SUCCESSFUL;
+}
+
+int
+pci_write_config_byte (oss_device_t * osdev, offset_t where,
+ unsigned char val)
+{
+ if (osdev->dev_type != DRV_PCI || osdev->dip == NULL)
+ return PCIBIOS_FAILED;
+ gPCI->write_pci_config (osdev->dip->pciinfo.bus,
+ osdev->dip->pciinfo.device,
+ osdev->dip->pciinfo.function,
+ (uchar)where, 1, val);
+ return PCIBIOS_SUCCESSFUL;
+}
+
+int
+pci_write_config_word (oss_device_t * osdev, offset_t where,
+ unsigned short val)
+{
+ if (osdev->dev_type != DRV_PCI || osdev->dip == NULL)
+ return PCIBIOS_FAILED;
+ gPCI->write_pci_config (osdev->dip->pciinfo.bus,
+ osdev->dip->pciinfo.device,
+ osdev->dip->pciinfo.function,
+ (uchar)where, 2, val);
+ return PCIBIOS_SUCCESSFUL;
+}
+
+int
+pci_write_config_dword (oss_device_t * osdev, offset_t where,
+ unsigned int val)
+{
+ if (osdev->dev_type != DRV_PCI || osdev->dip == NULL)
+ return PCIBIOS_FAILED;
+ gPCI->write_pci_config (osdev->dip->pciinfo.bus,
+ osdev->dip->pciinfo.device,
+ osdev->dip->pciinfo.function,
+ (uchar)where, 4, val);
+ return PCIBIOS_SUCCESSFUL;
+}
+
+
+
+#ifdef MUTEX_CHECKS
+static int oss_context = 0; /* 0=user context, 1=interrupt context */
+#endif
+
+static int32
+ossintr (void *idata)
+{
+ oss_device_t *osdev = idata;
+ oss_native_word flags;
+ //dprintf("oss:intr(%ld)!\n", osdev->irq);
+#ifdef MUTEX_CHECKS
+ int saved_context;
+ saved_context = oss_context;
+ if (oss_context == 1)
+ cmn_err (CE_WARN, "Recursive interrupt\n");
+ oss_context = 1;
+#endif
+
+ MUTEX_ENTER_IRQDISABLE (osdev->mutex, flags);
+
+ if (!osdev->tophalf_handler (osdev))
+ {
+ MUTEX_EXIT_IRQRESTORE (osdev->mutex, flags);
+#ifdef MUTEX_CHECKS
+ oss_context = saved_context;
+#endif
+ return B_UNHANDLED_INTERRUPT;
+ }
+
+ if (osdev->bottomhalf_handler != NULL)
+ osdev->bottomhalf_handler (osdev);
+
+ MUTEX_EXIT_IRQRESTORE (osdev->mutex, flags);
+#ifdef MUTEX_CHECKS
+ oss_context = saved_context;
+#endif
+
+ return B_HANDLED_INTERRUPT;
+}
+
+int
+oss_register_interrupts (oss_device_t * osdev, int intrnum,
+ oss_tophalf_handler_t top,
+ oss_bottomhalf_handler_t bottom)
+{
+ unsigned char pci_irq_line;
+ int err;
+ FENTRYA(", %d, , ", intrnum);
+
+ if (intrnum != 0)
+ {
+ cmn_err (CE_WARN, "Bad interrupt index (%d) for %s\n", intrnum,
+ osdev->name);
+ return RETERR(EINVAL);
+ }
+
+ if (osdev == NULL)
+ {
+ cmn_err (CE_WARN, "oss_register_interrupts: Bad osdev\n");
+ return RETERR(EINVAL);
+ }
+
+ if (osdev->tophalf_handler != NULL || osdev->bottomhalf_handler != NULL)
+ {
+ cmn_err (CE_WARN, "Interrupts already registered for %s\n",
+ osdev->name);
+ return RETERR(EINVAL);
+ }
+
+ if (top == NULL)
+ {
+ cmn_err (CE_WARN, "Bad interrupt handler for %s\n", osdev->name);
+ return RETERR(EINVAL);
+ }
+
+ // could probably use osdev->dip->pciinfo...
+ if (pci_read_config_irq (osdev, PCI_INTERRUPT_LINE, &pci_irq_line) > 0)
+ return RETERR(EIO);
+
+ osdev->irq = pci_irq_line;
+ osdev->tophalf_handler = top;
+ osdev->bottomhalf_handler = bottom;
+ err = install_io_interrupt_handler (pci_irq_line, ossintr, osdev, 0);
+ if (err < B_OK)
+ {
+ cmn_err (CE_WARN, "install_io_interrupt_handler failed for %s\n",
osdev->nick);
+ osdev->irq = -1;
+ osdev->tophalf_handler = NULL;
+ osdev->bottomhalf_handler = NULL;
+ return RETERR(err);
+ }
+
+ return 0;
+}
+
+void
+oss_unregister_interrupts (oss_device_t * osdev)
+{
+ FENTRY();
+ if (osdev->irq >= 0)
+ remove_io_interrupt_handler (osdev->irq, ossintr, osdev);
+ osdev->irq = -1;
+}
+
+int
+oss_register_device (oss_device_t * osdev, const char *name)
+{
+ static int dev_instance = 0;
+ FENTRYA(", %s", name);
+
+ DDB (cmn_err (CE_CONT, "OSS device %d is %s\n", dev_instance++, name));
+
+ if ((osdev->name = PMALLOC (NULL, strlen (name) + 1)) == NULL)
+ {
+ cmn_err (CE_WARN, "Cannot allocate memory for device name\n");
+ osdev->name = "Unknown device";
+ }
+ strcpy (osdev->name, name);
+ FEXITR(0);
+ return 0;
+}
+
+int
+oss_disable_device (oss_device_t * osdev)
+{
+ int i;
+ FENTRY();
+/*
+ * This routine should check if the device is ready to be unloaded (no devices
are in use).
+ * If the device cannot be unloaded this routine must return RETERR(EBUSY).
+ *
+ * If the device can be unloaded then disable any timers or other features
that may cause the
+ * device to be called. Also mark the audio/midi/mixer/etc devices of this
device to be disabled.
+ * However the interrupt handler should still stay enabled. The low level
driver will call
+ * oss_unregister_interrupts() after it has cleared the interrupt enable
register.
+ */
+ if (osdev->refcount > 0 || oss_open_devices > 0)
+ {
+ cmn_err (CE_CONT, "Refcount %d, open_devices %d\n", osdev->refcount,
+ oss_open_devices);
+ return RETERR(EBUSY);
+ }
+
+/*
+ * Now mark all devices unavailable (for the time being)
+ */
+
+ for (i = 0; i < num_mixers; i++)
+ if (mixer_devs[i]->osdev == osdev)
+ {
+ mixer_devs[i]->unloaded = 1;
+ }
+
+ for (i = 0; i < num_mididevs; i++)
+ {
+ if (midi_devs[i]->osdev == osdev)
+ {
+ midi_devs[i]->unloaded = 1;
+ if (midi_devs[i]->converter != NULL)
+ midi_devs[i]->converter->enabled = 0;
+ }
+ }
+
+ for (i = 0; i < num_audio_engines; i++)
+ if (audio_engines[i]->osdev == osdev)
+ {
+ audio_uninit_device (i);
+ }
+
+ FEXIT();
+ return 0;
+}
+
+void
+oss_unregister_device (oss_device_t * osdev)
+{
+ FENTRY();
+/*
+ * Notice! The driver calling this routine (the owner of the osdev parameter)
+ * has already uninitialized itself. Do not do any actions that may call this
+ * driver directly or indirectly.
+ */
+
+/*
+ * Force reload of all drivers if any application tries to open any
+ * of the devices.
+ */
+ //do_forceload = 1;
+ FEXIT();
+}
+
+void
+oss_reserve_device (oss_device_t * osdev)
+{
+ osdev->refcount++;
+}
+
+void
+oss_unreserve_device (oss_device_t * osdev)
+{
+ osdev->refcount--;
+ if (osdev->refcount < 0)
+ osdev->refcount = 0;
+}
+
+void *
+oss_get_osid (oss_device_t * osdev)
+{
+// return osdev->osid;
+// return osdev->dip;
+ return NULL; // XXX:TODO
+}
+
+
+oss_device_t *
+osdev_create (dev_info_t * dip, int dev_type, int instance, const char *nick,
+ const char *handle)
+{
+ oss_device_t *osdev = NULL;
+ int i, err;
+ caddr_t addr;
+ off_t region_size;
+ FENTRYA(", %d, %d, %s, %s", dev_type, instance, nick, handle);
+
+ if (handle == NULL)
+ handle = nick;
+
+ /*
+ * Don't accept any more drivers if expired
+ */
+ if (oss_expired && oss_num_cards > 0)
+ return NULL;
+
+ for (i = 0; dip && (i < oss_num_cards); i++)
+ {
+ if (cards[i] == NULL)
+ continue;
+ if (cards[i]->dip == dip)
+ {
+ osdev = cards[i];
+ break;
+ }
+ }
+
+ if (osdev == NULL)
+ {
+ if (oss_num_cards >= MAX_CARDS)
+ cmn_err (CE_PANIC, "Too many OSS devices. At most %d permitted.\n",
+ MAX_CARDS);
+ if ((osdev = PMALLOC (NULL, sizeof (*osdev))) == NULL)
+ {
+ cmn_err (CE_WARN, "osdev_create: Out of memory\n");
+ return NULL;
+ }
+ memset (osdev, 0, sizeof (*osdev));
+
+ osdev->cardnum = oss_num_cards;
+ cards[oss_num_cards++] = osdev;
+ }
+
+ osdev->dip = dip;
+ //osdev->osid = dip;
+ osdev->unloaded = 0;
+ osdev->instance = instance;
+ osdev->dev_type = dev_type;
+ osdev->devc = NULL;
+ MUTEX_INIT (osdev, osdev->mutex, MH_GLOBAL);
+ sprintf (osdev->nick, "%s%d", nick, instance);
+ strcpy (osdev->modname, nick);
+
+ switch (dev_type)
+ {
+ case DRV_PCI:
+ /* NOP */
+ break;
+
+ case DRV_VIRTUAL:
+ case DRV_STREAMS:
+ /* NOP */
+ break;
+
+ case DRV_USB:
+ /* NOP */
+ break;
+
+ default:
+ cmn_err (CE_WARN, "Bad device type\n");
+ return NULL;
+ }
+
+/*
+ * Create the device handle
+ */
+ switch (dev_type)
+ {
+ case DRV_PCI:
+ {
+ unsigned int subvendor;
+ pci_read_config_dword (osdev, 0x2c, &subvendor);
+
+ sprintf (osdev->handle, "PCI%08x-%d", subvendor, instance);
+ }
+ break;
+
+ case DRV_USB:
+ /* TODO: Get the vendor information */
+ sprintf (osdev->handle, "USB-%s%d", handle, instance);
+ break;
+
+ default:
+ sprintf (osdev->handle, "%s%d", handle, instance);
+ }
+
+ FEXIT();
+ return osdev;
+}
+
+oss_device_t *
+osdev_clone (oss_device_t * orig_osdev, int new_instance)
+{
+ oss_device_t *osdev;
+ FENTRYA(", %d", new_instance);
+
+ osdev = PMALLOC (NULL, sizeof (*osdev));
+ if (osdev == NULL)
+ {
+ cmn_err (CE_WARN, "osdev_create: Out of memory\n");
+ return NULL;
+ }
+ memcpy (osdev, orig_osdev, sizeof (*osdev));
+ osdev->dev_type = DRV_CLONE;
+ osdev->instance = new_instance;
+ sprintf (osdev->nick, "%s%d", orig_osdev->modname, new_instance);
+ sprintf (osdev->handle, "%s%d", orig_osdev->modname, new_instance);
+
+ FEXIT();
+ return osdev;
+}
+
+void
+osdev_delete (oss_device_t * osdev)
+{
+ int i;
+
+ FENTRY();
+ if (osdev == NULL)
+ return;
+
+ switch (osdev->dev_type)
+ {
+ case DRV_PCI:
+ /* NOP */
+ //pci_config_teardown (&osdev->pci_config_handle);
+ //osdev->pci_config_handle = NULL;
+ break;
+ }
+
+/*
+ * Mark all minor nodes for this module as invalid.
+ */
+ for (i = 0; i < oss_num_cdevs; i++)
+ if (oss_cdevs[i]->osdev == osdev)
+ {
+ oss_cdevs[i]->d = NULL;
+ oss_cdevs[i]->osdev = NULL;
+ strcpy (oss_cdevs[i]->name, "Removed device");
+ }
+ MUTEX_CLEANUP (osdev->mutex);
+ osdev->unloaded = 1;
+ FEXIT();
+}
+
+void
+oss_install_chrdev (oss_device_t * osdev, char *name, int dev_class,
+ int instance, oss_cdev_drv_t * drv, int flags)
+{
+/*
+ * oss_install_chrdev creates a character device (minor). However if
+ * name==NULL the device will not be exported (made visible to userland
+ * clients).
+ */
+
+ int i, num;
+ oss_cdev_t *cdev = NULL;
+ FENTRYA(", %s, %d, %d, , %d", name, dev_class, instance, flags);
+
+ if (dev_class != OSS_DEV_STATUS)
+ if (oss_expired && instance > 0)
+ return;
+/*
+ * Find if this dev_class&instance already exists (after previous module
+ * detach).
+ */
+
+ for (num = 0; num < oss_num_cdevs; num++)
+ if (oss_cdevs[num]->d == NULL) /* Unloaded driver */
+ if (oss_cdevs[num]->dev_class == dev_class
+ && oss_cdevs[num]->instance == instance)
+ {
+ cdev = oss_cdevs[num];
+ //dprintf("oss:reusing cdev[%d]\n", num);
+ break;
+ }
+
+ if (cdev == NULL)
+ {
+ num = oss_num_cdevs++;
+ if (oss_num_cdevs >= OSS_MAX_CDEVS)
+ {
+ cmn_err (CE_WARN, "Out of minor numbers.\n");
+ return;
+ }
+
+ if ((cdev = PMALLOC (NULL, sizeof (*cdev))) == NULL)
+ {
+ cmn_err (CE_WARN, "Cannot allocate character device desc.\n");
+ return;
+ }
+ //dprintf("oss:reusing cdev[%d]: @%p\n", num, cdev);
+ }
+
+ memset (cdev, 0, sizeof (*cdev));
+ cdev->dev_class = dev_class;
+ cdev->instance = instance;
+ cdev->d = drv;
+ cdev->osdev = osdev;
+ if (name != NULL)
+ strncpy (cdev->name, name, sizeof (cdev->name) - 1);
+ else
+ strcpy (cdev->name, "NONE");
+ cdev->name[sizeof (cdev->name) - 1] = 0;
+ oss_cdevs[num] = cdev;
+
+/*
+ * Export the device only if name != NULL
+ */
+ if (name != NULL)
+ {
+ char tmp[64], *s;
+ char *dev_type = "oss_sysdev";
+
+//XXX: maybe do something ??
+ }
+ FEXIT();
+}
+
+int
+oss_get_cardinfo (int cardnum, oss_card_info * ci)
+{
+/*
+ * Print information about a 'card' in a format suitable for /dev/sndstat
+ */
+
+ if (cardnum < 0 || cardnum >= oss_num_cards)
+ return RETERR(ENXIO);
+
+ if (cards[cardnum]->name != NULL)
+ strncpy (ci->longname, cards[cardnum]->name, 128);
+ ci->shortname[127] = 0;
+
+ if (cards[cardnum]->nick != NULL)
+ strncpy (ci->shortname, cards[cardnum]->nick, 16);
+ ci->shortname[15] = 0;
+
+ return 0;
+}
+
+/* XXX: major/minors don't exist in BeOS, WTF */
+int
+oss_find_minor (int dev_class, int instance)
+{
+ int i;
+
+ for (i = 0; i < oss_num_cdevs; i++)
+ if (oss_cdevs[i]->d != NULL && oss_cdevs[i]->dev_class == dev_class
+ && oss_cdevs[i]->instance == instance)
+ return i;
+
+ return -1;
+}
+
+
+#ifdef MUTEX_CHECKS
+void
+debug_mutex_init (oss_mutex_t * mutex, char *file, int line)
+{
+ memset (mutex, 0, sizeof (mutex));
+ mutex->lock = 0;
+ mutex->owner = -1;
+}
+
+void
+debug_mutex_destroy (oss_mutex_t * mutex, char *file, int line)
+{
+ if (find_thread(NULL) == mutex->owner)
+ {
+ cmn_err (CE_NOTE, "%s:%d: mutex still owned (%d)\n", file, line,
mutex->owner);
+ }
+ if (mutex->lock)
+ {
+ cmn_err (CE_NOTE, "%s:%d: mutex still locked (%d)\n", file, line,
mutex->lock);
+ }
+}
+
+void
+debug_mutex_enter (oss_mutex_t * mutex, char *file, int line, oss_native_word
*flags)
+{
+ if (find_thread(NULL) == mutex->owner)
+ {
+ cmn_err (CE_NOTE, "%s:%d: Re-entrant mutex (%s:%d %d)\n", file, line,
+ mutex->file, mutex->line, mutex->busy_flags);
+ return;
+ }
+
+ mutex->file = file;
+ mutex->line = line;
+ mutex->busy_flags = flags ? CNTX_INTR : CNTX_USER;
+ if (flags)
+ *flags = (oss_native_word) disable_interrupts();
+ acquire_spinlock (&mutex->lock);
+
+}
+
+void
+debug_mutex_exit (oss_mutex_t * mutex, char *file, int line, oss_native_word
*flags)
+{
+ if (find_thread(NULL) != mutex->owner)
+ {
+ cmn_err (CE_NOTE, "Mutex not owned %s:%d\n", file, line);
+ }
+ else
+ {
+ release_spinlock(&mutex->lock);
+ if (flags)
+ restore_interrupts((cpu_status)*flags);
+ }
+
+ mutex->owner = -1;
+ mutex->file = NULL;
+ mutex->line = 0;
+ mutex->busy_flags = 0;
+}
+#endif
+
+/*
+ * Driver entry point routines
+ */
+
+status_t
+init_osscore (void)
+{
+ int err = 0;
+ oss_device_t *osdev;
+ FENTRY();
+
+#ifdef LICENSED_VERSION
+/*WRITEME*/
+#endif
+
+ if ((osdev = osdev_create (NULL, DRV_VIRTUAL, 0, "oss", NULL)) == NULL)
+ {
+ cmn_err (CE_WARN, "Creating osdev failed\n");
+ FEXITR(ENOMEM);
+ return RETERR(ENOMEM);
+ }
+
+
+ MUTEX_INIT (osdev, osscore_mutex, MH_TOP);
+
+ //install_drvinfo (osdev);
+ oss_common_init (osdev);
+
+ oss_register_device (osdev, "OSS core services");
+
+ FEXIT();
+ return 0;
+}
+
+status_t
+uninit_osscore (void)
+{
+ int i;
+ static int already_unloaded = 0;
+ FENTRY();
+
+ if (oss_open_devices > 0)
+ return EBUSY;
+
+ if (already_unloaded)
+ return 0;
+ already_unloaded = 1;
+
+ oss_unload_drivers ();
+
+ for (i = 0; i < nmemblocks; i++)
+ KERNEL_FREE (memblocks[i]);
+ nmemblocks = 0;
+
+ MUTEX_CLEANUP (osscore_mutex);
+
+ return 0;
+}
+
+const char **
+oss_publish_devices(void)
+{
+ int i, j;
+ static const char *devices[OSS_MAX_CDEVS] = {
+ NULL
+ };
+
+ FENTRY();
+
+ // XXX:any locking ??
+ for (i = 0; i < OSS_MAX_CDEVS; i++)
+ devices[i] = NULL;
+ dprintf("oss_num_cdevs = %d\n", oss_num_cdevs);
+ for (i = 0, j = 0; i < oss_num_cdevs; i++) {
+ oss_cdev_t *cdev = oss_cdevs[i];
+ if (cdev && cdev->d) {
+ char *name = &gDevnames[i*DEVICE_NAME_LEN];
+ strcpy(name, DEVICE_PREFIX);
+ strncat(name, cdev->name, 32-1);
+ dprintf("oss: publishing %s\n", name);
+ devices[j++] = name;
+ }
+ }
+
+ FEXIT();
+ return devices;
+}
+
+device_hooks *oss_get_driver_hooks (void)
+{
+ return &oss_driver_hooks;
+}
+
+//XXX:hack: testing testing!
+extern int atiaudio_probe(void);
+extern int ali5455_probe(void);
+
+status_t
+oss_load_drivers (void)
+{
+ oss_drv_module_info *drv;
+ char module[256];
+ size_t modulesz = sizeof(module);
+ void *cookie;
+ status_t err = ENOENT;
+ FENTRY();
+ cookie = open_module_list(OSS_MODULES_PREFIX);
+ if (cookie == NULL)
+ goto err1;
+ while (read_next_module_name(cookie, module, &modulesz) >= B_OK)
+ {
+ err = get_module(module, (module_info **)&drv);
+ if (err >= B_OK)
+ {
+ if (drv->driver_probe() < B_OK)
+ put_module(module);
+ }
+ modulesz = sizeof(module);
+ }
+ err = B_OK;
+err2:
+ close_module_list(cookie);
+err1:
+ FEXITR(err);
+ return B_OK;
+}
+
+status_t
+oss_probe_pci (void)
+{
+ FENTRY();
+ ali5455_probe();
+ atiaudio_probe();
+ FEXIT();
+ return B_OK;
+}
+
+
+static status_t
+unload_driver (const char *nick)
+{
+ oss_drv_module_info *drv;
+ char module[256];
+ status_t err = B_OK;
+ int i;
+ FENTRYA("%s", nick);
+
+ /* skip ourselves */
+ if (!strcmp(nick, "oss"))
+ goto err1;
+
+ sprintf(module, "%s%s%s", OSS_MODULES_PREFIX, nick, OSS_MODULES_SUFFIX);
+ err = get_module(module, (module_info **)&drv);
+ if (err < B_OK)
+ goto err1;
+
+ err = EBUSY;
+ /* detach all osdevs for this driver */
+ for (i = 0; i < oss_num_cards; i++)
+ {
+ if (!cards[i])
+ continue;
+ if (strncmp(cards[i]->modname, nick, 32))
+ continue;
+ err = drv->driver_detach(cards[i]);
+ if (err < B_OK)
+ goto err2;
+ //cards[i] = NULL; // XXX: not sure...
+ }
+ err = B_OK;
+ put_module(module);
+ /* twice */
+err2:
+ put_module(module);
+err1:
+ FEXITR(err);
+ return err;
+}
+
+status_t
+oss_unload_all_drivers(void)
+{
+ char module[256];
+ status_t err = B_OK;
+ int i;
+ FENTRY();
+
+ /* for each osdev still around, unload the module it came from,
+ * which should delete them.
+ */
+ for (i = 0; i < oss_num_cards; i++)
+ {
+ if (!cards[i])
+ continue;
+ if (cards[i]->unloaded)
+ continue;
+ err = unload_driver(cards[i]->modname);
+ if (err < B_OK)
+ break;
+ }
+ FEXITR(err);
+ return err;
+}
+
+
+static status_t
+oss_stdops(int32 op, ...)
+{
+ status_t err;
+ switch (op)
+ {
+ case B_MODULE_INIT:
+ gDevnames = malloc(OSS_MAX_CDEVS*DEVICE_NAME_LEN);
+ if (!gDevnames)
+ break;
+ err = get_module(B_PCI_MODULE_NAME, (module_info **)&gPCI);
+ if (err >= B_OK)
+ {
+ //XXX:call init_osscore() here
+ return err;
+ put_module(B_PCI_MODULE_NAME);
+ }
+ free(gDevnames);
+ return err;
+ case B_MODULE_UNINIT:
+ free(gDevnames);
+ put_module(B_PCI_MODULE_NAME);
+ return B_OK;
+
+ }
+ return B_ERROR;
+}
+
+oss_core_module_info gOSSCoreModule = {
+ {
+ OSS_CORE_MODULE_NAME,
+ 0,
+ oss_stdops,
+ },
+ init_osscore,
+ uninit_osscore,
+ oss_publish_devices,
+ oss_get_driver_hooks,
+ oss_probe_pci,
+ oss_load_drivers,
+ oss_unload_all_drivers,
+};
+
+extern oss_drv_module_info gModule_ali5455;
+extern oss_drv_module_info gModule_allegro;
+extern oss_drv_module_info gModule_als300;
+extern oss_drv_module_info gModule_als4000;
+extern oss_drv_module_info gModule_apci97;
+extern oss_drv_module_info gModule_atiaudio;
+extern oss_drv_module_info gModule_audigyls;
+extern oss_drv_module_info gModule_audioloop;
+extern oss_drv_module_info gModule_audiopci;
+extern oss_drv_module_info gModule_cmi8788;
+extern oss_drv_module_info gModule_cmpci;
+extern oss_drv_module_info gModule_cs4280;
+extern oss_drv_module_info gModule_cs4281;
+extern oss_drv_module_info gModule_digi32;
+extern oss_drv_module_info gModule_digi96;
+extern oss_drv_module_info gModule_emu10k1x;
+extern oss_drv_module_info gModule_fm801;
+extern oss_drv_module_info gModule_geode;
+extern oss_drv_module_info gModule_hdaudio;
+extern oss_drv_module_info gModule_ich;
+extern oss_drv_module_info gModule_imux;
+extern oss_drv_module_info gModule_maestro;
+extern oss_drv_module_info gModule_neomagic;
+extern oss_drv_module_info gModule_s3vibes;
+extern oss_drv_module_info gModule_sblive;
+extern oss_drv_module_info gModule_softoss;
+extern oss_drv_module_info gModule_solo;
+extern oss_drv_module_info gModule_trident;
+extern oss_drv_module_info gModule_via8233;
+extern oss_drv_module_info gModule_via97;
+extern oss_drv_module_info gModule_vortex;
+extern oss_drv_module_info gModule_ymf7xx;
+module_info *modules[] = {
+
+ (module_info *)&gOSSCoreModule,
+
+ (module_info *)&gModule_ali5455,
+
+ (module_info *)&gModule_allegro,
+ (module_info *)&gModule_als300,
+ (module_info *)&gModule_als4000,
+ (module_info *)&gModule_apci97,
+
+ (module_info *)&gModule_atiaudio,
+
+ (module_info *)&gModule_audigyls,
+ //(module_info *)&gModule_audioloop,
+ (module_info *)&gModule_audiopci,
+ (module_info *)&gModule_cmi8788,
+ (module_info *)&gModule_cmpci,
+ (module_info *)&gModule_cs4280,
+ (module_info *)&gModule_cs4281,
+ (module_info *)&gModule_digi32,
+ (module_info *)&gModule_digi96,
+ (module_info *)&gModule_emu10k1x,
+ (module_info *)&gModule_fm801,
+ (module_info *)&gModule_geode,
+ (module_info *)&gModule_hdaudio,
+
+ (module_info *)&gModule_ich,
+
+ //(module_info *)&gModule_imux,
+ (module_info *)&gModule_maestro,
+ (module_info *)&gModule_neomagic,
+ (module_info *)&gModule_s3vibes,
+ (module_info *)&gModule_sblive,
+ //(module_info *)&gModule_softoss,
+ (module_info *)&gModule_solo,
+ (module_info *)&gModule_trident,
+ (module_info *)&gModule_via8233,
+ (module_info *)&gModule_via97,
+ (module_info *)&gModule_vortex,
+ (module_info *)&gModule_ymf7xx,
+
+ NULL
+};
+
+/*
+ * Driver hooks
+ */
+
+
+typedef struct ossdev_cookie {
+ int minor; /* index into cdevs[] */
+ oss_cdev_t *cdev;
+ struct fileinfo file;
+} ossdev_cookie_t;
+
+static int find_cdev(const char *name)
+{
+ int i;
+// if (strlen(name) < strlen(DEVICE_PREFIX))
+// return -1;
+ name += strlen(DEVICE_PREFIX);
+ // XXX:locking ?
+ for (i = 0; i < oss_num_cdevs; i++)
+ {
+ oss_cdev_t *cdev = oss_cdevs[i];
+ //dprintf("oss:find_cdev: cdev %p, ->d %p, %s <> %s\n", cdev,
cdev?cdev->d:NULL, cdev?cdev->name:"-", name);
+ if (cdev && cdev->d && !strncmp(cdev->name, name, 32))
+ return i;
+ }
+ return -1;
+}
+
+static status_t
+ossdrv_open(const char *name, uint32 oflags, void **cookie)
+{
+ ossdev_cookie_t *c;
+ status_t err;
+ int dev, tmpdev;
+ oss_cdev_t *cdev;
+ oss_native_word flags;
+ FENTRYA("%s, %ld, ", name, oflags);
+
+ dev = find_cdev(name);
+ err = ENOENT;
+ if (dev < 0)
+ goto err1;
+ err = ENXIO;
+ if (dev > oss_num_cdevs)
+ goto err1;
+ if ((cdev = oss_cdevs[dev]) == NULL || cdev->d == NULL)
+ goto err1;
+
+ DDB (cmn_err
+ (CE_CONT, "oss_cdev_open(%d): %s, class=%d, instance=%d\n", dev,
+ cdev->name, cdev->dev_class, cdev->instance));
+
+ err = ENODEV;
+ if (cdev->d->open == NULL)
+ goto err1;
+
+ err = ENOMEM;
+ c = malloc(sizeof(ossdev_cookie_t));
+ if (!c)
+ goto err1;
+
+ switch (oflags & O_RWMASK)
+ {
+ case O_RDONLY:
+ c->file.mode = OPEN_READ;
+ break;
+ case O_WRONLY:
+ c->file.mode = OPEN_WRITE;
+ break;
+ case O_RDWR:
+ c->file.mode = OPEN_READWRITE;
+ break;
+ default:
+ err = EINVAL;
+ goto err2;
+ }
+ c->file.flags = oflags;
+
+ tmpdev = dev;
+ err =
+ cdev->d->open (cdev->instance, cdev->dev_class, &c->file, 0, 0, &tmpdev);
+ if (err)
+ goto err3;
+
+ c->minor = dev = tmpdev;
+ c->cdev = cdev = oss_cdevs[dev];
+
+ //XXX:locking
+ MUTEX_ENTER_IRQDISABLE (osscore_mutex, flags);
+ oss_open_devices++;
+ open_count[dev]++;
+ MUTEX_EXIT_IRQRESTORE (osscore_mutex, flags);
+
+ *cookie = c;
+ FEXITR(B_OK);
+ return B_OK;
+
+err3:
+err2:
+ free(c);
+err1:
+ FEXITR(err);
+ return err;
+}
+
+
+static status_t
+ossdrv_close(void *cookie)
+{
+ FENTRY();
+ FEXIT();
+ return B_OK;
+}
+
+
+static status_t
+ossdrv_freecookie(ossdev_cookie_t *cookie)
+{
+ oss_cdev_t *cdev = cookie->cdev;
+ int dev = cookie->minor;
+ oss_native_word flags;
+ status_t err;
+ FENTRY();
+
+ err = ENXIO;
+ if (dev >= OSS_MAX_CDEVS)
+ goto err;
+
+ err = B_OK;
+ if (open_count[dev] == 0) /* Not opened */
+ goto err;
+
+ err = ENXIO;
+ if (cdev != oss_cdevs[dev])
+ goto err;
+
+ //in close or free ??
+ cdev->d->close (cdev->instance, &cookie->file);
+
+ MUTEX_ENTER_IRQDISABLE (osscore_mutex, flags);
+ oss_open_devices--;
+ open_count[dev]--;
+ MUTEX_EXIT_IRQRESTORE (osscore_mutex, flags);
+
+ free(cookie);
+ err = B_OK;
+err:
+ FEXITR(err);
+ return B_OK;
+}
+
+/* note: IOC stuff seems to not collide with the base ioctls from Drivers.h
+ * as long as the type field is printable ascii (>32). Lucky are we.
+ */
+static status_t
+ossdrv_ioctl(ossdev_cookie_t *cookie, uint32 op, void *buffer, size_t length)
+{
+ oss_cdev_t *cdev = cookie->cdev;
+ status_t err = ENXIO;
+ uint32 cmd = op;
+ int len = 0;
+ char buf[4096];
+ FENTRYA(", %lx, , %ld", op, length);
+
+ if ((cdev != oss_cdevs[cookie->minor]) || cdev->d->ioctl == NULL)
+ goto err1;
+
+ if (cmd & (SIOC_OUT | SIOC_IN))
+ {
+
+ len = (cmd >> 16) & SIOCPARM_MASK;
+ if (len < 0)
+ len = 0;
+ if (len > sizeof (buf))
+ {
+ cmn_err (CE_WARN, "Bad ioctl buffer size %d\n", len);
+ err = EFAULT;
+ goto err1;
+ }
+
+ if ((cmd & SIOC_IN) && len > 0)
+ {
+ memcpy (buf, buffer, len);
+ //return EFAULT;
+ }
+
+ }
+
+ err = cdev->d->ioctl (cdev->instance, &cookie->file, cmd, (ioctl_arg) buf);
+
+ if ((cmd & SIOC_OUT) && len > 0)
+ {
+ memcpy (buffer, buf, len);
+ //return EFAULT;
+ }
+
+
+err1:
+ FEXITR(err);
+ return err;
+}
+
+
+static status_t
+ossdrv_read(ossdev_cookie_t *cookie, off_t pos, void *buffer, size_t *_length)
+{
+ oss_cdev_t *cdev = cookie->cdev;
+ uio_t uio;
+ int count = *_length;
+ int err;
+ FENTRYA(", %Ld, , %ld", pos, *_length);
+
+ err = ENXIO;
+ if ((cdev != oss_cdevs[cookie->minor]) || cdev->d->read == NULL)
+ goto err;
+ //files[dev].acc_flags = uiop->uio_fmode;
+ if ((err = oss_create_uio (&uio, buffer, count, UIO_READ, 0)) < 0)
+ goto err;
+
+ err = cdev->d->read (cdev->instance, &cookie->file, &uio, count);
+ *_length = (err > 0) ? err : 0;
+ if (err < 0)
+ goto err;
+
+ *_length = err;
+ err = B_OK;
+ FEXITR(err);
+ return err;
+
+err:
+ *_length = 0;
+ FEXITR(err);
+ return err;
+}
+
+
+static status_t
+ossdrv_write(ossdev_cookie_t *cookie, off_t pos, const void *buffer, size_t
*_length)
+{
+ oss_cdev_t *cdev = cookie->cdev;
+ uio_t uio;
+ int count = *_length;
+ int err;
+ FENTRYA(", %Ld, , %ld", pos, *_length);
+
+ err = ENXIO;
+ if ((cdev != oss_cdevs[cookie->minor]) || cdev->d->write == NULL)
+ goto err;
+ //files[dev].acc_flags = uiop->uio_fmode;
+ if ((err = oss_create_uio (&uio, (void *)buffer, count, UIO_WRITE, 0)) < 0)
+ goto err;
+
+ err = cdev->d->write (cdev->instance, &cookie->file, &uio, count);
+ *_length = (err > 0) ? err : 0;
+ if (err < 0)
+ goto err;
+
+ *_length = err;
+ err = B_OK;
+ FEXITR(err);
+ return err;
+
+err:
+ *_length = 0;
+ FEXITR(err);
+ return err;
+}
+
+
+device_hooks oss_driver_hooks = {
+ &ossdrv_open,
+ &ossdrv_close,
+ (device_free_hook)&ossdrv_freecookie,
+ (device_control_hook)&ossdrv_ioctl,
+ (device_read_hook)&ossdrv_read,
+ (device_write_hook)&ossdrv_write,
+ /* Leave select/deselect/readv/writev undefined. The kernel will
+ * use its own default implementation. The basic hooks above this
+ * line MUST be defined, however. */
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/os_beos.h
oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/os_beos.h
--- oss-v4.1test0-070624-src-gpl.org/kernel/OS/BeOS/os_beos.h Thu Jan 1
01:00:00 1970
+++ oss-v4.1test0-070624-src-gpl/kernel/OS/BeOS/os_beos.h Wed Jun 27
02:57:36 2007
@@ -0,0 +1,456 @@
+#ifndef _OS_H_
+#define _OS_H_
+
+/*
+ * Purpose: OS specific definitions for BeOS/Haiku
+ *
+ */
+/*
+ *
+ * This file is part of Open Sound System.
+ *
+ * Copyright (C) 4Front Technologies 1996-2007.
+ *
+ * This this source file is released under GPL v2 license (no other versions).
+ * See the COPYING file included in the main directory of this source
+ * distribution. Please contact sales@xxxxxxxxxxxxx for further info.
+ *
+ */
+#define OS_VERSION "5"
+#define __inline__ inline
+#define __inline inline
+#define EXTERN_C extern "C"
+
+/*
+ * Debugging and misc settings
+ */
+#undef DO_TIMINGS
+#undef MUTEX_CHECKS
+#undef MEMDEBUG
+/* very verbose */
+//#define DO_DEBUG_FUNC_CALLS
+
+/*
+ * Disable support for per-application features such as /dev/dsp device
+ * selection based on command name. Requires working GET_PROCESS_NAME
+ * macro implementation.
+ */
+//Disable??
+#define APPLIST_SUPPORT
+#define USE_DEVICE_SUBDIRS
+
+#include <OS.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <errno.h>
+#include <sys/uio.h>
+#include <sys/fcntl.h>
+#ifdef __HAIKU__
+#include <poll.h>
+#endif
+//#include <sys/malloc.h>
+#include <malloc.h>
+
+
+#include <KernelExport.h>
+#include <Drivers.h>
+#include <PCI.h>
+
+#ifndef ENOTSUP
+#define ENOTSUP ENOSYS
+#endif
+
+#define OSS_CONTIG_AREA_NAME "OSS CONTIG MEM"
+#define OSS_PCI_AREA_NAME "OSS PCI MEM"
+#define OSS_WQ_SEM_NAME "OSS WAITQ: "
+
+//#define DEVICE_PREFIX "audio/oss/"
+#define DEVICE_PREFIX ""
+#define DEVICE_NAME_LEN (32+sizeof(DEVICE_PREFIX))
+
+#ifdef _KERNEL_MODE
+
+/* references to modules */
+extern pci_module_info *gPCI;
+
+#endif /* _KERNEL_MODE */
+
+/*
+ * Some integer types
+ */
+#if defined(amd64) || defined(sparc) // 64bit ? not yet
+typedef uint64 oss_native_word; /* Same as the address and status
register size */
+#else
+typedef uint32 oss_native_word; /* Same as the address and status
register size */
+#endif
+
+typedef uint64 oss_uint64_t; /* Unsigned 64 bit integer */
+typedef unsigned long offset_t;
+
+
+extern void oss_cmn_err (int level, char *format, ...);
+#define CE_CONT 0
+#define CE_NOTE 1
+#define CE_WARN 2
+#define CE_PANIC 3
+#define cmn_err oss_cmn_err
+
+//snooze(1000000); \
+
+#ifdef DO_DEBUG_FUNC_CALLS
+/* verbose debugging */
+#define FENTRY() \
+dprintf("oss>%s()\n", __FUNCTION__)
+#define FENTRYA(f,a...) \
+dprintf("oss>%s(" f ")\n", __FUNCTION__, a)
+#define FEXIT() \
+dprintf("oss<%s\n", __FUNCTION__)
+#define FEXITR(e) \
+dprintf("oss<%s returned 0x%08lx\n", __FUNCTION__, (uint32)e)
+#else
+#define FENTRY() {}
+#define FENTRYA(f,a...) {}
+#define FEXIT() {}
+#define FEXITR(e) {}
+#endif
+
+struct _dev_info_t
+{
+ //struct pci_dev *pcidev;
+ struct pci_info pciinfo; //XXX: ptr or not ???
+};
+typedef struct _dev_info_t dev_info_t;
+
+
+/*
+ * timeout wrappers
+ */
+#undef timeout
+#define timeout oss_timeout
+#undef untimeout
+#define untimeout oss_untimeout
+typedef int timeout_id_t;
+extern timeout_id_t oss_timeout (void (*func) (void *), void *arg,
+ unsigned long long ticks);
+extern void oss_untimeout (timeout_id_t id);
+
+#define uiomove oss_uiomove
+typedef enum uio_rw
+{ UIO_READ, UIO_WRITE } uio_rw_t;
+struct uio
+{
+ char *ptr;
+ int resid;
+ int kernel_space; /* Set if this uio points to a kernel space
buffer */
+ uio_rw_t rw;
+};
+typedef struct uio uio_t;
+extern int oss_uiomove (void *address, size_t nbytes, enum uio_rw rwflag,
+ uio_t * uio);
+extern int oss_create_uio (uio_t * uiop, char *buf, size_t count, uio_rw_t rw,
+ int is_kernel);
+
+
+
+/*
+ * Mutexes
+ */
+
+#ifdef MUTEX_CHECKS
+/* Debugging version */
+struct _oss_mutex_t
+{
+ spinlock lock;
+ thread_id owner;
+ char *file;
+ int line;
+ int busy_flags;
+#define CNTX_INTR 1
+#define CNTX_USER 2
+};
+
+typedef struct _oss_mutex_t oss_mutex_t;
+extern void debug_mutex_init (oss_mutex_t * mutex, char *file, int line);
+extern void debug_mutex_destroy (oss_mutex_t * mutex, char *file, int line);
+extern void debug_mutex_enter (oss_mutex_t * mutex, char *file, int line,
oss_native_word *flags);
+extern void debug_mutex_exit (oss_mutex_t * mutex, char *file, int line,
oss_native_word *flags);
+
+#define MUTEX_INIT(osdev, mutex, hier)
debug_mutex_init(&mutex, NULL, __FILE__, __LINE__)
+#define MUTEX_CLEANUP(mutex) debug_mutex_destroy(&mutex,
__FILE__, __LINE__)
+#define MUTEX_ENTER_IRQDISABLE(mutex, flags) debug_mutex_enter(&mutex,
__FILE__, __LINE__, &flags)
+#define MUTEX_ENTER(mutex, flags)
debug_mutex_enter(&mutex, __FILE__, __LINE__, NULL)
+#define MUTEX_EXIT_IRQRESTORE(mutex, flags) debug_mutex_exit(&mutex,
__FILE__, __LINE__, &flags)
+#define MUTEX_EXIT(mutex, flags)
debug_mutex_exit(&mutex, __FILE__, __LINE__, NULL)
+#else
+typedef spinlock oss_mutex_t;
+#define MUTEX_INIT(osdev, mutex, hier) { mutex = 0; }
+#define MUTEX_CLEANUP(mutex)
+#define MUTEX_ENTER_IRQDISABLE(mutex, flags) \
+{ \
+ flags = (oss_native_word) disable_interrupts(); \
+ acquire_spinlock(&(mutex)); \
+}
+#define MUTEX_ENTER(mutex, flags)
acquire_spinlock(&(mutex))
+#define MUTEX_EXIT_IRQRESTORE(mutex, flags) \
+{ \
+ release_spinlock(&(mutex)); \
+ restore_interrupts((cpu_status)(flags)); \
+}
+#define MUTEX_EXIT(mutex, flags)
release_spinlock(&(mutex))
+#endif
+
+/* The soundcard.h could be in a nonstandard place so include it here. */
+#include "soundcard.h"
+
+typedef struct udi_usb_devc udi_usb_devc;
+struct _oss_device_t
+{
+#ifdef NEEDED_FOR_DRIVERS
+ int instance;
+ void *devc;
+ char *name;
+#endif
+
+ int cardnum;
+ int dev_type;
+ int instance;
+ dev_info_t *dip;
+ int unloaded;
+ void *osid;
+ void *devc;
+ char *name;
+ char nick[16];
+ char modname[32];
+ char handle[32];
+ int num_audio_engines;
+ int num_audioplay, num_audiorec, num_audioduplex;
+ int num_mididevs;
+ int num_mixerdevs;
+
+ volatile int refcount; /* Nonzero means that the device is needed by
some other (virtual) driver. */
+
+/* Interrupts */
+
+ long irq; //XXX:init =-1
+ oss_tophalf_handler_t tophalf_handler;
+ oss_bottomhalf_handler_t bottomhalf_handler;
+ oss_mutex_t mutex;
+
+};
+
+/* XXX we'll deal with select() later */
+#undef ALLOW_SELECT
+/* BeOS doesn't support mmap. Haiku does, so FIXME someday */
+#undef ALLOW_BUFFER_MAPPING
+
+/*
+ * Sleep/wakeup
+ */
+
+#ifdef _KERNEL
+struct oss_wait_queue
+{
+//XXX:
+// oss_mutex_t mutex;
+ char name[32];
+ sem_id sem;
+ unsigned long flags;
+// struct selinfo poll_info;
+};
+#endif
+
+/* Busy wait routine */
+#define oss_udelay(d) spin((bigtime_t)d)
+
+
+/* usec time base */
+#undef HZ
+/* XXX: might need to be lower to handle casts to long */
+#define OSS_HZ 1000000
+
+/* System wall timer access */
+extern unsigned long oss_get_time (void);
+#define GET_JIFFIES() oss_get_time()
+
+
+/*
+ * INB() and OUTB() should be obvious. NOTE! The order of
+ * paratemeters of OUTB() is different than on some other
+ * operating systems.
+ */
+
+/* I/O Mapped devices */
+#define INB(o, p) gPCI->read_io_8(p)
+#define INW(o, p) gPCI->read_io_16(p)
+#define INL(o, p) gPCI->read_io_32(p)
+
+#define OUTB(o, v, p) gPCI->write_io_8(p,v)
+#define OUTW(o, v, p) gPCI->write_io_16(p,v)
+#define OUTL(o, v, p) gPCI->write_io_32(p,v)
+
+/* Memory Mapped devices */
+#define PCI_READB(osdev, addr) *(volatile unsigned char *)(addr)
+#define PCI_READW(osdev, addr) *(volatile unsigned short *)(addr)
+#define PCI_READL(osdev, addr) *(volatile unsigned int *)(addr)
+
+#define PCI_WRITEB(osdev, addr, data) *(volatile unsigned char *)(addr)=data
+#define PCI_WRITEW(osdev, addr, data) *(volatile unsigned short *)(addr)=data
+#define PCI_WRITEL(osdev, addr, data) *(volatile unsigned int *)(addr)=data
+
+/*
+ * When a error (such as EINVAL) is returned by a function,
+ * the following macro is used. The driver assumes that a
+ * error is signalled by returning a negative value.
+ */
+
+/*
+ KERNEL_MALLOC() allocates requested number of memory and
+ KERNEL_FREE is used to free it.
+ These macros are never called from interrupt, in addition the
+ nbytes will never be more than 4096 bytes. Generally the driver
+ will allocate memory in blocks of 4k. If the kernel has just a
+ page level memory allocation, 4K can be safely used as the size
+ (the nbytes parameter can be ignored).
+*/
+#define KERNEL_MALLOC(nbytes) malloc(nbytes)
+#define KERNEL_FREE(addr) {if (addr)free(addr);addr=NULL;}
+
+extern void *oss_contig_malloc (oss_device_t * osdev, int sz,
+ oss_uint64_t memlimit,
+ oss_native_word * phaddr);
+extern void oss_contig_free (oss_device_t * osdev, void *p, int sz);
+extern oss_native_word oss_virt_to_bus (void *addr);
+#define CONTIG_MALLOC(osdev, sz, memlimit, phaddr)
oss_contig_malloc(osdev, sz, memlimit, phaddr)
+#define CONTIG_FREE(osdev, p, sz) oss_contig_free(osdev, p, sz)
+
+/*
+ * PMALLOC is used to allocate memory that will get automatically freed when
+ * OSS unloads. Usable for per-instance structures allocated when OSS modules
+ * are being loaded.
+ */
+extern void *oss_pmalloc (size_t sz);
+
+#define PMALLOC(osdev, sz) oss_pmalloc(sz)
+
+/*
+ * Timer macros
+ *
+ * These macros are obsolete and should not be used in any new code.
+ * Use the timeout mechanism (see the timeout(9F) Solaris man page).
+ */
+#define DEFINE_TIMER(name, proc) static timeout_id_t name = 0
+#define REMOVE_TIMER(name, proc) {if (name != 0) untimeout(name);}
+#define INIT_TIMER(name,proc)
+typedef void (*timeout_func_t) (void *);
+#define ACTIVATE_TIMER(name, proc, time) \
+ name=timeout((timeout_func_t)proc, (void*)&name, time)
+#endif
+
+struct fileinfo
+{
+ int mode; /* Open mode */
+ int flags;
+ int acc_flags;
+};
+#define ISSET_FILE_FLAG(fileinfo, flag) (fileinfo->acc_flags & (flag) ? 1:0)
+
+#define OSS_OS "BeOS"
+#define OSS_OS_LONGNAME "BeOS R" OS_VERSION
+
+typedef void (*softintr_func_t) (int);
+
+struct oss_softintr
+{
+ int id;
+ softintr_func_t func;
+ volatile int armed, running;
+};
+
+struct _oss_poll_event_t
+{
+ short events, revents;
+ struct thread *p;
+ struct cdev *bsd_dev;
+};
+typedef struct _oss_poll_event_t oss_poll_event_t;
+#ifndef POLLIN
+/* events & revents - compatible with the B_SELECT_xxx definitions in
Drivers.h */
+#define POLLIN 0x0001 /* any readable data available */
+#define POLLOUT 0x0002 /* file descriptor is writeable */
+#define POLLRDNORM POLLIN
+#define POLLWRNORM POLLOUT
+#define POLLRDBAND 0x0008 /* priority readable data */
+#define POLLWRBAND 0x0010 /* priority data can be written */
+#define POLLPRI 0x0020 /* high priority readable data */
+#endif
+
+extern int detect_trace;
+#define DDB(x) if (detect_trace) x
+
+extern caddr_t oss_map_pci_mem (oss_device_t * osdev, int nr, int phaddr,
+ int size);
+extern void oss_unmap_pci_mem (void *addr);
+#define MAP_PCI_IOADDR(osdev, nr, io) (oss_native_word)io
+#define MAP_PCI_MEM(osdev, ix, phaddr, size) oss_map_pci_mem(osdev, ix,
phaddr, size)
+#define UNMAP_PCI_MEM(osdev, ph, virt, size) oss_unmap_pci_mem(virt)
+
+#define GET_PROCESS_PID(f) find_thread(NULL)
+#define GET_PROCESS_NAME(f) NULL
+
+#define abs(x) ((x) >= 0 ? (x) : -(x))
+
+/*
+ * PCI config space access (in os.c)
+ */
+extern char *oss_pci_read_devpath (dev_info_t * dip);
+
+
+/*
+ * Interface with the front-end driver
+ */
+extern status_t init_osscore (void);
+extern status_t uninit_osscore (void);
+extern status_t oss_probe_pci (void);
+extern status_t oss_load_drivers (void);
+extern status_t oss_unload_all_drivers (void);
+
+/*
+ * osscore module for use by low-level driver
+ */
+#define OSS_CORE_MODULE_NAME "media/oss/osscore/v1"
+#define OSS_MODULES_PREFIX "media/oss/drivers/"
+#define OSS_MODULES_SUFFIX "/v1"
+#define OSS_MAKE_DRV_MOD_NAME(nick) OSS_MODULES_PREFIX nick OSS_MODULES_SUFFIX
+typedef struct oss_drv_module_info {
+ module_info minfo;
+ int (*driver_probe)(void);
+ int (*driver_attach)(oss_device_t *osdev);
+ int (*driver_detach)(oss_device_t *osdev);
+} oss_drv_module_info;
+
+typedef struct oss_core_module_info {
+ module_info minfo;
+ status_t (*init_osscore) (void);
+ status_t (*uninit_osscore) (void);
+ const char **(*oss_publish_devices) (void);
+ device_hooks *(*oss_get_driver_hooks) (void);
+ status_t (*oss_probe_pci) (void);
+ status_t (*oss_load_drivers) (void);
+ status_t (*oss_unload_all_drivers) (void);
+} oss_core_module_info;
+extern oss_core_module_info *gOSSCore;
+
+//XXX: not yet
+#ifdef ASMODULES
+
+struct oss_core_module {
+ module_info minfo;
+ void (*oss_foo)(void);
+};
+extern struct oss_core_info *gOSSCore;
+#ifdef BUILDING_DRIVER
+ #define oss_foo gOSSCore->oss_foo
+#endif
+#endif /* ASMODULES */
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/OS/FreeBSD/os_freebsd.c
oss-v4.1test0-070624-src-gpl/kernel/OS/FreeBSD/os_freebsd.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/OS/FreeBSD/os_freebsd.c Sun Jun
24 18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/OS/FreeBSD/os_freebsd.c Tue Jun 26
22:19:34 2007
@@ -89,7 +89,7 @@
tmpbuf = CONTIG_MALLOC (dmap->osdev, size, maxaddr, &phaddr);
if (tmpbuf == NULL)
- return -ENOMEM;
+ return RETERR(ENOMEM);
dmap->dmabuf = tmpbuf;
dmap->buffsize = size;
dmap->dmabuf_phys = phaddr;
@@ -213,7 +213,7 @@
strcpy (osdev->name, name);
if (osdev->dip != NULL)
device_set_desc (osdev->dip, name);
- return -ENXIO;
+ return RETERR(ENXIO);
}
void
@@ -256,10 +256,10 @@
int i;
if (osdev->refcount > 0)
- return -EBUSY;
+ return RETERR(EBUSY);
if (open_devices > 0)
- return -EBUSY;
+ return RETERR(EBUSY);
for (i = 0; i < num_mixers; i++)
if (mixer_devs[i]->osdev == osdev)
@@ -293,7 +293,7 @@
*/
if (cardnum < 0 || cardnum >= oss_num_cards)
- return -ENXIO;
+ return RETERR(ENXIO);
if (cards[cardnum]->name != NULL)
strncpy (ci->longname, cards[cardnum]->name, 128);
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/OS/Linux/os_linux.c
oss-v4.1test0-070624-src-gpl/kernel/OS/Linux/os_linux.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/OS/Linux/os_linux.c Sun Jun 24
18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/OS/Linux/os_linux.c Tue Jun 26
22:19:34 2007
@@ -298,7 +298,7 @@
*/
if (osdev->refcount > 0)
{
- return -EBUSY;
+ return RETERR(EBUSY);
}
for (i = 0; i < num_mixers; i++)
@@ -374,7 +374,7 @@
*/
if (cardnum < 0 || cardnum >= oss_num_cards)
- return -ENXIO;
+ return RETERR(ENXIO);
if (cards[cardnum]->name != NULL)
strncpy (ci->longname, cards[cardnum]->name, 128);
@@ -406,7 +406,7 @@
if (dmap == NULL)
{
cmn_err (CE_WARN, "oss_alloc_dmabuf: dmap==NULL\n");
- return -EIO;
+ return RETERR(EIO);
}
/*
@@ -436,7 +436,7 @@
&phaddr)) == NULL)
{
if ((dmap->buffsize = (dmap->buffsize / 2)) < 8 * 1024)
- return -ENOMEM;
+ return RETERR(ENOMEM);
cmn_err (CE_CONT, "Dropping DMA buffer size to %d bytes.\n",
dmap->buffsize);
continue;
@@ -448,7 +448,7 @@
return 0;
}
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
void
@@ -493,9 +493,9 @@
oss_cdev_t *cdev;
if (dev > oss_num_cdevs)
- return -ENXIO;
+ return RETERR(ENXIO);
if ((cdev = oss_cdevs[dev]) == NULL || cdev->d == NULL)
- return -ENXIO;
+ return RETERR(ENXIO);
DDB (cmn_err
(CE_CONT, "oss_cdev_open(%d): %s, class=%d, instance=%d\n", dev,
@@ -503,7 +503,7 @@
if (cdev->d->open == NULL)
{
- return -ENODEV;
+ return RETERR(ENODEV);
}
dev_class = cdev->dev_class;
@@ -566,10 +566,10 @@
cpy_file (file, &fi);
if (dev > oss_num_cdevs)
- return -ENXIO;
+ return RETERR(ENXIO);
if ((cdev = oss_cdevs[dev]) == NULL || cdev->d->read == NULL)
{
- return -ENXIO;
+ return RETERR(ENXIO);
}
if ((err = oss_create_uio (&uio, buf, count, UIO_READ, 0)) < 0)
@@ -596,10 +596,10 @@
cpy_file (file, &fi);
if (dev > oss_num_cdevs)
- return -ENXIO;
+ return RETERR(ENXIO);
if ((cdev = oss_cdevs[dev]) == NULL || cdev->d->write == NULL)
{
- return -ENXIO;
+ return RETERR(ENXIO);
}
if ((err = oss_create_uio (&uio, buf, count, UIO_WRITE, 0)) < 0)
@@ -630,10 +630,10 @@
cpy_file (file, &fi);
if (dev > oss_num_cdevs)
- return -ENXIO;
+ return RETERR(ENXIO);
if ((cdev = oss_cdevs[dev]) == NULL || cdev->d->ioctl == NULL)
{
- return -ENXIO;
+ return RETERR(ENXIO);
}
if (__SIOC_DIR (cmd) != __SIOC_NONE && __SIOC_DIR (cmd) != 0)
@@ -642,7 +642,7 @@
if (len < 1 || len > 65536 || arg == 0)
{
cmn_err (CE_WARN, "Bad ioctl command %x, %d, %x\n", cmd, len, arg);
- return -EFAULT;
+ return RETERR(EFAULT);
}
/* Use statically allocated buffer for short arguments */
@@ -656,7 +656,7 @@
if (ptr == NULL || arg == 0)
{
- return -EFAULT;
+ return RETERR(EFAULT);
}
if (__SIOC_DIR (cmd) & __SIOC_WRITE)
@@ -665,7 +665,7 @@
{
if (alloced)
KERNEL_FREE (ptr);
- return -EFAULT;
+ return RETERR(EFAULT);
}
}
}
@@ -683,7 +683,7 @@
{
if (alloced)
KERNEL_FREE (ptr);
- return -EFAULT;
+ return RETERR(EFAULT);
}
}
@@ -709,10 +709,10 @@
cpy_file (file, &fi);
if (dev > oss_num_cdevs)
- return -ENXIO;
+ return RETERR(ENXIO);
if ((cdev = oss_cdevs[dev]) == NULL || cdev->d->chpoll == NULL)
{
- return -ENXIO;
+ return RETERR(ENXIO);
}
ev.wait = wait;
@@ -738,21 +738,21 @@
int err;
if (dev > oss_num_cdevs)
- return -ENXIO;
+ return RETERR(ENXIO);
if ((cdev = oss_cdevs[dev]) == NULL)
{
- return -ENXIO;
+ return RETERR(ENXIO);
}
if (cdev->dev_class != OSS_DEV_DSP && cdev->dev_class != OSS_DEV_DSP_ENGINE)
/* Only mmap audio devices */
{
- return -ENXIO;
+ return RETERR(ENXIO);
}
dev = cdev->instance;
if (dev < 0 || dev >= num_audio_engines)
- return -ENXIO;
+ return RETERR(ENXIO);
if (oss_vma_get_flags (vma) & VM_WRITE) /* Map write and read/write to
the output buf */
{
@@ -765,38 +765,38 @@
else
{
cmn_err (CE_WARN, "Undefined mmap() access\n");
- return -EINVAL;
+ return RETERR(EINVAL);
}
if (dmap == NULL)
{
cmn_err (CE_WARN, "mmap() error. dmap == NULL\n");
- return -EIO;
+ return RETERR(EIO);
}
if (dmap->dmabuf == NULL)
{
cmn_err (CE_WARN, "mmap() called when raw_buf == NULL\n");
- return -EIO;
+ return RETERR(EIO);
}
if (dmap->dmabuf_phys == 0)
{
cmn_err (CE_WARN, "mmap() not supported by device /dev/dsp%d.\n", dev);
- return -EIO;
+ return RETERR(EIO);
}
if (dmap->mapping_flags)
{
cmn_err (CE_WARN, "mmap() called twice for the same DMA buffer\n");
- return -EIO;
+ return RETERR(EIO);
}
if (dmap->flags & DMAP_COOKED)
{
cmn_err (CE_WARN,
"mmap() not possible with currently selected sample format.\n");
- return -EIO;
+ return RETERR(EIO);
}
if ((err = oss_do_mmap (vma, dmap->dmabuf_phys, dmap->bytes_in_use)) < 0)
@@ -930,7 +930,7 @@
{
cmn_err (CE_WARN, "Failed to allocate character major number %d\n",
osscore_major);
- return -EBUSY;
+ return RETERR(EBUSY);
}
osdev->major = osscore_major;
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/OS/SCO_SV/os_sco.c
oss-v4.1test0-070624-src-gpl/kernel/OS/SCO_SV/os_sco.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/OS/SCO_SV/os_sco.c Sun Jun 24
18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/OS/SCO_SV/os_sco.c Tue Jun 26
22:19:34 2007
@@ -236,7 +236,7 @@
if ((p =
oss_contig_malloc (audio_engines[dev]->osdev, size, maxaddr,
&phaddr)) == NULL)
- return -ENOMEM;
+ return RETERR(ENOMEM);
dmap->dmabuf = p;
dmap->dmabuf_phys = phaddr;
@@ -493,7 +493,7 @@
*/
if (cardnum < 0 || cardnum >= oss_num_cards)
- return -ENXIO;
+ return RETERR(ENXIO);
if (cards[cardnum]->name != NULL)
strncpy (ci->longname, cards[cardnum]->name, 128);
@@ -722,7 +722,7 @@
int i;
/*
* This routine should check if the device is ready to be unloaded (no devices
are in use).
- * If the device cannot be unloaded this routine must return -EBUSY.
+ * If the device cannot be unloaded this routine must return RETERR(EBUSY).
*
* If the device can be unloaded then disable any timers or other features
that may cause the
* device to be called. Also mark the audio/midi/mixer/etc devices of this
device to be disabled.
@@ -731,7 +731,7 @@
*/
if (osdev->refcount > 0)
{
- return -EBUSY;
+ return RETERR(EBUSY);
}
/*
@@ -818,26 +818,26 @@
{
cmn_err (CE_WARN, "Bad interrupt index (%d) for %s\n", intrnum,
osdev->name);
- return -EINVAL;
+ return RETERR(EINVAL);
}
if (osdev == NULL)
{
cmn_err (CE_WARN, "oss_register_interrupts: Bad osdev\n");
- return -EINVAL;
+ return RETERR(EINVAL);
}
if (osdev->tophalf_handler != NULL || osdev->bottomhalf_handler != NULL)
{
cmn_err (CE_WARN, "Interrupts already registered for %s\n",
osdev->name);
- return -EINVAL;
+ return RETERR(EINVAL);
}
if (top == NULL)
{
cmn_err (CE_WARN, "Bad interrupt handler for %s\n", osdev->name);
- return -EINVAL;
+ return RETERR(EINVAL);
}
osdev->tophalf_handler = top;
@@ -1013,13 +1013,13 @@
int i;
if (drvinfo_busy)
- return -EBUSY;
+ return RETERR(EBUSY);
drvinfo_busy = 1;
if ((drvinfo_buf = KERNEL_MALLOC (DRVINFO_SIZE)) == NULL)
{
cmn_err (CE_WARN, "Cannot allocate drvinfo buffer\n");
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
drvinfo_len = 0;
@@ -1067,7 +1067,7 @@
return 0;
if (uiomove (&drvinfo_buf[drvinfo_ptr], l, UIO_READ, buf) != 0)
- return -EFAULT;
+ return RETERR(EFAULT);
drvinfo_ptr += l;
return l;
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/OS/SunOS/os_solaris.c
oss-v4.1test0-070624-src-gpl/kernel/OS/SunOS/os_solaris.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/OS/SunOS/os_solaris.c Sun Jun
24 18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/OS/SunOS/os_solaris.c Tue Jun 26
22:19:34 2007
@@ -1499,7 +1499,7 @@
*/
if (cardnum < 0 || cardnum >= oss_num_cards)
- return -ENXIO;
+ return RETERR(ENXIO);
if (cards[cardnum]->name != NULL)
strncpy (ci->longname, cards[cardnum]->name, 128);
@@ -1668,19 +1668,19 @@
if (osdev == NULL)
{
cmn_err (CE_WARN, "oss_alloc_dmabuf: osdev==NULL\n");
- return -EIO;
+ return RETERR(EIO);
}
if (osdev->dip == NULL)
{
cmn_err (CE_WARN, "oss_alloc_dmabuf: osdev->dip==NULL\n");
- return -EIO;
+ return RETERR(EIO);
}
if (dmap == NULL)
{
cmn_err (CE_WARN, "oss_alloc_dmabuf: dmap==NULL\n");
- return -EIO;
+ return RETERR(EIO);
}
if ((err = ddi_dma_alloc_handle (osdev->dip,
@@ -1690,7 +1690,7 @@
&dmap->dma_parms.dhandle)) != DDI_SUCCESS)
{
cmn_err (CE_WARN, "Failed to allocate DMA handle (error %d)\n", err);
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
dmap->dmabuf = NULL;
@@ -1722,7 +1722,7 @@
if (!(alloc_flags & DMABUF_QUIET))
cmn_err (CE_WARN, "Can't allocate a DMA buffer for device %d\n", dev);
ddi_dma_free_handle (&dmap->dma_parms.dhandle);
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
dmap->buffsize = len;
@@ -1743,7 +1743,7 @@
{
cmn_err (CE_WARN, "DMA address setup failed (%d)\n", err);
- return -EIO;
+ return RETERR(EIO);
}
dmap->dmabuf =
@@ -1752,7 +1752,7 @@
desc = PMALLOC (osdev, sizeof (contig_desc));
if (desc == NULL)
- return -ENOMEM;
+ return RETERR(ENOMEM);
desc->osdev = osdev;
desc->next = NULL;
@@ -1843,26 +1843,26 @@
{
cmn_err (CE_WARN, "Bad interrupt index (%d) for %s\n", intrnum,
osdev->name);
- return -EINVAL;
+ return RETERR(EINVAL);
}
if (osdev == NULL)
{
cmn_err (CE_WARN, "oss_register_interrupts: Bad osdev\n");
- return -EINVAL;
+ return RETERR(EINVAL);
}
if (osdev->tophalf_handler != NULL || osdev->bottomhalf_handler != NULL)
{
cmn_err (CE_WARN, "Interrupts already registered for %s\n",
osdev->name);
- return -EINVAL;
+ return RETERR(EINVAL);
}
if (top == NULL)
{
cmn_err (CE_WARN, "Bad interrupt handler for %s\n", osdev->name);
- return -EINVAL;
+ return RETERR(EINVAL);
}
osdev->tophalf_handler = top;
@@ -1875,14 +1875,14 @@
cmn_err (CE_WARN,
"The driver for %s doesn't support hilevel interrupts\n",
osdev->name);
- return -EINVAL;
+ return RETERR(EINVAL);
}
DDB (cmn_err (CE_NOTE, "Using hilevel intr for %s\n", osdev->name));
/* TODO: Fix hilevel intr handling */
cmn_err (CE_WARN, "Hilevel interrupts are not supported yet.\n");
- return -EINVAL;
+ return RETERR(EINVAL);
}
else
{
@@ -1894,7 +1894,7 @@
oss_intr, (caddr_t) osdev)) != DDI_SUCCESS)
{
cmn_err (CE_WARN, "ddi_add_intr() failed, error=%d\n", err);
- return -EIO;
+ return RETERR(EIO);
}
return 0;
@@ -1930,7 +1930,7 @@
int i;
/*
* This routine should check if the device is ready to be unloaded (no devices
are in use).
- * If the device cannot be unloaded this routine must return -EBUSY.
+ * If the device cannot be unloaded this routine must return RETERR(EBUSY).
*
* If the device can be unloaded then disable any timers or other features
that may cause the
* device to be called. Also mark the audio/midi/mixer/etc devices of this
device to be disabled.
@@ -1941,7 +1941,7 @@
{
cmn_err (CE_CONT, "Refcount %d, open_devices %d\n", osdev->refcount,
open_devices);
- return -EBUSY;
+ return RETERR(EBUSY);
}
/*
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/OS/SunOS/udi.c
oss-v4.1test0-070624-src-gpl/kernel/OS/SunOS/udi.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/OS/SunOS/udi.c Tue Jun 12
14:22:35 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/OS/SunOS/udi.c Tue Jun 26 22:19:34 2007
@@ -391,7 +391,7 @@
usb_set_alt_if (usbdev->osdev->dip, inum, altset, USB_FLAGS_SLEEP,
NULL, 0)) != USB_SUCCESS)
{
- return -EIO;
+ return RETERR(EIO);
}
return 0;
@@ -532,7 +532,7 @@
if (usbdev == NULL)
{
cmn_err (CE_CONT, "udi_usb_snd_control_msg: usbdev==NULL\n");
- return -EFAULT;
+ return RETERR(EFAULT);
}
data = allocb_wait (len + 1, BPRI_HI, STR_NOSIG, NULL);
@@ -558,7 +558,7 @@
cmn_err (CE_CONT, "bRq %x, wIx %x, wVal %x, wLen %d\n", rq, index,
value, len);
freemsg (data);
- return -EIO;
+ return RETERR(EIO);
}
freemsg (data);
@@ -583,7 +583,7 @@
if (usbdev == NULL)
{
cmn_err (CE_CONT, "udi_usb_rcv_control_msg: usbdev==NULL\n");
- return -EFAULT;
+ return RETERR(EFAULT);
}
setup.bmRequestType = rqtype | USB_DEV_REQ_DEV_TO_HOST;
@@ -602,7 +602,7 @@
cmn_err (CE_NOTE, "usb_pipe_ctrl_xfer_wait read failed: %s (%s)\n",
usb_errstr (err), usb_cb_err (completion_reason));
freemsg (data);
- return -EIO;
+ return RETERR(EIO);
}
l = data->b_wptr - data->b_rptr;
@@ -944,7 +944,7 @@
{
cmn_err (CE_WARN, "allocb_wait (isoc) failed\n");
KERNEL_FREE (req);
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
if ((isoc_req = usb_alloc_isoc_req (req->dip, 1, 0, 0)) == NULL)
@@ -952,7 +952,7 @@
cmn_err (CE_WARN, "usb_alloc_isoc_req failed\n");
freemsg (req->data);
KERNEL_FREE (req);
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
req->isoc_req = isoc_req;
}
@@ -960,7 +960,7 @@
if (isoc_req == NULL)
{
cmn_err (CE_WARN, "req->isoc==NULL\n");
- return -EIO;
+ return RETERR(EIO);
}
memcpy (req->data->b_wptr, data, len);
@@ -982,7 +982,7 @@
{
cmn_err (CE_WARN, "usb_pipe_isoc_xfer failed (%s)\n",
usb_errstr (err));
- return -EIO;
+ return RETERR(EIO);
}
req->active = 1;
}
@@ -1002,7 +1002,7 @@
{
cmn_err (CE_WARN, "usb_alloc_isoc_req failed\n");
KERNEL_FREE (req);
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
req->isoc_req = isoc_req;
}
@@ -1010,7 +1010,7 @@
if (isoc_req == NULL)
{
cmn_err (CE_WARN, "req->isoc==NULL\n");
- return -EIO;
+ return RETERR(EIO);
}
isoc_req->isoc_attributes = USB_ATTRS_ISOC_XFER_ASAP;
@@ -1028,7 +1028,7 @@
{
cmn_err (CE_WARN, "usb_pipe_isoc_xfer failed (%s)\n",
usb_errstr (err));
- return -EIO;
+ return RETERR(EIO);
}
}
break;
@@ -1046,7 +1046,7 @@
{
cmn_err (CE_WARN, "allocb_wait (bulk) failed\n");
KERNEL_FREE (req);
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
if ((bulk_req = usb_alloc_bulk_req (req->dip, len, 0)) == NULL)
@@ -1054,7 +1054,7 @@
cmn_err (CE_WARN, "usb_alloc_bulk_req failed\n");
freemsg (req->data);
KERNEL_FREE (req);
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
req->bulk_req = bulk_req;
}
@@ -1062,7 +1062,7 @@
if (bulk_req == NULL)
{
cmn_err (CE_WARN, "req->bulk==NULL\n");
- return -EIO;
+ return RETERR(EIO);
}
memcpy (req->data->b_wptr, data, len);
@@ -1082,7 +1082,7 @@
{
cmn_err (CE_WARN, "usb_pipe_bulk_xfer failed (%s)\n",
usb_errstr (err));
- return -EIO;
+ return RETERR(EIO);
}
req->active = 1;
}
@@ -1102,7 +1102,7 @@
{
cmn_err (CE_WARN, "allocb_wait (bulk) failed\n");
KERNEL_FREE (req);
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
#endif
@@ -1112,7 +1112,7 @@
cmn_err (CE_WARN, "usb_alloc_bulk_req failed\n");
freemsg (req->data);
KERNEL_FREE (req);
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
req->bulk_req = bulk_req;
}
@@ -1120,7 +1120,7 @@
if (bulk_req == NULL)
{
cmn_err (CE_WARN, "req->bulk==NULL\n");
- return -EIO;
+ return RETERR(EIO);
}
bulk_req->bulk_attributes = USB_ATTRS_SHORT_XFER_OK;
@@ -1138,7 +1138,7 @@
{
cmn_err (CE_WARN, "usb_pipe_bulk_xfer failed (%s)\n",
usb_errstr (err));
- return -EIO;
+ return RETERR(EIO);
}
}
break;
@@ -1157,7 +1157,7 @@
{
cmn_err (CE_WARN, "allocb_wait (intr) failed\n");
KERNEL_FREE (req);
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
#endif
@@ -1167,7 +1167,7 @@
cmn_err (CE_WARN, "usb_alloc_intr_req failed\n");
freemsg (req->data);
KERNEL_FREE (req);
- return -ENOMEM;
+ return RETERR(ENOMEM);
}
req->intr_req = intr_req;
}
@@ -1175,7 +1175,7 @@
if (intr_req == NULL)
{
cmn_err (CE_WARN, "req->intr==NULL\n");
- return -EIO;
+ return RETERR(EIO);
}
intr_req->intr_attributes =
@@ -1194,14 +1194,14 @@
{
cmn_err (CE_WARN, "usb_pipe_intr_xfer failed (%s)\n",
usb_errstr (err));
- return -EIO;
+ return RETERR(EIO);
}
}
break;
default:
cmn_err (CE_WARN, "Unimplemented transfer type %d\n", xfer_type);
- return -EIO;
+ return RETERR(EIO);
}
return 0;
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/drv/ali5455/ali5455.c
oss-v4.1test0-070624-src-gpl/kernel/drv/ali5455/ali5455.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/drv/ali5455/ali5455.c Sun Jun
24 18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/drv/ali5455/ali5455.c Tue Jun 26
22:19:34 2007
@@ -380,7 +380,7 @@
static int
ALI_audio_ioctl (int dev, unsigned int cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static void ALI_audio_trigger (int dev, int state);
@@ -416,7 +416,7 @@
if (portc->open_mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
if (portc->port_type == DF_SPDIF)
@@ -426,7 +426,7 @@
cmn_err (CE_WARN,
"ICH: The S/PDIF device supports only playback\n");
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EIO;
+ return RETERR(EIO);
}
}
else
@@ -434,7 +434,7 @@
if (devc->open_mode & mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
devc->open_mode |= mode;
@@ -704,14 +704,14 @@
ALI_check_input (int dev)
{
cmn_err (CE_WARN, "OSS ALI: Input timed out.\n");
- return -EIO;
+ return RETERR(EIO);
}
static int
ALI_check_output (int dev)
{
cmn_err (CE_WARN, "OSS ALI: Output timed out\n");
- return -EIO;
+ return RETERR(EIO);
}
static const audiodrv_t ALI_audio_driver = {
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/drv/allegro/allegro.c
oss-v4.1test0-070624-src-gpl/kernel/drv/allegro/allegro.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/drv/allegro/allegro.c Sun Jun
24 18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/drv/allegro/allegro.c Tue Jun 26
22:19:35 2007
@@ -367,7 +367,7 @@
static int
allegro_audio_ioctl (int dev, unsigned int cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static void allegro_audio_trigger (int dev, int state);
@@ -403,13 +403,13 @@
if (portc->open_mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
if (devc->open_mode & mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
devc->open_mode |= mode;
@@ -690,7 +690,7 @@
}
if (!db->rawbuf)
- return -ENOMEM;
+ return RETERR(ENOMEM);
#ifdef linux
/* now mark the pages as reserved; otherwise remap_page_range doesn't do
what we want */
@@ -726,7 +726,7 @@
db->rawbuf = NULL;
return 0;
}
- return -EIO;
+ return RETERR(EIO);
}
static audiodrv_t allegro_audio_driver = {
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/drv/als300/als300.c
oss-v4.1test0-070624-src-gpl/kernel/drv/als300/als300.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/drv/als300/als300.c Sun Jun 24
18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/drv/als300/als300.c Tue Jun 26
22:19:35 2007
@@ -286,7 +286,7 @@
static int
als300_audio_ioctl (int dev, unsigned int cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static void als300_audio_trigger (int dev, int state);
@@ -322,13 +322,13 @@
if (portc->open_mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
if (devc->open_mode & mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
devc->open_mode |= mode;
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/drv/als4000/als4000.c
oss-v4.1test0-070624-src-gpl/kernel/drv/als4000/als4000.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/drv/als4000/als4000.c Sun Jun
24 18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/drv/als4000/als4000.c Tue Jun 26
22:19:35 2007
@@ -255,17 +255,17 @@
right = 100;
if (dev > 31)
- return -EINVAL;
+ return RETERR(EINVAL);
if (!(ALS4000_MIXER_DEVICES & (1 << dev))) /*
* Not supported
*/
- return -EINVAL;
+ return RETERR(EINVAL);
regoffs = als4000_mix[dev][LEFT_CHN].regno;
if (regoffs == 0)
- return -EINVAL;
+ return RETERR(EINVAL);
val = als4000_getmixer (devc, regoffs);
change_bits (devc, &val, dev, LEFT_CHN, left);
@@ -351,7 +351,7 @@
}
}
else
- return -EINVAL;
+ return RETERR(EINVAL);
}
@@ -550,7 +550,7 @@
static int
als4000_audio_ioctl (int dev, unsigned int cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static int
@@ -609,13 +609,13 @@
if (portc->open_mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
if (devc->open_mode & mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
devc->open_mode |= mode;
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/drv/apci97/apci97.c
oss-v4.1test0-070624-src-gpl/kernel/drv/apci97/apci97.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/drv/apci97/apci97.c Sun Jun 24
18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/drv/apci97/apci97.c Tue Jun 26
22:19:35 2007
@@ -541,7 +541,7 @@
static int
apci97_audio_ioctl (int dev, unsigned int cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static void apci97_audio_trigger (int dev, int state);
@@ -577,7 +577,7 @@
if (portc->open_mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
portc->open_mode = mode;
portc->audio_enabled = ~mode;
@@ -962,7 +962,7 @@
if (devc->midi_opened)
{
- return -EBUSY;
+ return RETERR(EBUSY);
}
devc->midi_input_intr = inputbyte;
@@ -1013,7 +1013,7 @@
static int
apci97_midi_ioctl (int dev, unsigned cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static midi_driver_t apci97_midi_driver = {
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/drv/atiaudio/atiaudio.c
oss-v4.1test0-070624-src-gpl/kernel/drv/atiaudio/atiaudio.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/drv/atiaudio/atiaudio.c Sun Jun
24 18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/drv/atiaudio/atiaudio.c Tue Jun 26
22:19:35 2007
@@ -98,7 +98,7 @@
if (!timeout--)
{
cmn_err (CE_WARN, "ATIIXP: codec ready timed out\n");
- return -EIO;
+ return RETERR(EIO);
}
oss_udelay (10);
}
@@ -121,7 +121,7 @@
{
cmn_err (CE_WARN, "ATI: ac97 not ready\n");
MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
- return -EIO;
+ return RETERR(EIO);
}
addr = (unsigned int) (reg << 9) | (1 << 8) | (1 << 2);
@@ -131,7 +131,7 @@
{
cmn_err (CE_WARN, "ATI: ac97 not ready\n");
MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
- return -EIO;
+ return RETERR(EIO);
}
timeout = 1000;
@@ -374,7 +374,7 @@
static int
ATI_audio_ioctl (int dev, unsigned int cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static void ATI_audio_trigger (int dev, int state);
@@ -410,7 +410,7 @@
if (portc->open_mode || (devc->open_mode & mode))
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
portc->open_mode = mode;
@@ -612,7 +612,7 @@
if (n > BDL_SIZE)
{
cmn_err (CE_WARN, "oss: Internal error - BDL too small\n");
- return -EIO;
+ return RETERR(EIO);
}
for (i = 0; i < n; i++)
@@ -708,7 +708,7 @@
if (n > BDL_SIZE)
{
cmn_err (CE_WARN, "oss: Internal error - BDL too small\n");
- return -EIO;
+ return RETERR(EIO);
}
for (i = 0; i < n; i++)
@@ -734,14 +734,14 @@
ATI_check_input (int dev)
{
cmn_err (CE_WARN, "OSS ATI: Input timed out.\n");
- return -EIO;
+ return RETERR(EIO);
}
static int
ATI_check_output (int dev)
{
cmn_err (CE_WARN, "OSS ATI: Output timed out\n");
- return -EIO;
+ return RETERR(EIO);
}
@@ -1024,7 +1024,11 @@
devc->membar_virt =
(char *) MAP_PCI_MEM (devc->osdev, 0, devc->membar_addr, 256);
-
+ if (devc->membar_virt == NULL)
+ {
+ cmn_err (CE_WARN, "ATIIXP: Cannot map pci mem\n");
+ return 0;
+ }
pci_command |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
pci_write_config_word (osdev, PCI_COMMAND, pci_command);
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/drv/audigyls/audigyls.c
oss-v4.1test0-070624-src-gpl/kernel/drv/audigyls/audigyls.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/drv/audigyls/audigyls.c Sun Jun
24 18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/drv/audigyls/audigyls.c Tue Jun 26
22:19:36 2007
@@ -240,7 +240,7 @@
if (i == 10000)
{
MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
- return -EIO;
+ return RETERR(EIO);
}
dtemp = INW (devc->osdev, devc->base + 0x1c);
MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
@@ -263,7 +263,7 @@
if (i == 10000)
{
MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
- return -EIO;
+ return RETERR(EIO);
}
OUTW (devc->osdev, wData, devc->base + 0x1c);
MUTEX_EXIT_IRQRESTORE (devc->low_mutex, flags);
@@ -441,7 +441,7 @@
static int
audigyls_ioctl (int dev, unsigned int cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static void audigyls_trigger (int dev, int state);
@@ -463,13 +463,13 @@
if (portc->open_mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
if (devc->open_mode & mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
devc->open_mode |= mode;
@@ -1001,7 +1001,7 @@
if (devc->midi_opened)
{
- return -EBUSY;
+ return RETERR(EBUSY);
}
while (input_avail (devc))
@@ -1069,7 +1069,7 @@
static int
audigylsuart_ioctl (int dev, unsigned cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static midi_driver_t audigyls_midi_driver = {
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/drv/audioloop/audioloop.c
oss-v4.1test0-070624-src-gpl/kernel/drv/audioloop/audioloop.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/drv/audioloop/audioloop.c Sun Jun
24 18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/drv/audioloop/audioloop.c Tue Jun
26 22:19:36 2007
@@ -174,7 +174,7 @@
audioloop_portc_t *portc = audio_engines[dev]->portc;
if (!portc->peer->output_triggered)
{
- return -ECONNRESET;
+ return RETERR(ECONNRESET);
}
return 0;
}
@@ -186,11 +186,11 @@
if (!portc->peer->input_triggered)
{
- return -ECONNRESET;
+ return RETERR(ECONNRESET);
}
if (portc->peer->open_mode == 0)
- return -EIO;
+ return RETERR(EIO);
return 0;
}
@@ -347,17 +347,17 @@
adev_t *adev;
if ((mode & OPEN_READ) && (mode & OPEN_WRITE))
- return -EACCES;
+ return RETERR(EACCES);
if (portc == NULL || portc->peer == NULL)
- return -ENXIO;
+ return RETERR(ENXIO);
MUTEX_ENTER_IRQDISABLE (devc->mutex, flags);
if (portc->open_mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
portc->open_mode = mode;
@@ -387,14 +387,14 @@
oss_native_word flags;
if (portc == NULL || portc->peer == NULL)
- return -ENXIO;
+ return RETERR(ENXIO);
MUTEX_ENTER_IRQDISABLE (devc->mutex, flags);
if (portc->open_mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
portc->open_mode = mode;
@@ -443,7 +443,7 @@
static int
audioloop_ioctl (int dev, unsigned int cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static void
@@ -526,7 +526,7 @@
if (status & WK_SIGNAL)
{
MUTEX_EXIT_IRQRESTORE (portc->mutex, flags);
- return -EINTR;
+ return RETERR(EINTR);
}
}
MUTEX_EXIT_IRQRESTORE (portc->mutex, flags);
@@ -558,7 +558,7 @@
if (status & WK_SIGNAL)
{
MUTEX_EXIT_IRQRESTORE (portc->mutex, flags);
- return -EINTR;
+ return RETERR(EINTR);
}
}
MUTEX_EXIT_IRQRESTORE (portc->mutex, flags);
@@ -623,7 +623,7 @@
dmap->dmabuf_phys = 0; /* Not mmap() capable */
dmap->dmabuf = KERNEL_MALLOC (MY_BUFFSIZE);
if (dmap->dmabuf == NULL)
- return -ENOSPC;
+ return RETERR(ENOSPC);
dmap->buffsize = MY_BUFFSIZE;
return 0;
@@ -716,7 +716,7 @@
ADEV_FIXEDRATE | ADEV_SPECIAL;
if ((portc = PMALLOC (devc->osdev, sizeof (*portc))) == NULL)
- return -ENOMEM;
+ return RETERR(ENOMEM);
memset (portc, 0, sizeof (*portc));
portc->devc = devc;
@@ -724,7 +724,7 @@
if ((portc->wq = oss_create_wait_queue (devc->osdev, "audioloop")) == NULL)
{
cmn_err (CE_WARN, "Cannot create audioloop wait queue\n");
- return -EIO;
+ return RETERR(EIO);
}
portc->instance = num;
@@ -777,14 +777,14 @@
ADEV_FIXEDRATE | ADEV_SPECIAL | ADEV_LOOP;
if ((portc = PMALLOC (devc->osdev, sizeof (*portc))) == NULL)
- return -ENOMEM;
+ return RETERR(ENOMEM);
memset (portc, 0, sizeof (*portc));
portc->devc = devc;
if ((portc->wq = oss_create_wait_queue (devc->osdev, "audioloop")) == NULL)
{
cmn_err (CE_WARN, "Cannot create audioloop wait queue\n");
- return -EIO;
+ return RETERR(EIO);
}
portc->instance = num;
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/drv/audiopci/audiopci.c
oss-v4.1test0-070624-src-gpl/kernel/drv/audiopci/audiopci.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/drv/audiopci/audiopci.c Sun Jun
24 18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/drv/audiopci/audiopci.c Tue Jun 26
22:19:36 2007
@@ -230,7 +230,7 @@
apci_mixer_get (apci_devc * devc, int dev)
{
if (!((1 << dev) & MIXER_DEVS))
- return -EINVAL;
+ return RETERR(EINVAL);
return devc->levels[dev];
}
@@ -246,10 +246,10 @@
unsigned char val;
if (dev > 31)
- return -EINVAL;
+ return RETERR(EINVAL);
if (!(MIXER_DEVS & (1 << dev)))
- return -EINVAL;
+ return RETERR(EINVAL);
if (left > 100)
left = 100;
@@ -272,7 +272,7 @@
#endif
if (ak_mix_devices[dev][LEFT_CHN].regno == 0xff)
- return -EINVAL;
+ return RETERR(EINVAL);
devc->levels[dev] = retvol;
@@ -365,7 +365,7 @@
}
}
else
- return -EINVAL;
+ return RETERR(EINVAL);
}
static int
@@ -460,7 +460,7 @@
break;
default:
- return -EINVAL;
+ return RETERR(EINVAL);
}
return value;
@@ -530,13 +530,13 @@
break;
default:
- return -EINVAL;
+ return RETERR(EINVAL);
}
return value;
}
- return -EINVAL;
+ return RETERR(EINVAL);
}
static int
@@ -800,7 +800,7 @@
static int
apci_audio_ioctl (int dev, unsigned int cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static void apci_audio_trigger (int dev, int state);
@@ -836,7 +836,7 @@
if (portc->open_mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
portc->open_mode = mode;
@@ -1216,7 +1216,7 @@
if (devc->midi_opened)
{
- return -EBUSY;
+ return RETERR(EBUSY);
}
devc->midi_input_intr = inputbyte;
@@ -1272,7 +1272,7 @@
static int
apci_midi_ioctl (int dev, unsigned cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static midi_driver_t apci_midi_driver = {
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/drv/cmi8788/cmi8788.c
oss-v4.1test0-070624-src-gpl/kernel/drv/cmi8788/cmi8788.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/drv/cmi8788/cmi8788.c Sun Jun
24 18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/drv/cmi8788/cmi8788.c Tue Jun 26
22:19:36 2007
@@ -291,7 +291,7 @@
if (status & 0x1)
{
cmn_err (CE_WARN, "Two-Wire interface busy\n");
- return -EIO;
+ return RETERR(EIO);
}
/* first write the Register Address into the MAP register */
@@ -452,7 +452,7 @@
static int
cmi8788_audio_ioctl (int dev, unsigned int cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
@@ -489,13 +489,13 @@
if (portc->open_mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
if (devc->open_mode & mode)
{
MUTEX_EXIT_IRQRESTORE (devc->mutex, flags);
- return -EBUSY;
+ return RETERR(EBUSY);
}
devc->open_mode |= mode;
@@ -1066,14 +1066,14 @@
cmi8788_check_input (int dev)
{
cmn_err (CE_WARN, "Input timed out on %s.\n", audio_engines[dev]->devnode);
- return -EIO;
+ return RETERR(EIO);
}
static int
cmi8788_check_output (int dev)
{
cmn_err (CE_WARN, "Output timed out on %s.\n", audio_engines[dev]->devnode);
- return -EIO;
+ return RETERR(EIO);
}
@@ -1217,7 +1217,7 @@
if (devc->midi_opened)
{
- return -EBUSY;
+ return RETERR(EBUSY);
}
while (input_avail (devc))
@@ -1285,7 +1285,7 @@
static int
cmi8788uart_ioctl (int dev, unsigned cmd, ioctl_arg arg)
{
- return -EINVAL;
+ return RETERR(EINVAL);
}
static midi_driver_t cmi8788_midi_driver = {
@@ -1544,7 +1544,7 @@
break;
default:
- return -EINVAL;
+ return RETERR(EINVAL);
}
return value;
@@ -1602,11 +1602,11 @@
break;
default:
- return -EINVAL;
+ return RETERR(EINVAL);
}
return (value);
}
- return -EINVAL;
+ return RETERR(EINVAL);
}
@@ -1817,7 +1817,7 @@
return (value);
}
- return -EINVAL;
+ return RETERR(EINVAL);
}
static int
diff -urN oss-v4.1test0-070624-src-gpl.org/kernel/drv/cmpci/cmpci.c
oss-v4.1test0-070624-src-gpl/kernel/drv/cmpci/cmpci.c
--- oss-v4.1test0-070624-src-gpl.org/kernel/drv/cmpci/cmpci.c Sun Jun 24
18:09:41 2007
+++ oss-v4.1test0-070624-src-gpl/kernel/drv/cmpci/cmpci.c Tue Jun 26
22:19:37 2007
@@ -414,17 +414,17 @@
right = 100;
if (chan > 31)
- return -EINVAL;
+ return RETERR(EINVAL);
if (!(CMEDIA_MIXER_DEVICES & (1 << chan))) /*
* Not supported
|