/* * * AD1816 lowlevel sound driver for Linux 2.6.0 and above * * Copyright (C) 1998-2003 by Thorsten Knabe <linux@thorsten-knabe.de> * * Based on the CS4232/AD1848 driver Copyright (C) by Hannu Savolainen 1993-1996 * * * version: 1.5 * status: beta * date: 2003/07/15 * * Changes: * Oleg Drokin: Some cleanup of load/unload functions. 1998/11/24 * * Thorsten Knabe: attach and unload rewritten, * some argument checks added 1998/11/30 * * Thorsten Knabe: Buggy isa bridge workaround added 1999/01/16 * * David Moews/Thorsten Knabe: Introduced options * parameter. Added slightly modified patch from * David Moews to disable dsp audio sources by setting * bit 0 of options parameter. This seems to be * required by some Aztech/Newcom SC-16 cards. 1999/04/18 * * Christoph Hellwig: Adapted to module_init/module_exit. 2000/03/03 * * Christoph Hellwig: Added isapnp support 2000/03/15 * * Arnaldo Carvalho de Melo: get rid of check_region 2001/10/07 * * Thorsten Knabe: Compiling with CONFIG_PNP enabled * works again. It is now possible to use more than one * AD1816 sound card. Sample rate now may be changed during * playback/capture. printk() uses log levels everywhere. * SMP fixes. DMA handling fixes. * Other minor code cleanup. 2003/07/15 * */#include<linux/module.h>#include<linux/init.h>#include<linux/interrupt.h>#include<linux/isapnp.h>#include<linux/stddef.h>#include<linux/spinlock.h>#include"sound_config.h"#define DEBUGNOISE(x)#define CHECK_FOR_POWER { int timeout=100; \ while (timeout > 0 && (inb(devc->base)&0x80)!= 0x80) {\ timeout--; \ } \ if (timeout==0) {\ printk(KERN_WARNING "ad1816: Check for power failed in %s line: %d\n",__FILE__,__LINE__); \ } \}/* structure to hold device specific information */typedefstruct{intbase;/* set in attach */intirq;intdma_playback;intdma_capture;intopened;/* open */intspeed;intchannels;intaudio_format;intaudio_mode;intrecmask;/* setup */unsignedcharformat_bits;intsupported_devices;intsupported_rec_devices;unsignedshortlevels[SOUND_MIXER_NRDEVICES];/* misc */structpnp_dev*pnpdev;/* configured via pnp */intdev_no;/* this is the # in audio_devs and NOT in ad1816_info */spinlock_tlock;}ad1816_info;staticintnr_ad1816_devs;staticintad1816_clockfreq=33000;staticintoptions;/* supported audio formats */staticintad_format_mask=AFMT_U8|AFMT_S16_LE|AFMT_S16_BE|AFMT_MU_LAW|AFMT_A_LAW;/* array of device info structures */staticad1816_infodev_info[MAX_AUDIO_DEV];/* ------------------------------------------------------------------- *//* functions for easier access to inderect registers */staticintad_read(ad1816_info*devc,intreg){intresult;CHECK_FOR_POWER