X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Foss%2Fwavfront.c;h=9057edaaab16fd1bc3a0a468aeb50c2f2b5b24d7;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=fe9427e93e4937a9772f251606beccd6d2eaa40e;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/sound/oss/wavfront.c b/sound/oss/wavfront.c index fe9427e93..9057edaaa 100644 --- a/sound/oss/wavfront.c +++ b/sound/oss/wavfront.c @@ -114,7 +114,7 @@ #define OSS_SUPPORT_LEVEL 0x1 /* just /dev/sequencer for now */ #if OSS_SUPPORT_LEVEL & OSS_SUPPORT_SEQ -static int (*midi_load_patch) (int devno, int format, const char *addr, +static int (*midi_load_patch) (int devno, int format, const char __user *addr, int offs, int count, int pmgr_flag) = NULL; #endif /* OSS_SUPPORT_SEQ */ @@ -157,14 +157,14 @@ int wf_raw; /* we normally check for "raw state" to firmware board and load the firmware anyway. */ -int fx_raw = 1; /* if this is zero, we'll leave the FX processor in - whatever state it is when the driver is loaded. - The default is to download the microprogram and - associated coefficients to set it up for "default" - operation, whatever that means. - */ - -int debug_default; /* you can set this to control debugging +static int fx_raw = 1; /* if this is zero, we'll leave the FX processor in + whatever state it is when the driver is loaded. + The default is to download the microprogram and + associated coefficients to set it up for "default" + operation, whatever that means. + */ + +static int debug_default; /* you can set this to control debugging during driver loading. it takes any combination of the WF_DEBUG_* flags defined in wavefront.h @@ -172,44 +172,46 @@ int debug_default; /* you can set this to control debugging /* XXX this needs to be made firmware and hardware version dependent */ -char *ospath = "/etc/sound/wavefront.os"; /* where to find a processed - version of the WaveFront OS - */ +static char *ospath = "/etc/sound/wavefront.os"; /* where to find a processed + version of the WaveFront OS + */ -int wait_polls = 2000; /* This is a number of tries we poll the status register - before resorting to sleeping. WaveFront being an ISA - card each poll takes about 1.2us. So before going to - sleep we wait up to 2.4ms in a loop. - */ +static int wait_polls = 2000; /* This is a number of tries we poll the + status register before resorting to sleeping. + WaveFront being an ISA card each poll takes + about 1.2us. So before going to + sleep we wait up to 2.4ms in a loop. + */ -int sleep_length = HZ/100; /* This says how long we're going to sleep between polls. - 10ms sounds reasonable for fast response. - */ +static int sleep_length = HZ/100; /* This says how long we're going to + sleep between polls. + 10ms sounds reasonable for fast response. + */ -int sleep_tries = 50; /* Wait for status 0.5 seconds total. */ +static int sleep_tries = 50; /* Wait for status 0.5 seconds total. */ -int reset_time = 2; /* hundreths of a second we wait after a HW reset for +static int reset_time = 2; /* hundreths of a second we wait after a HW reset for the expected interrupt. */ -int ramcheck_time = 20; /* time in seconds to wait while ROM code - checks on-board RAM. - */ - -int osrun_time = 10; /* time in seconds we wait for the OS to - start running. - */ - -MODULE_PARM(wf_raw,"i"); -MODULE_PARM(fx_raw,"i"); -MODULE_PARM(debug_default,"i"); -MODULE_PARM(wait_polls,"i"); -MODULE_PARM(sleep_length,"i"); -MODULE_PARM(sleep_tries,"i"); -MODULE_PARM(ospath,"s"); -MODULE_PARM(reset_time,"i"); -MODULE_PARM(ramcheck_time,"i"); -MODULE_PARM(osrun_time,"i"); +static int ramcheck_time = 20; /* time in seconds to wait while ROM code + checks on-board RAM. + */ + +static int osrun_time = 10; /* time in seconds we wait for the OS to + start running. + */ + +module_param(wf_raw, int, 0); +module_param(fx_raw, int, 0); +module_param(debug_default, int, 0); +module_param(wait_polls, int, 0); +module_param(sleep_length, int, 0); +module_param(sleep_tries, int, 0); +module_param(ospath, charp, 0); +module_param(reset_time, int, 0); +module_param(ramcheck_time, int, 0); +module_param(osrun_time, int, 0); /***************************************************************************/ @@ -275,7 +277,7 @@ struct wf_config { wait_queue_head_t interrupt_sleeper; } dev; -static spinlock_t lock=SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(lock); static int detect_wffx(void); static int wffx_ioctl (wavefront_fx_info *); static int wffx_init (void); @@ -312,7 +314,7 @@ static struct { { 0x0E, "Bad MIDI channel number" }, { 0x10, "Download Record Error" }, { 0x80, "Success" }, - { 0x0, 0x0 } + { 0 } }; #define NEEDS_ACK 1 @@ -493,7 +495,7 @@ wavefront_cmd (int cmd, unsigned char *rbuf, unsigned char *wbuf) if (cmd == WFC_DOWNLOAD_MULTISAMPLE) { wfcmd->write_cnt = (unsigned int) rbuf; - rbuf = 0; + rbuf = NULL; } DPRINT (WF_DEBUG_CMD, "0x%x [%s] (%d,%d,%d)\n", @@ -745,7 +747,7 @@ wavefront_delete_sample (int sample_num) wbuf[0] = sample_num & 0x7f; wbuf[1] = sample_num >> 7; - if ((x = wavefront_cmd (WFC_DELETE_SAMPLE, 0, wbuf)) == 0) { + if ((x = wavefront_cmd (WFC_DELETE_SAMPLE, NULL, wbuf)) == 0) { dev.sample_status[sample_num] = WF_ST_EMPTY; } @@ -934,7 +936,7 @@ wavefront_send_patch (wavefront_patch_info *header) bptr = munge_int32 (header->number, buf, 2); munge_buf ((unsigned char *)&header->hdr.p, bptr, WF_PATCH_BYTES); - if (wavefront_cmd (WFC_DOWNLOAD_PATCH, 0, buf)) { + if (wavefront_cmd (WFC_DOWNLOAD_PATCH, NULL, buf)) { printk (KERN_ERR LOGNAME "download patch failed\n"); return -(EIO); } @@ -972,7 +974,7 @@ wavefront_send_program (wavefront_patch_info *header) buf[0] = header->number; munge_buf ((unsigned char *)&header->hdr.pr, &buf[1], WF_PROGRAM_BYTES); - if (wavefront_cmd (WFC_DOWNLOAD_PROGRAM, 0, buf)) { + if (wavefront_cmd (WFC_DOWNLOAD_PROGRAM, NULL, buf)) { printk (KERN_WARNING LOGNAME "download patch failed\n"); return -(EIO); } @@ -986,7 +988,7 @@ wavefront_freemem (void) { char rbuf[8]; - if (wavefront_cmd (WFC_REPORT_FREE_MEMORY, rbuf, 0)) { + if (wavefront_cmd (WFC_REPORT_FREE_MEMORY, rbuf, NULL)) { printk (KERN_WARNING LOGNAME "can't get memory stats.\n"); return -1; } else { @@ -996,7 +998,7 @@ wavefront_freemem (void) static int wavefront_send_sample (wavefront_patch_info *header, - UINT16 *dataptr, + UINT16 __user *dataptr, int data_is_unsigned) { @@ -1011,7 +1013,7 @@ wavefront_send_sample (wavefront_patch_info *header, UINT16 sample_short; UINT32 length; - UINT16 *data_end = 0; + UINT16 __user *data_end = NULL; unsigned int i; const int max_blksize = 4096/2; unsigned int written; @@ -1024,11 +1026,11 @@ wavefront_send_sample (wavefront_patch_info *header, int initial_skip = 0; DPRINT (WF_DEBUG_LOAD_PATCH, "sample %sdownload for slot %d, " - "type %d, %d bytes from 0x%x\n", + "type %d, %d bytes from %p\n", header->size ? "" : "header ", header->number, header->subkey, header->size, - (int) header->dataptr); + header->dataptr); if (header->number == WAVEFRONT_FIND_FREE_SAMPLE_SLOT) { int x; @@ -1188,7 +1190,7 @@ wavefront_send_sample (wavefront_patch_info *header, if (wavefront_cmd (header->size ? WFC_DOWNLOAD_SAMPLE : WFC_DOWNLOAD_SAMPLE_HEADER, - 0, sample_hdr)) { + NULL, sample_hdr)) { printk (KERN_WARNING LOGNAME "sample %sdownload refused.\n", header->size ? "" : "header "); return -(EIO); @@ -1214,7 +1216,7 @@ wavefront_send_sample (wavefront_patch_info *header, blocksize = ((length-written+7)&~0x7); } - if (wavefront_cmd (WFC_DOWNLOAD_BLOCK, 0, 0)) { + if (wavefront_cmd (WFC_DOWNLOAD_BLOCK, NULL, NULL)) { printk (KERN_WARNING LOGNAME "download block " "request refused.\n"); return -(EIO); @@ -1321,7 +1323,7 @@ wavefront_send_alias (wavefront_patch_info *header) munge_int32 (header->hdr.a.FrequencyBias, &alias_hdr[20], 3); munge_int32 (*(&header->hdr.a.FrequencyBias+1), &alias_hdr[23], 2); - if (wavefront_cmd (WFC_DOWNLOAD_SAMPLE_ALIAS, 0, alias_hdr)) { + if (wavefront_cmd (WFC_DOWNLOAD_SAMPLE_ALIAS, NULL, alias_hdr)) { printk (KERN_ERR LOGNAME "download alias failed.\n"); return -(EIO); } @@ -1402,7 +1404,7 @@ wavefront_fetch_multisample (wavefront_patch_info *header) num_samples = (1 << log_ns[0]); for (i = 0; i < num_samples; i++) { - char d[2]; + s8 d[2]; if ((d[0] = wavefront_read ()) == -1) { printk (KERN_ERR LOGNAME "upload multisample failed " @@ -1445,7 +1447,7 @@ wavefront_send_drum (wavefront_patch_info *header) munge_int32 (((unsigned char *)drum)[i], &drumbuf[1+(i*2)], 2); } - if (wavefront_cmd (WFC_DOWNLOAD_EDRUM_PROGRAM, 0, drumbuf)) { + if (wavefront_cmd (WFC_DOWNLOAD_EDRUM_PROGRAM, NULL, drumbuf)) { printk (KERN_ERR LOGNAME "download drum failed.\n"); return -(EIO); } @@ -1512,7 +1514,7 @@ log2_2048(int n) } static int -wavefront_load_gus_patch (int devno, int format, const char *addr, +wavefront_load_gus_patch (int devno, int format, const char __user *addr, int offs, int count, int pmgr_flag) { struct patch_info guspatch; @@ -1636,7 +1638,7 @@ wavefront_load_gus_patch (int devno, int format, const char *addr, /* Now ship it down */ wavefront_send_sample (&samp, - (unsigned short *) &(addr)[sizeof_patch], + (unsigned short __user *) &(addr)[sizeof_patch], (guspatch.mode & WAVE_UNSIGNED) ? 1:0); wavefront_send_patch (&pat); wavefront_send_program (&prog); @@ -1656,7 +1658,7 @@ wavefront_load_gus_patch (int devno, int format, const char *addr, } static int -wavefront_load_patch (const char *addr) +wavefront_load_patch (const char __user *addr) { @@ -1680,7 +1682,7 @@ wavefront_load_patch (const char *addr) case WF_ST_SAMPLE: /* sample or sample_header, based on patch->size */ if (copy_from_user((unsigned char *) &header.hdr.s, - (unsigned char *) header.hdrptr, + (unsigned char __user *) header.hdrptr, sizeof (wavefront_sample))) return -EFAULT; @@ -1688,8 +1690,7 @@ wavefront_load_patch (const char *addr) case WF_ST_MULTISAMPLE: - if (copy_from_user((unsigned char *) &header.hdr.s, - (unsigned char *) header.hdrptr, + if (copy_from_user(&header.hdr.s, header.hdrptr, sizeof(wavefront_multisample))) return -EFAULT; @@ -1698,32 +1699,28 @@ wavefront_load_patch (const char *addr) case WF_ST_ALIAS: - if (copy_from_user((unsigned char *) &header.hdr.a, - (unsigned char *) header.hdrptr, + if (copy_from_user(&header.hdr.a, header.hdrptr, sizeof (wavefront_alias))) return -EFAULT; return wavefront_send_alias (&header); case WF_ST_DRUM: - if (copy_from_user((unsigned char *) &header.hdr.d, - (unsigned char *) header.hdrptr, + if (copy_from_user(&header.hdr.d, header.hdrptr, sizeof (wavefront_drum))) return -EFAULT; return wavefront_send_drum (&header); case WF_ST_PATCH: - if (copy_from_user((unsigned char *) &header.hdr.p, - (unsigned char *) header.hdrptr, + if (copy_from_user(&header.hdr.p, header.hdrptr, sizeof (wavefront_patch))) return -EFAULT; return wavefront_send_patch (&header); case WF_ST_PROGRAM: - if (copy_from_user((unsigned char *) &header.hdr.pr, - (unsigned char *) header.hdrptr, + if (copy_from_user(&header.hdr.pr, header.hdrptr, sizeof (wavefront_program))) return -EFAULT; @@ -1940,18 +1937,18 @@ wavefront_ioctl(struct inode *inode, struct file *file, switch (cmd) { case WFCTL_WFCMD: - if (copy_from_user(&wc, (void *) arg, sizeof (wc))) + if (copy_from_user(&wc, (void __user *) arg, sizeof (wc))) return -EFAULT; if ((err = wavefront_synth_control (cmd, &wc)) == 0) { - if (copy_to_user ((void *) arg, &wc, sizeof (wc))) + if (copy_to_user ((void __user *) arg, &wc, sizeof (wc))) return -EFAULT; } return err; case WFCTL_LOAD_SPP: - return wavefront_load_patch ((const char *) arg); + return wavefront_load_patch ((const char __user *) arg); default: printk (KERN_WARNING LOGNAME "invalid ioctl %#x\n", cmd); @@ -1998,7 +1995,7 @@ wavefront_oss_close (int devno) } static int -wavefront_oss_ioctl (int devno, unsigned int cmd, caddr_t arg) +wavefront_oss_ioctl (int devno, unsigned int cmd, void __user * arg) { wavefront_control wc; @@ -2006,8 +2003,7 @@ wavefront_oss_ioctl (int devno, unsigned int cmd, caddr_t arg) switch (cmd) { case SNDCTL_SYNTH_INFO: - if(copy_to_user(&((char *) arg)[0], &wavefront_info, - sizeof (wavefront_info))) + if(copy_to_user(arg, &wavefront_info, sizeof (wavefront_info))) return -EFAULT; return 0; @@ -2042,8 +2038,8 @@ wavefront_oss_ioctl (int devno, unsigned int cmd, caddr_t arg) } } -int -wavefront_oss_load_patch (int devno, int format, const char *addr, +static int +wavefront_oss_load_patch (int devno, int format, const char __user *addr, int offs, int count, int pmgr_flag) { @@ -2171,7 +2167,7 @@ wavefrontintr(int irq, void *dev_id, struct pt_regs *dummy) 7 Unused */ -int +static int wavefront_interrupt_bits (int irq) { @@ -2199,7 +2195,7 @@ wavefront_interrupt_bits (int irq) return bits; } -void +static void wavefront_should_cause_interrupt (int val, int port, int timeout) { @@ -2744,7 +2740,7 @@ static int __init wavefront_do_reset (int atboot) voices[0] = 32; - if (wavefront_cmd (WFC_SET_NVOICES, 0, voices)) { + if (wavefront_cmd (WFC_SET_NVOICES, NULL, voices)) { printk (KERN_WARNING LOGNAME "cannot set number of voices to 32.\n"); goto gone_bad; @@ -2901,16 +2897,6 @@ int __init detect_wffx (void) return 0; } -int __init attach_wffx (void) -{ - if ((dev.fx_mididev = sound_alloc_mididev ()) < 0) { - printk (KERN_WARNING LOGNAME "cannot install FX Midi driver\n"); - return -1; - } - - return 0; -} - void wffx_mute (int onoff) @@ -2967,8 +2953,8 @@ wffx_memset (int page, if (i != cnt) { printk (KERN_WARNING LOGNAME "FX memset " - "(0x%x, 0x%x, 0x%x, %d) incomplete\n", - page, addr, (int) data, cnt); + "(0x%x, 0x%x, %p, %d) incomplete\n", + page, addr, data, cnt); return -(EIO); } } @@ -3003,7 +2989,7 @@ wffx_ioctl (wavefront_fx_info *r) return -(EINVAL); } if (copy_from_user(page_data, - (unsigned char *)r->data[3], + (unsigned char __user *)r->data[3], r->data[2])) return -EFAULT; pd = page_data; @@ -3496,8 +3482,8 @@ static int irq = -1; MODULE_AUTHOR ("Paul Barton-Davis "); MODULE_DESCRIPTION ("Turtle Beach WaveFront Linux Driver"); MODULE_LICENSE("GPL"); -MODULE_PARM (io,"i"); -MODULE_PARM (irq,"i"); +module_param (io, int, 0); +module_param (irq, int, 0); static int __init init_wavfront (void) {