Path: blob/master/sound/oss/dmasound/dmasound_core.c
10817 views
/*1* linux/sound/oss/dmasound/dmasound_core.c2*3*4* OSS/Free compatible Atari TT/Falcon and Amiga DMA sound driver for5* Linux/m68k6* Extended to support Power Macintosh for Linux/ppc by Paul Mackerras7*8* (c) 1995 by Michael Schlueter & Michael Marte9*10* Michael Schlueter ([email protected]) did the basic structure of the VFS11* interface and the u-law to signed byte conversion.12*13* Michael Marte ([email protected]) did the sound queue,14* /dev/mixer, /dev/sndstat and complemented the VFS interface. He would like15* to thank:16* - Michael Schlueter for initial ideas and documentation on the MFP and17* the DMA sound hardware.18* - Therapy? for their CD 'Troublegum' which really made me rock.19*20* /dev/sndstat is based on code by Hannu Savolainen, the author of the21* VoxWare family of drivers.22*23* This file is subject to the terms and conditions of the GNU General Public24* License. See the file COPYING in the main directory of this archive25* for more details.26*27* History:28*29* 1995/8/25 First release30*31* 1995/9/02 Roman Hodek:32* - Fixed atari_stram_alloc() call, the timer33* programming and several race conditions34* 1995/9/14 Roman Hodek:35* - After some discussion with Michael Schlueter,36* revised the interrupt disabling37* - Slightly speeded up U8->S8 translation by using38* long operations where possible39* - Added 4:3 interpolation for /dev/audio40*41* 1995/9/20 Torsten Scherer:42* - Fixed a bug in sq_write and changed /dev/audio43* converting to play at 12517Hz instead of 6258Hz.44*45* 1995/9/23 Torsten Scherer:46* - Changed sq_interrupt() and sq_play() to pre-program47* the DMA for another frame while there's still one48* running. This allows the IRQ response to be49* arbitrarily delayed and playing will still continue.50*51* 1995/10/14 Guenther Kelleter, Torsten Scherer:52* - Better support for Falcon audio (the Falcon doesn't53* raise an IRQ at the end of a frame, but at the54* beginning instead!). uses 'if (codec_dma)' in lots55* of places to simply switch between Falcon and TT56* code.57*58* 1995/11/06 Torsten Scherer:59* - Started introducing a hardware abstraction scheme60* (may perhaps also serve for Amigas?)61* - Can now play samples at almost all frequencies by62* means of a more generalized expand routine63* - Takes a good deal of care to cut data only at64* sample sizes65* - Buffer size is now a kernel runtime option66* - Implemented fsync() & several minor improvements67* Guenther Kelleter:68* - Useful hints and bug fixes69* - Cross-checked it for Falcons70*71* 1996/3/9 Geert Uytterhoeven:72* - Support added for Amiga, A-law, 16-bit little73* endian.74* - Unification to drivers/sound/dmasound.c.75*76* 1996/4/6 Martin Mitchell:77* - Updated to 1.3 kernel.78*79* 1996/6/13 Topi Kanerva:80* - Fixed things that were broken (mainly the amiga81* 14-bit routines)82* - /dev/sndstat shows now the real hardware frequency83* - The lowpass filter is disabled by default now84*85* 1996/9/25 Geert Uytterhoeven:86* - Modularization87*88* 1998/6/10 Andreas Schwab:89* - Converted to use sound_core90*91* 1999/12/28 Richard Zidlicky:92* - Added support for Q4093*94* 2000/2/27 Geert Uytterhoeven:95* - Clean up and split the code into 4 parts:96* o dmasound_core: machine-independent code97* o dmasound_atari: Atari TT and Falcon support98* o dmasound_awacs: Apple PowerMac support99* o dmasound_paula: Amiga support100*101* 2000/3/25 Geert Uytterhoeven:102* - Integration of dmasound_q40103* - Small clean ups104*105* 2001/01/26 [1.0] Iain Sandoe106* - make /dev/sndstat show revision & edition info.107* - since dmasound.mach.sq_setup() can fail on pmac108* its type has been changed to int and the returns109* are checked.110* [1.1] - stop missing translations from being called.111* 2001/02/08 [1.2] - remove unused translation tables & move machine-112* specific tables to low-level.113* - return correct info. for SNDCTL_DSP_GETFMTS.114* [1.3] - implement SNDCTL_DSP_GETCAPS fully.115* [1.4] - make /dev/sndstat text length usage deterministic.116* - make /dev/sndstat call to low-level117* dmasound.mach.state_info() pass max space to ll driver.118* - tidy startup banners and output info.119* [1.5] - tidy up a little (removed some unused #defines in120* dmasound.h)121* - fix up HAS_RECORD conditionalisation.122* - add record code in places it is missing...123* - change buf-sizes to bytes to allow < 1kb for pmac124* if user param entry is < 256 the value is taken to125* be in kb > 256 is taken to be in bytes.126* - make default buff/frag params conditional on127* machine to allow smaller values for pmac.128* - made the ioctls, read & write comply with the OSS129* rules on setting params.130* - added parsing of _setup() params for record.131* 2001/04/04 [1.6] - fix bug where sample rates higher than maximum were132* being reported as OK.133* - fix open() to return -EBUSY as per OSS doc. when134* audio is in use - this is independent of O_NOBLOCK.135* - fix bug where SNDCTL_DSP_POST was blocking.136*/137138/* Record capability notes 30/01/2001:139* At present these observations apply only to pmac LL driver (the only one140* that can do record, at present). However, if other LL drivers for machines141* with record are added they may apply.142*143* The fragment parameters for the record and play channels are separate.144* However, if the driver is opened O_RDWR there is no way (in the current OSS145* API) to specify their values independently for the record and playback146* channels. Since the only common factor between the input & output is the147* sample rate (on pmac) it should be possible to open /dev/dspX O_WRONLY and148* /dev/dspY O_RDONLY. The input & output channels could then have different149* characteristics (other than the first that sets sample rate claiming the150* right to set it for ever). As it stands, the format, channels, number of151* bits & sample rate are assumed to be common. In the future perhaps these152* should be the responsibility of the LL driver - and then if a card really153* does not share items between record & playback they can be specified154* separately.155*/156157/* Thread-safeness of shared_resources notes: 31/01/2001158* If the user opens O_RDWR and then splits record & play between two threads159* both of which inherit the fd - and then starts changing things from both160* - we will have difficulty telling.161*162* It's bad application coding - but ...163* TODO: think about how to sort this out... without bogging everything down in164* semaphores.165*166* Similarly, the OSS spec says "all changes to parameters must be between167* open() and the first read() or write(). - and a bit later on (by168* implication) "between SNDCTL_DSP_RESET and the first read() or write() after169* it". If the app is multi-threaded and this rule is broken between threads170* we will have trouble spotting it - and the fault will be rather obscure :-(171*172* We will try and put out at least a kmsg if we see it happen... but I think173* it will be quite hard to trap it with an -EXXX return... because we can't174* see the fault until after the damage is done.175*/176177#include <linux/module.h>178#include <linux/slab.h>179#include <linux/sound.h>180#include <linux/init.h>181#include <linux/soundcard.h>182#include <linux/poll.h>183#include <linux/mutex.h>184185#include <asm/uaccess.h>186187#include "dmasound.h"188189#define DMASOUND_CORE_REVISION 1190#define DMASOUND_CORE_EDITION 6191192/*193* Declarations194*/195196static DEFINE_MUTEX(dmasound_core_mutex);197int dmasound_catchRadius = 0;198module_param(dmasound_catchRadius, int, 0);199200static unsigned int numWriteBufs = DEFAULT_N_BUFFERS;201module_param(numWriteBufs, int, 0);202static unsigned int writeBufSize = DEFAULT_BUFF_SIZE ; /* in bytes */203module_param(writeBufSize, int, 0);204205MODULE_LICENSE("GPL");206207#ifdef MODULE208static int sq_unit = -1;209static int mixer_unit = -1;210static int state_unit = -1;211static int irq_installed;212#endif /* MODULE */213214/* control over who can modify resources shared between play/record */215static fmode_t shared_resource_owner;216static int shared_resources_initialised;217218/*219* Mid level stuff220*/221222struct sound_settings dmasound = {223.lock = __SPIN_LOCK_UNLOCKED(dmasound.lock)224};225226static inline void sound_silence(void)227{228dmasound.mach.silence(); /* _MUST_ stop DMA */229}230231static inline int sound_set_format(int format)232{233return dmasound.mach.setFormat(format);234}235236237static int sound_set_speed(int speed)238{239if (speed < 0)240return dmasound.soft.speed;241242/* trap out-of-range speed settings.243at present we allow (arbitrarily) low rates - using soft244up-conversion - but we can't allow > max because there is245no soft down-conversion.246*/247if (dmasound.mach.max_dsp_speed &&248(speed > dmasound.mach.max_dsp_speed))249speed = dmasound.mach.max_dsp_speed ;250251dmasound.soft.speed = speed;252253if (dmasound.minDev == SND_DEV_DSP)254dmasound.dsp.speed = dmasound.soft.speed;255256return dmasound.soft.speed;257}258259static int sound_set_stereo(int stereo)260{261if (stereo < 0)262return dmasound.soft.stereo;263264stereo = !!stereo; /* should be 0 or 1 now */265266dmasound.soft.stereo = stereo;267if (dmasound.minDev == SND_DEV_DSP)268dmasound.dsp.stereo = stereo;269270return stereo;271}272273static ssize_t sound_copy_translate(TRANS *trans, const u_char __user *userPtr,274size_t userCount, u_char frame[],275ssize_t *frameUsed, ssize_t frameLeft)276{277ssize_t (*ct_func)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);278279switch (dmasound.soft.format) {280case AFMT_MU_LAW:281ct_func = trans->ct_ulaw;282break;283case AFMT_A_LAW:284ct_func = trans->ct_alaw;285break;286case AFMT_S8:287ct_func = trans->ct_s8;288break;289case AFMT_U8:290ct_func = trans->ct_u8;291break;292case AFMT_S16_BE:293ct_func = trans->ct_s16be;294break;295case AFMT_U16_BE:296ct_func = trans->ct_u16be;297break;298case AFMT_S16_LE:299ct_func = trans->ct_s16le;300break;301case AFMT_U16_LE:302ct_func = trans->ct_u16le;303break;304default:305return 0;306}307/* if the user has requested a non-existent translation don't try308to call it but just return 0 bytes moved309*/310if (ct_func)311return ct_func(userPtr, userCount, frame, frameUsed, frameLeft);312return 0;313}314315/*316* /dev/mixer abstraction317*/318319static struct {320int busy;321int modify_counter;322} mixer;323324static int mixer_open(struct inode *inode, struct file *file)325{326mutex_lock(&dmasound_core_mutex);327if (!try_module_get(dmasound.mach.owner)) {328mutex_unlock(&dmasound_core_mutex);329return -ENODEV;330}331mixer.busy = 1;332mutex_unlock(&dmasound_core_mutex);333return 0;334}335336static int mixer_release(struct inode *inode, struct file *file)337{338mutex_lock(&dmasound_core_mutex);339mixer.busy = 0;340module_put(dmasound.mach.owner);341mutex_unlock(&dmasound_core_mutex);342return 0;343}344345static int mixer_ioctl(struct file *file, u_int cmd, u_long arg)346{347if (_SIOC_DIR(cmd) & _SIOC_WRITE)348mixer.modify_counter++;349switch (cmd) {350case OSS_GETVERSION:351return IOCTL_OUT(arg, SOUND_VERSION);352case SOUND_MIXER_INFO:353{354mixer_info info;355memset(&info, 0, sizeof(info));356strlcpy(info.id, dmasound.mach.name2, sizeof(info.id));357strlcpy(info.name, dmasound.mach.name2, sizeof(info.name));358info.modify_counter = mixer.modify_counter;359if (copy_to_user((void __user *)arg, &info, sizeof(info)))360return -EFAULT;361return 0;362}363}364if (dmasound.mach.mixer_ioctl)365return dmasound.mach.mixer_ioctl(cmd, arg);366return -EINVAL;367}368369static long mixer_unlocked_ioctl(struct file *file, u_int cmd, u_long arg)370{371int ret;372373mutex_lock(&dmasound_core_mutex);374ret = mixer_ioctl(file, cmd, arg);375mutex_unlock(&dmasound_core_mutex);376377return ret;378}379380static const struct file_operations mixer_fops =381{382.owner = THIS_MODULE,383.llseek = no_llseek,384.unlocked_ioctl = mixer_unlocked_ioctl,385.open = mixer_open,386.release = mixer_release,387};388389static void mixer_init(void)390{391#ifndef MODULE392int mixer_unit;393#endif394mixer_unit = register_sound_mixer(&mixer_fops, -1);395if (mixer_unit < 0)396return;397398mixer.busy = 0;399dmasound.treble = 0;400dmasound.bass = 0;401if (dmasound.mach.mixer_init)402dmasound.mach.mixer_init();403}404405406/*407* Sound queue stuff, the heart of the driver408*/409410struct sound_queue dmasound_write_sq;411static void sq_reset_output(void) ;412413static int sq_allocate_buffers(struct sound_queue *sq, int num, int size)414{415int i;416417if (sq->buffers)418return 0;419sq->numBufs = num;420sq->bufSize = size;421sq->buffers = kmalloc (num * sizeof(char *), GFP_KERNEL);422if (!sq->buffers)423return -ENOMEM;424for (i = 0; i < num; i++) {425sq->buffers[i] = dmasound.mach.dma_alloc(size, GFP_KERNEL);426if (!sq->buffers[i]) {427while (i--)428dmasound.mach.dma_free(sq->buffers[i], size);429kfree(sq->buffers);430sq->buffers = NULL;431return -ENOMEM;432}433}434return 0;435}436437static void sq_release_buffers(struct sound_queue *sq)438{439int i;440441if (sq->buffers) {442for (i = 0; i < sq->numBufs; i++)443dmasound.mach.dma_free(sq->buffers[i], sq->bufSize);444kfree(sq->buffers);445sq->buffers = NULL;446}447}448449450static int sq_setup(struct sound_queue *sq)451{452int (*setup_func)(void) = NULL;453int hard_frame ;454455if (sq->locked) { /* are we already set? - and not changeable */456#ifdef DEBUG_DMASOUND457printk("dmasound_core: tried to sq_setup a locked queue\n") ;458#endif459return -EINVAL ;460}461sq->locked = 1 ; /* don't think we have a race prob. here _check_ */462463/* make sure that the parameters are set up464This should have been done already...465*/466467dmasound.mach.init();468469/* OK. If the user has set fragment parameters explicitly, then we470should leave them alone... as long as they are valid.471Invalid user fragment params can occur if we allow the whole buffer472to be used when the user requests the fragments sizes (with no soft473x-lation) and then the user subsequently sets a soft x-lation that474requires increased internal buffering.475476Othwerwise (if the user did not set them) OSS says that we should477select frag params on the basis of 0.5 s output & 0.1 s input478latency. (TODO. For now we will copy in the defaults.)479*/480481if (sq->user_frags <= 0) {482sq->max_count = sq->numBufs ;483sq->max_active = sq->numBufs ;484sq->block_size = sq->bufSize;485/* set up the user info */486sq->user_frags = sq->numBufs ;487sq->user_frag_size = sq->bufSize ;488sq->user_frag_size *=489(dmasound.soft.size * (dmasound.soft.stereo+1) ) ;490sq->user_frag_size /=491(dmasound.hard.size * (dmasound.hard.stereo+1) ) ;492} else {493/* work out requested block size */494sq->block_size = sq->user_frag_size ;495sq->block_size *=496(dmasound.hard.size * (dmasound.hard.stereo+1) ) ;497sq->block_size /=498(dmasound.soft.size * (dmasound.soft.stereo+1) ) ;499/* the user wants to write frag-size chunks */500sq->block_size *= dmasound.hard.speed ;501sq->block_size /= dmasound.soft.speed ;502/* this only works for size values which are powers of 2 */503hard_frame =504(dmasound.hard.size * (dmasound.hard.stereo+1))/8 ;505sq->block_size += (hard_frame - 1) ;506sq->block_size &= ~(hard_frame - 1) ; /* make sure we are aligned */507/* let's just check for obvious mistakes */508if ( sq->block_size <= 0 || sq->block_size > sq->bufSize) {509#ifdef DEBUG_DMASOUND510printk("dmasound_core: invalid frag size (user set %d)\n", sq->user_frag_size) ;511#endif512sq->block_size = sq->bufSize ;513}514if ( sq->user_frags <= sq->numBufs ) {515sq->max_count = sq->user_frags ;516/* if user has set max_active - then use it */517sq->max_active = (sq->max_active <= sq->max_count) ?518sq->max_active : sq->max_count ;519} else {520#ifdef DEBUG_DMASOUND521printk("dmasound_core: invalid frag count (user set %d)\n", sq->user_frags) ;522#endif523sq->max_count =524sq->max_active = sq->numBufs ;525}526}527sq->front = sq->count = sq->rear_size = 0;528sq->syncing = 0;529sq->active = 0;530531if (sq == &write_sq) {532sq->rear = -1;533setup_func = dmasound.mach.write_sq_setup;534}535if (setup_func)536return setup_func();537return 0 ;538}539540static inline void sq_play(void)541{542dmasound.mach.play();543}544545static ssize_t sq_write(struct file *file, const char __user *src, size_t uLeft,546loff_t *ppos)547{548ssize_t uWritten = 0;549u_char *dest;550ssize_t uUsed = 0, bUsed, bLeft;551unsigned long flags ;552553/* ++TeSche: Is something like this necessary?554* Hey, that's an honest question! Or does any other part of the555* filesystem already checks this situation? I really don't know.556*/557if (uLeft == 0)558return 0;559560/* implement any changes we have made to the soft/hard params.561this is not satisfactory really, all we have done up to now is to562say what we would like - there hasn't been any real checking of capability563*/564565if (shared_resources_initialised == 0) {566dmasound.mach.init() ;567shared_resources_initialised = 1 ;568}569570/* set up the sq if it is not already done. This may seem a dumb place571to do it - but it is what OSS requires. It means that write() can572return memory allocation errors. To avoid this possibility use the573GETBLKSIZE or GETOSPACE ioctls (after you've fiddled with all the574params you want to change) - these ioctls also force the setup.575*/576577if (write_sq.locked == 0) {578if ((uWritten = sq_setup(&write_sq)) < 0) return uWritten ;579uWritten = 0 ;580}581582/* FIXME: I think that this may be the wrong behaviour when we get strapped583for time and the cpu is close to being (or actually) behind in sending data.584- because we've lost the time that the N samples, already in the buffer,585would have given us to get here with the next lot from the user.586*/587/* The interrupt doesn't start to play the last, incomplete frame.588* Thus we can append to it without disabling the interrupts! (Note589* also that write_sq.rear isn't affected by the interrupt.)590*/591592/* as of 1.6 this behaviour changes if SNDCTL_DSP_POST has been issued:593this will mimic the behaviour of syncing and allow the sq_play() to594queue a partial fragment. Since sq_play() may/will be called from595the IRQ handler - at least on Pmac we have to deal with it.596The strategy - possibly not optimum - is to kill _POST status if we597get here. This seems, at least, reasonable - in the sense that POST598is supposed to indicate that we might not write before the queue599is drained - and if we get here in time then it does not apply.600*/601602spin_lock_irqsave(&dmasound.lock, flags);603write_sq.syncing &= ~2 ; /* take out POST status */604spin_unlock_irqrestore(&dmasound.lock, flags);605606if (write_sq.count > 0 &&607(bLeft = write_sq.block_size-write_sq.rear_size) > 0) {608dest = write_sq.buffers[write_sq.rear];609bUsed = write_sq.rear_size;610uUsed = sound_copy_translate(dmasound.trans_write, src, uLeft,611dest, &bUsed, bLeft);612if (uUsed <= 0)613return uUsed;614src += uUsed;615uWritten += uUsed;616uLeft = (uUsed <= uLeft) ? (uLeft - uUsed) : 0 ; /* paranoia */617write_sq.rear_size = bUsed;618}619620while (uLeft) {621while (write_sq.count >= write_sq.max_active) {622sq_play();623if (write_sq.non_blocking)624return uWritten > 0 ? uWritten : -EAGAIN;625SLEEP(write_sq.action_queue);626if (signal_pending(current))627return uWritten > 0 ? uWritten : -EINTR;628}629630/* Here, we can avoid disabling the interrupt by first631* copying and translating the data, and then updating632* the write_sq variables. Until this is done, the interrupt633* won't see the new frame and we can work on it634* undisturbed.635*/636637dest = write_sq.buffers[(write_sq.rear+1) % write_sq.max_count];638bUsed = 0;639bLeft = write_sq.block_size;640uUsed = sound_copy_translate(dmasound.trans_write, src, uLeft,641dest, &bUsed, bLeft);642if (uUsed <= 0)643break;644src += uUsed;645uWritten += uUsed;646uLeft = (uUsed <= uLeft) ? (uLeft - uUsed) : 0 ; /* paranoia */647if (bUsed) {648write_sq.rear = (write_sq.rear+1) % write_sq.max_count;649write_sq.rear_size = bUsed;650write_sq.count++;651}652} /* uUsed may have been 0 */653654sq_play();655656return uUsed < 0? uUsed: uWritten;657}658659static unsigned int sq_poll(struct file *file, struct poll_table_struct *wait)660{661unsigned int mask = 0;662int retVal;663664if (write_sq.locked == 0) {665if ((retVal = sq_setup(&write_sq)) < 0)666return retVal;667return 0;668}669if (file->f_mode & FMODE_WRITE )670poll_wait(file, &write_sq.action_queue, wait);671if (file->f_mode & FMODE_WRITE)672if (write_sq.count < write_sq.max_active || write_sq.block_size - write_sq.rear_size > 0)673mask |= POLLOUT | POLLWRNORM;674return mask;675676}677678static inline void sq_init_waitqueue(struct sound_queue *sq)679{680init_waitqueue_head(&sq->action_queue);681init_waitqueue_head(&sq->open_queue);682init_waitqueue_head(&sq->sync_queue);683sq->busy = 0;684}685686#if 0 /* blocking open() */687static inline void sq_wake_up(struct sound_queue *sq, struct file *file,688fmode_t mode)689{690if (file->f_mode & mode) {691sq->busy = 0; /* CHECK: IS THIS OK??? */692WAKE_UP(sq->open_queue);693}694}695#endif696697static int sq_open2(struct sound_queue *sq, struct file *file, fmode_t mode,698int numbufs, int bufsize)699{700int rc = 0;701702if (file->f_mode & mode) {703if (sq->busy) {704#if 0 /* blocking open() */705rc = -EBUSY;706if (file->f_flags & O_NONBLOCK)707return rc;708rc = -EINTR;709while (sq->busy) {710SLEEP(sq->open_queue);711if (signal_pending(current))712return rc;713}714rc = 0;715#else716/* OSS manual says we will return EBUSY regardless717of O_NOBLOCK.718*/719return -EBUSY ;720#endif721}722sq->busy = 1; /* Let's play spot-the-race-condition */723724/* allocate the default number & size of buffers.725(i.e. specified in _setup() or as module params)726can't be changed at the moment - but _could_ be perhaps727in the setfragments ioctl.728*/729if (( rc = sq_allocate_buffers(sq, numbufs, bufsize))) {730#if 0 /* blocking open() */731sq_wake_up(sq, file, mode);732#else733sq->busy = 0 ;734#endif735return rc;736}737738sq->non_blocking = file->f_flags & O_NONBLOCK;739}740return rc;741}742743#define write_sq_init_waitqueue() sq_init_waitqueue(&write_sq)744#if 0 /* blocking open() */745#define write_sq_wake_up(file) sq_wake_up(&write_sq, file, FMODE_WRITE)746#endif747#define write_sq_release_buffers() sq_release_buffers(&write_sq)748#define write_sq_open(file) \749sq_open2(&write_sq, file, FMODE_WRITE, numWriteBufs, writeBufSize )750751static int sq_open(struct inode *inode, struct file *file)752{753int rc;754755mutex_lock(&dmasound_core_mutex);756if (!try_module_get(dmasound.mach.owner)) {757mutex_unlock(&dmasound_core_mutex);758return -ENODEV;759}760761rc = write_sq_open(file); /* checks the f_mode */762if (rc)763goto out;764if (file->f_mode & FMODE_READ) {765/* TODO: if O_RDWR, release any resources grabbed by write part */766rc = -ENXIO ; /* I think this is what is required by open(2) */767goto out;768}769770if (dmasound.mach.sq_open)771dmasound.mach.sq_open(file->f_mode);772773/* CHECK whether this is sensible - in the case that dsp0 could be opened774O_RDONLY and dsp1 could be opened O_WRONLY775*/776777dmasound.minDev = iminor(inode) & 0x0f;778779/* OK. - we should make some attempt at consistency. At least the H'ware780options should be set with a valid mode. We will make it that the LL781driver must supply defaults for hard & soft params.782*/783784if (shared_resource_owner == 0) {785/* you can make this AFMT_U8/mono/8K if you want to mimic old786OSS behaviour - while we still have soft translations ;-) */787dmasound.soft = dmasound.mach.default_soft ;788dmasound.dsp = dmasound.mach.default_soft ;789dmasound.hard = dmasound.mach.default_hard ;790}791792#ifndef DMASOUND_STRICT_OSS_COMPLIANCE793/* none of the current LL drivers can actually do this "native" at the moment794OSS does not really require us to supply /dev/audio if we can't do it.795*/796if (dmasound.minDev == SND_DEV_AUDIO) {797sound_set_speed(8000);798sound_set_stereo(0);799sound_set_format(AFMT_MU_LAW);800}801#endif802mutex_unlock(&dmasound_core_mutex);803return 0;804out:805module_put(dmasound.mach.owner);806mutex_unlock(&dmasound_core_mutex);807return rc;808}809810static void sq_reset_output(void)811{812sound_silence(); /* this _must_ stop DMA, we might be about to lose the buffers */813write_sq.active = 0;814write_sq.count = 0;815write_sq.rear_size = 0;816/* write_sq.front = (write_sq.rear+1) % write_sq.max_count;*/817write_sq.front = 0 ;818write_sq.rear = -1 ; /* same as for set-up */819820/* OK - we can unlock the parameters and fragment settings */821write_sq.locked = 0 ;822write_sq.user_frags = 0 ;823write_sq.user_frag_size = 0 ;824}825826static void sq_reset(void)827{828sq_reset_output() ;829/* we could consider resetting the shared_resources_owner here... but I830think it is probably still rather non-obvious to application writer831*/832833/* we release everything else though */834shared_resources_initialised = 0 ;835}836837static int sq_fsync(struct file *filp, struct dentry *dentry)838{839int rc = 0;840int timeout = 5;841842write_sq.syncing |= 1;843sq_play(); /* there may be an incomplete frame waiting */844845while (write_sq.active) {846SLEEP(write_sq.sync_queue);847if (signal_pending(current)) {848/* While waiting for audio output to drain, an849* interrupt occurred. Stop audio output immediately850* and clear the queue. */851sq_reset_output();852rc = -EINTR;853break;854}855if (!--timeout) {856printk(KERN_WARNING "dmasound: Timeout draining output\n");857sq_reset_output();858rc = -EIO;859break;860}861}862863/* flag no sync regardless of whether we had a DSP_POST or not */864write_sq.syncing = 0 ;865return rc;866}867868static int sq_release(struct inode *inode, struct file *file)869{870int rc = 0;871872mutex_lock(&dmasound_core_mutex);873874if (file->f_mode & FMODE_WRITE) {875if (write_sq.busy)876rc = sq_fsync(file, file->f_path.dentry);877878sq_reset_output() ; /* make sure dma is stopped and all is quiet */879write_sq_release_buffers();880write_sq.busy = 0;881}882883if (file->f_mode & shared_resource_owner) { /* it's us that has them */884shared_resource_owner = 0 ;885shared_resources_initialised = 0 ;886dmasound.hard = dmasound.mach.default_hard ;887}888889module_put(dmasound.mach.owner);890891#if 0 /* blocking open() */892/* Wake up a process waiting for the queue being released.893* Note: There may be several processes waiting for a call894* to open() returning. */895896/* Iain: hmm I don't understand this next comment ... */897/* There is probably a DOS atack here. They change the mode flag. */898/* XXX add check here,*/899read_sq_wake_up(file); /* checks f_mode */900write_sq_wake_up(file); /* checks f_mode */901#endif /* blocking open() */902903mutex_unlock(&dmasound_core_mutex);904905return rc;906}907908/* here we see if we have a right to modify format, channels, size and so on909if no-one else has claimed it already then we do...910911TODO: We might change this to mask O_RDWR such that only one or the other channel912is the owner - if we have problems.913*/914915static int shared_resources_are_mine(fmode_t md)916{917if (shared_resource_owner)918return (shared_resource_owner & md) != 0;919else {920shared_resource_owner = md ;921return 1 ;922}923}924925/* if either queue is locked we must deny the right to change shared params926*/927928static int queues_are_quiescent(void)929{930if (write_sq.locked)931return 0 ;932return 1 ;933}934935/* check and set a queue's fragments per user's wishes...936we will check against the pre-defined literals and the actual sizes.937This is a bit fraught - because soft translations can mess with our938buffer requirements *after* this call - OSS says "call setfrags first"939*/940941/* It is possible to replace all the -EINVAL returns with an override that942just puts the allowable value in. This may be what many OSS apps require943*/944945static int set_queue_frags(struct sound_queue *sq, int bufs, int size)946{947if (sq->locked) {948#ifdef DEBUG_DMASOUND949printk("dmasound_core: tried to set_queue_frags on a locked queue\n") ;950#endif951return -EINVAL ;952}953954if ((size < MIN_FRAG_SIZE) || (size > MAX_FRAG_SIZE))955return -EINVAL ;956size = (1<<size) ; /* now in bytes */957if (size > sq->bufSize)958return -EINVAL ; /* this might still not work */959960if (bufs <= 0)961return -EINVAL ;962if (bufs > sq->numBufs) /* the user is allowed say "don't care" with 0x7fff */963bufs = sq->numBufs ;964965/* there is, currently, no way to specify max_active separately966from max_count. This could be a LL driver issue - I guess967if there is a requirement for these values to be different then968we will have to pass that info. up to this level.969*/970sq->user_frags =971sq->max_active = bufs ;972sq->user_frag_size = size ;973974return 0 ;975}976977static int sq_ioctl(struct file *file, u_int cmd, u_long arg)978{979int val, result;980u_long fmt;981int data;982int size, nbufs;983audio_buf_info info;984985switch (cmd) {986case SNDCTL_DSP_RESET:987sq_reset();988return 0;989break ;990case SNDCTL_DSP_GETFMTS:991fmt = dmasound.mach.hardware_afmts ; /* this is what OSS says.. */992return IOCTL_OUT(arg, fmt);993break ;994case SNDCTL_DSP_GETBLKSIZE:995/* this should tell the caller about bytes that the app can996read/write - the app doesn't care about our internal buffers.997We force sq_setup() here as per OSS 1.1 (which should998compute the values necessary).999Since there is no mechanism to specify read/write separately, for1000fds opened O_RDWR, the write_sq values will, arbitrarily, overwrite1001the read_sq ones.1002*/1003size = 0 ;1004if (file->f_mode & FMODE_WRITE) {1005if ( !write_sq.locked )1006sq_setup(&write_sq) ;1007size = write_sq.user_frag_size ;1008}1009return IOCTL_OUT(arg, size);1010break ;1011case SNDCTL_DSP_POST:1012/* all we are going to do is to tell the LL that any1013partial frags can be queued for output.1014The LL will have to clear this flag when last output1015is queued.1016*/1017write_sq.syncing |= 0x2 ;1018sq_play() ;1019return 0 ;1020case SNDCTL_DSP_SYNC:1021/* This call, effectively, has the same behaviour as SNDCTL_DSP_RESET1022except that it waits for output to finish before resetting1023everything - read, however, is killed immediately.1024*/1025result = 0 ;1026if (file->f_mode & FMODE_WRITE) {1027result = sq_fsync(file, file->f_path.dentry);1028sq_reset_output() ;1029}1030/* if we are the shared resource owner then release them */1031if (file->f_mode & shared_resource_owner)1032shared_resources_initialised = 0 ;1033return result ;1034break ;1035case SOUND_PCM_READ_RATE:1036return IOCTL_OUT(arg, dmasound.soft.speed);1037case SNDCTL_DSP_SPEED:1038/* changing this on the fly will have weird effects on the sound.1039Where there are rate conversions implemented in soft form - it1040will cause the _ctx_xxx() functions to be substituted.1041However, there doesn't appear to be any reason to dis-allow it from1042a driver pov.1043*/1044if (shared_resources_are_mine(file->f_mode)) {1045IOCTL_IN(arg, data);1046data = sound_set_speed(data) ;1047shared_resources_initialised = 0 ;1048return IOCTL_OUT(arg, data);1049} else1050return -EINVAL ;1051break ;1052/* OSS says these next 4 actions are undefined when the device is1053busy/active - we will just return -EINVAL.1054To be allowed to change one - (a) you have to own the right1055(b) the queue(s) must be quiescent1056*/1057case SNDCTL_DSP_STEREO:1058if (shared_resources_are_mine(file->f_mode) &&1059queues_are_quiescent()) {1060IOCTL_IN(arg, data);1061shared_resources_initialised = 0 ;1062return IOCTL_OUT(arg, sound_set_stereo(data));1063} else1064return -EINVAL ;1065break ;1066case SOUND_PCM_WRITE_CHANNELS:1067if (shared_resources_are_mine(file->f_mode) &&1068queues_are_quiescent()) {1069IOCTL_IN(arg, data);1070/* the user might ask for 20 channels, we will return 1 or 2 */1071shared_resources_initialised = 0 ;1072return IOCTL_OUT(arg, sound_set_stereo(data-1)+1);1073} else1074return -EINVAL ;1075break ;1076case SNDCTL_DSP_SETFMT:1077if (shared_resources_are_mine(file->f_mode) &&1078queues_are_quiescent()) {1079int format;1080IOCTL_IN(arg, data);1081shared_resources_initialised = 0 ;1082format = sound_set_format(data);1083result = IOCTL_OUT(arg, format);1084if (result < 0)1085return result;1086if (format != data && data != AFMT_QUERY)1087return -EINVAL;1088return 0;1089} else1090return -EINVAL ;1091case SNDCTL_DSP_SUBDIVIDE:1092return -EINVAL ;1093case SNDCTL_DSP_SETFRAGMENT:1094/* we can do this independently for the two queues - with the1095proviso that for fds opened O_RDWR we cannot separate the1096actions and both queues will be set per the last call.1097NOTE: this does *NOT* actually set the queue up - merely1098registers our intentions.1099*/1100IOCTL_IN(arg, data);1101result = 0 ;1102nbufs = (data >> 16) & 0x7fff ; /* 0x7fff is 'use maximum' */1103size = data & 0xffff;1104if (file->f_mode & FMODE_WRITE) {1105result = set_queue_frags(&write_sq, nbufs, size) ;1106if (result)1107return result ;1108}1109/* NOTE: this return value is irrelevant - OSS specifically says that1110the value is 'random' and that the user _must_ check the actual1111frags values using SNDCTL_DSP_GETBLKSIZE or similar */1112return IOCTL_OUT(arg, data);1113break ;1114case SNDCTL_DSP_GETOSPACE:1115/*1116*/1117if (file->f_mode & FMODE_WRITE) {1118if ( !write_sq.locked )1119sq_setup(&write_sq) ;1120info.fragments = write_sq.max_active - write_sq.count;1121info.fragstotal = write_sq.max_active;1122info.fragsize = write_sq.user_frag_size;1123info.bytes = info.fragments * info.fragsize;1124if (copy_to_user((void __user *)arg, &info, sizeof(info)))1125return -EFAULT;1126return 0;1127} else1128return -EINVAL ;1129break ;1130case SNDCTL_DSP_GETCAPS:1131val = dmasound.mach.capabilities & 0xffffff00;1132return IOCTL_OUT(arg,val);11331134default:1135return mixer_ioctl(file, cmd, arg);1136}1137return -EINVAL;1138}11391140static long sq_unlocked_ioctl(struct file *file, u_int cmd, u_long arg)1141{1142int ret;11431144mutex_lock(&dmasound_core_mutex);1145ret = sq_ioctl(file, cmd, arg);1146mutex_unlock(&dmasound_core_mutex);11471148return ret;1149}11501151static const struct file_operations sq_fops =1152{1153.owner = THIS_MODULE,1154.llseek = no_llseek,1155.write = sq_write,1156.poll = sq_poll,1157.unlocked_ioctl = sq_unlocked_ioctl,1158.open = sq_open,1159.release = sq_release,1160};11611162static int sq_init(void)1163{1164const struct file_operations *fops = &sq_fops;1165#ifndef MODULE1166int sq_unit;1167#endif11681169sq_unit = register_sound_dsp(fops, -1);1170if (sq_unit < 0) {1171printk(KERN_ERR "dmasound_core: couldn't register fops\n") ;1172return sq_unit ;1173}11741175write_sq_init_waitqueue();11761177/* These parameters will be restored for every clean open()1178* in the case of multiple open()s (e.g. dsp0 & dsp1) they1179* will be set so long as the shared resources have no owner.1180*/11811182if (shared_resource_owner == 0) {1183dmasound.soft = dmasound.mach.default_soft ;1184dmasound.hard = dmasound.mach.default_hard ;1185dmasound.dsp = dmasound.mach.default_soft ;1186shared_resources_initialised = 0 ;1187}1188return 0 ;1189}119011911192/*1193* /dev/sndstat1194*/11951196/* we allow more space for record-enabled because there are extra output lines.1197the number here must include the amount we are prepared to give to the low-level1198driver.1199*/12001201#define STAT_BUFF_LEN 76812021203/* this is how much space we will allow the low-level driver to use1204in the stat buffer. Currently, 2 * (80 character line + <NL>).1205We do not police this (it is up to the ll driver to be honest).1206*/12071208#define LOW_LEVEL_STAT_ALLOC 16212091210static struct {1211int busy;1212char buf[STAT_BUFF_LEN]; /* state.buf should not overflow! */1213int len, ptr;1214} state;12151216/* publish this function for use by low-level code, if required */12171218static char *get_afmt_string(int afmt)1219{1220switch(afmt) {1221case AFMT_MU_LAW:1222return "mu-law";1223break;1224case AFMT_A_LAW:1225return "A-law";1226break;1227case AFMT_U8:1228return "unsigned 8 bit";1229break;1230case AFMT_S8:1231return "signed 8 bit";1232break;1233case AFMT_S16_BE:1234return "signed 16 bit BE";1235break;1236case AFMT_U16_BE:1237return "unsigned 16 bit BE";1238break;1239case AFMT_S16_LE:1240return "signed 16 bit LE";1241break;1242case AFMT_U16_LE:1243return "unsigned 16 bit LE";1244break;1245case 0:1246return "format not set" ;1247break ;1248default:1249break ;1250}1251return "ERROR: Unsupported AFMT_XXXX code" ;1252}12531254static int state_open(struct inode *inode, struct file *file)1255{1256char *buffer = state.buf;1257int len = 0;1258int ret;12591260mutex_lock(&dmasound_core_mutex);1261ret = -EBUSY;1262if (state.busy)1263goto out;12641265ret = -ENODEV;1266if (!try_module_get(dmasound.mach.owner))1267goto out;12681269state.ptr = 0;1270state.busy = 1;12711272len += sprintf(buffer+len, "%sDMA sound driver rev %03d :\n",1273dmasound.mach.name, (DMASOUND_CORE_REVISION<<4) +1274((dmasound.mach.version>>8) & 0x0f));1275len += sprintf(buffer+len,1276"Core driver edition %02d.%02d : %s driver edition %02d.%02d\n",1277DMASOUND_CORE_REVISION, DMASOUND_CORE_EDITION, dmasound.mach.name2,1278(dmasound.mach.version >> 8), (dmasound.mach.version & 0xff)) ;12791280/* call the low-level module to fill in any stat info. that it has1281if present. Maximum buffer usage is specified.1282*/12831284if (dmasound.mach.state_info)1285len += dmasound.mach.state_info(buffer+len,1286(size_t) LOW_LEVEL_STAT_ALLOC) ;12871288/* make usage of the state buffer as deterministic as poss.1289exceptional conditions could cause overrun - and this is flagged as1290a kernel error.1291*/12921293/* formats and settings */12941295len += sprintf(buffer+len,"\t\t === Formats & settings ===\n") ;1296len += sprintf(buffer+len,"Parameter %20s%20s\n","soft","hard") ;1297len += sprintf(buffer+len,"Format :%20s%20s\n",1298get_afmt_string(dmasound.soft.format),1299get_afmt_string(dmasound.hard.format));13001301len += sprintf(buffer+len,"Samp Rate:%14d s/sec%14d s/sec\n",1302dmasound.soft.speed, dmasound.hard.speed);13031304len += sprintf(buffer+len,"Channels :%20s%20s\n",1305dmasound.soft.stereo ? "stereo" : "mono",1306dmasound.hard.stereo ? "stereo" : "mono" );13071308/* sound queue status */13091310len += sprintf(buffer+len,"\t\t === Sound Queue status ===\n");1311len += sprintf(buffer+len,"Allocated:%8s%6s\n","Buffers","Size") ;1312len += sprintf(buffer+len,"%9s:%8d%6d\n",1313"write", write_sq.numBufs, write_sq.bufSize) ;1314len += sprintf(buffer+len,1315"Current : MaxFrg FragSiz MaxAct Frnt Rear "1316"Cnt RrSize A B S L xruns\n") ;1317len += sprintf(buffer+len,"%9s:%7d%8d%7d%5d%5d%4d%7d%2d%2d%2d%2d%7d\n",1318"write", write_sq.max_count, write_sq.block_size,1319write_sq.max_active, write_sq.front, write_sq.rear,1320write_sq.count, write_sq.rear_size, write_sq.active,1321write_sq.busy, write_sq.syncing, write_sq.locked, write_sq.xruns) ;1322#ifdef DEBUG_DMASOUND1323printk("dmasound: stat buffer used %d bytes\n", len) ;1324#endif13251326if (len >= STAT_BUFF_LEN)1327printk(KERN_ERR "dmasound_core: stat buffer overflowed!\n");13281329state.len = len;1330ret = 0;1331out:1332mutex_unlock(&dmasound_core_mutex);1333return ret;1334}13351336static int state_release(struct inode *inode, struct file *file)1337{1338mutex_lock(&dmasound_core_mutex);1339state.busy = 0;1340module_put(dmasound.mach.owner);1341mutex_unlock(&dmasound_core_mutex);1342return 0;1343}13441345static ssize_t state_read(struct file *file, char __user *buf, size_t count,1346loff_t *ppos)1347{1348int n = state.len - state.ptr;1349if (n > count)1350n = count;1351if (n <= 0)1352return 0;1353if (copy_to_user(buf, &state.buf[state.ptr], n))1354return -EFAULT;1355state.ptr += n;1356return n;1357}13581359static const struct file_operations state_fops = {1360.owner = THIS_MODULE,1361.llseek = no_llseek,1362.read = state_read,1363.open = state_open,1364.release = state_release,1365};13661367static int state_init(void)1368{1369#ifndef MODULE1370int state_unit;1371#endif1372state_unit = register_sound_special(&state_fops, SND_DEV_STATUS);1373if (state_unit < 0)1374return state_unit ;1375state.busy = 0;1376return 0 ;1377}137813791380/*1381* Config & Setup1382*1383* This function is called by _one_ chipset-specific driver1384*/13851386int dmasound_init(void)1387{1388int res ;1389#ifdef MODULE1390if (irq_installed)1391return -EBUSY;1392#endif13931394/* Set up sound queue, /dev/audio and /dev/dsp. */13951396/* Set default settings. */1397if ((res = sq_init()) < 0)1398return res ;13991400/* Set up /dev/sndstat. */1401if ((res = state_init()) < 0)1402return res ;14031404/* Set up /dev/mixer. */1405mixer_init();14061407if (!dmasound.mach.irqinit()) {1408printk(KERN_ERR "DMA sound driver: Interrupt initialization failed\n");1409return -ENODEV;1410}1411#ifdef MODULE1412irq_installed = 1;1413#endif14141415printk(KERN_INFO "%s DMA sound driver rev %03d installed\n",1416dmasound.mach.name, (DMASOUND_CORE_REVISION<<4) +1417((dmasound.mach.version>>8) & 0x0f));1418printk(KERN_INFO1419"Core driver edition %02d.%02d : %s driver edition %02d.%02d\n",1420DMASOUND_CORE_REVISION, DMASOUND_CORE_EDITION, dmasound.mach.name2,1421(dmasound.mach.version >> 8), (dmasound.mach.version & 0xff)) ;1422printk(KERN_INFO "Write will use %4d fragments of %7d bytes as default\n",1423numWriteBufs, writeBufSize) ;1424return 0;1425}14261427#ifdef MODULE14281429void dmasound_deinit(void)1430{1431if (irq_installed) {1432sound_silence();1433dmasound.mach.irqcleanup();1434irq_installed = 0;1435}14361437write_sq_release_buffers();14381439if (mixer_unit >= 0)1440unregister_sound_mixer(mixer_unit);1441if (state_unit >= 0)1442unregister_sound_special(state_unit);1443if (sq_unit >= 0)1444unregister_sound_dsp(sq_unit);1445}14461447#else /* !MODULE */14481449static int dmasound_setup(char *str)1450{1451int ints[6], size;14521453str = get_options(str, ARRAY_SIZE(ints), ints);14541455/* check the bootstrap parameter for "dmasound=" */14561457/* FIXME: other than in the most naive of cases there is no sense in these1458* buffers being other than powers of two. This is not checked yet.1459*/14601461switch (ints[0]) {1462case 3:1463if ((ints[3] < 0) || (ints[3] > MAX_CATCH_RADIUS))1464printk("dmasound_setup: invalid catch radius, using default = %d\n", catchRadius);1465else1466catchRadius = ints[3];1467/* fall through */1468case 2:1469if (ints[1] < MIN_BUFFERS)1470printk("dmasound_setup: invalid number of buffers, using default = %d\n", numWriteBufs);1471else1472numWriteBufs = ints[1];1473/* fall through */1474case 1:1475if ((size = ints[2]) < 256) /* check for small buffer specs */1476size <<= 10 ;1477if (size < MIN_BUFSIZE || size > MAX_BUFSIZE)1478printk("dmasound_setup: invalid write buffer size, using default = %d\n", writeBufSize);1479else1480writeBufSize = size;1481case 0:1482break;1483default:1484printk("dmasound_setup: invalid number of arguments\n");1485return 0;1486}1487return 1;1488}14891490__setup("dmasound=", dmasound_setup);14911492#endif /* !MODULE */14931494/*1495* Conversion tables1496*/14971498#ifdef HAS_8BIT_TABLES1499/* 8 bit mu-law */15001501char dmasound_ulaw2dma8[] = {1502-126, -122, -118, -114, -110, -106, -102, -98,1503-94, -90, -86, -82, -78, -74, -70, -66,1504-63, -61, -59, -57, -55, -53, -51, -49,1505-47, -45, -43, -41, -39, -37, -35, -33,1506-31, -30, -29, -28, -27, -26, -25, -24,1507-23, -22, -21, -20, -19, -18, -17, -16,1508-16, -15, -15, -14, -14, -13, -13, -12,1509-12, -11, -11, -10, -10, -9, -9, -8,1510-8, -8, -7, -7, -7, -7, -6, -6,1511-6, -6, -5, -5, -5, -5, -4, -4,1512-4, -4, -4, -4, -3, -3, -3, -3,1513-3, -3, -3, -3, -2, -2, -2, -2,1514-2, -2, -2, -2, -2, -2, -2, -2,1515-1, -1, -1, -1, -1, -1, -1, -1,1516-1, -1, -1, -1, -1, -1, -1, -1,1517-1, -1, -1, -1, -1, -1, -1, 0,1518125, 121, 117, 113, 109, 105, 101, 97,151993, 89, 85, 81, 77, 73, 69, 65,152062, 60, 58, 56, 54, 52, 50, 48,152146, 44, 42, 40, 38, 36, 34, 32,152230, 29, 28, 27, 26, 25, 24, 23,152322, 21, 20, 19, 18, 17, 16, 15,152415, 14, 14, 13, 13, 12, 12, 11,152511, 10, 10, 9, 9, 8, 8, 7,15267, 7, 6, 6, 6, 6, 5, 5,15275, 5, 4, 4, 4, 4, 3, 3,15283, 3, 3, 3, 2, 2, 2, 2,15292, 2, 2, 2, 1, 1, 1, 1,15301, 1, 1, 1, 1, 1, 1, 1,15310, 0, 0, 0, 0, 0, 0, 0,15320, 0, 0, 0, 0, 0, 0, 0,15330, 0, 0, 0, 0, 0, 0, 01534};15351536/* 8 bit A-law */15371538char dmasound_alaw2dma8[] = {1539-22, -21, -24, -23, -18, -17, -20, -19,1540-30, -29, -32, -31, -26, -25, -28, -27,1541-11, -11, -12, -12, -9, -9, -10, -10,1542-15, -15, -16, -16, -13, -13, -14, -14,1543-86, -82, -94, -90, -70, -66, -78, -74,1544-118, -114, -126, -122, -102, -98, -110, -106,1545-43, -41, -47, -45, -35, -33, -39, -37,1546-59, -57, -63, -61, -51, -49, -55, -53,1547-2, -2, -2, -2, -2, -2, -2, -2,1548-2, -2, -2, -2, -2, -2, -2, -2,1549-1, -1, -1, -1, -1, -1, -1, -1,1550-1, -1, -1, -1, -1, -1, -1, -1,1551-6, -6, -6, -6, -5, -5, -5, -5,1552-8, -8, -8, -8, -7, -7, -7, -7,1553-3, -3, -3, -3, -3, -3, -3, -3,1554-4, -4, -4, -4, -4, -4, -4, -4,155521, 20, 23, 22, 17, 16, 19, 18,155629, 28, 31, 30, 25, 24, 27, 26,155710, 10, 11, 11, 8, 8, 9, 9,155814, 14, 15, 15, 12, 12, 13, 13,155986, 82, 94, 90, 70, 66, 78, 74,1560118, 114, 126, 122, 102, 98, 110, 106,156143, 41, 47, 45, 35, 33, 39, 37,156259, 57, 63, 61, 51, 49, 55, 53,15631, 1, 1, 1, 1, 1, 1, 1,15641, 1, 1, 1, 1, 1, 1, 1,15650, 0, 0, 0, 0, 0, 0, 0,15660, 0, 0, 0, 0, 0, 0, 0,15675, 5, 5, 5, 4, 4, 4, 4,15687, 7, 7, 7, 6, 6, 6, 6,15692, 2, 2, 2, 2, 2, 2, 2,15703, 3, 3, 3, 3, 3, 3, 31571};1572#endif /* HAS_8BIT_TABLES */15731574/*1575* Visible symbols for modules1576*/15771578EXPORT_SYMBOL(dmasound);1579EXPORT_SYMBOL(dmasound_init);1580#ifdef MODULE1581EXPORT_SYMBOL(dmasound_deinit);1582#endif1583EXPORT_SYMBOL(dmasound_write_sq);1584EXPORT_SYMBOL(dmasound_catchRadius);1585#ifdef HAS_8BIT_TABLES1586EXPORT_SYMBOL(dmasound_ulaw2dma8);1587EXPORT_SYMBOL(dmasound_alaw2dma8);1588#endif158915901591