1 /* $Id: audio.c,v 1.1.1.1 2005/04/11 02:50:34 jack Exp $
2 * drivers/sbus/audio/audio.c
4 * Copyright 1996 Thomas K. Dyas (tdyas@noc.rutgers.edu)
5 * Copyright 1997,1998,1999 Derrick J. Brashear (shadow@dementia.org)
6 * Copyright 1997 Brent Baccala (baccala@freesoft.org)
8 * Mixer code adapted from code contributed by and
9 * Copyright 1998 Michael Mraka (michael@fi.muni.cz)
10 * and with fixes from Michael Shuey (shuey@ecn.purdue.edu)
11 * The mixer code cheats; Sparc hardware doesn't generally allow independent
12 * line control, and this fakes it badly.
14 * SNDCTL_DSP_SETFMT based on code contributed by
15 * Ion Badulescu (ionut@moisil.cs.columbia.edu)
17 * This is the audio midlayer that sits between the VFS character
18 * devices and the low-level audio hardware device drivers.
21 #include <linux/config.h>
22 #include <linux/module.h>
23 #include <linux/errno.h>
25 #include <linux/kernel.h>
26 #include <linux/sched.h>
27 #include <linux/smp_lock.h>
29 #include <linux/tqueue.h>
30 #include <linux/major.h>
31 #include <linux/slab.h>
32 #include <linux/interrupt.h>
33 #include <linux/init.h>
34 #include <linux/soundcard.h>
35 #include <linux/devfs_fs_kernel.h>
36 #include <linux/delay.h>
37 #include <linux/poll.h>
38 #include <asm/pgtable.h>
39 #include <asm/uaccess.h>
41 #include <asm/audioio.h>
46 #undef __AUDIO_OSSDEBUG
48 #define dprintk(x) printk x
52 #ifdef __AUDIO_OSSDEBUG
53 #define oprintk(x) printk x
58 #define eprintk(x) printk x
63 #define tprintk(x) printk x
68 static short lis_get_elist_ent( strevent_t *list, pid_t pid );
69 static int lis_add_to_elist( strevent_t **list, pid_t pid, short events );
70 static int lis_del_from_elist( strevent_t **list, pid_t pid, short events );
71 static void lis_free_elist( strevent_t **list);
72 static void kill_procs( struct strevent *elist, int sig, short e);
74 static struct sparcaudio_driver *drivers[SPARCAUDIO_MAX_DEVICES];
75 static devfs_handle_t devfs_handle;
78 void sparcaudio_output_done(struct sparcaudio_driver * drv, int status)
80 /* If !status, just restart current output.
81 * If status & 1, a buffer is finished; make it available again.
82 * If status & 2, a buffer was claimed for DMA and is still in use.
84 * The playing_count for non-DMA hardware should never be non-zero.
85 * Value of status for non-DMA hardware should always be 1.
88 if (drv->playing_count) {
92 drv->output_size -= drv->output_sizes[drv->output_front];
93 if (drv->output_notify[drv->output_front] == 1) {
95 drv->output_notify[drv->output_front] = 0;
96 kill_procs(drv->sd_siglist,SIGPOLL,S_MSG);
98 drv->output_front = (drv->output_front + 1) %
99 drv->num_output_buffers;
105 drv->playing_count++;
106 drv->output_size -= drv->output_sizes[drv->output_front];
107 if (drv->output_notify[drv->output_front] == 1) {
109 drv->output_notify[drv->output_front] = 0;
110 kill_procs(drv->sd_siglist,SIGPOLL,S_MSG);
112 drv->output_front = (drv->output_front + 1) %
113 drv->num_output_buffers;
116 /* If we've played everything go inactive. */
117 if ((drv->output_count < 1) && (drv->playing_count < 1))
118 drv->output_active = 0;
120 /* If we got back a buffer, see if anyone wants to write to it */
121 if ((status & 1) || ((drv->output_count + drv->playing_count)
122 < drv->num_output_buffers)) {
123 wake_up_interruptible(&drv->output_write_wait);
126 /* If the output queue is empty, shut down the driver. */
127 if ((drv->output_count < 1) && (drv->playing_count < 1)) {
128 kill_procs(drv->sd_siglist,SIGPOLL,S_MSG);
130 /* Stop the lowlevel driver from outputing. */
131 /* drv->ops->stop_output(drv); Should not be necessary -- DJB 5/25/98 */
132 drv->output_active = 0;
134 /* Wake up any waiting writers or syncers and return. */
135 wake_up_interruptible(&drv->output_write_wait);
136 wake_up_interruptible(&drv->output_drain_wait);
140 /* Start next block of output if we have it */
141 if (drv->output_count > 0) {
142 drv->ops->start_output(drv, drv->output_buffers[drv->output_front],
143 drv->output_sizes[drv->output_front]);
144 drv->output_active = 1;
146 drv->output_active = 0;
150 void sparcaudio_input_done(struct sparcaudio_driver * drv, int status)
152 /* Deal with the weird case here */
153 if (drv->duplex == 2) {
154 if (drv->input_count < drv->num_input_buffers)
156 drv->ops->start_input(drv, drv->input_buffers[drv->input_front],
157 drv->input_buffer_size);
158 wake_up_interruptible(&drv->input_read_wait);
162 /* If status % 2, they filled a buffer for us.
163 * If status & 2, they took a buffer from us.
165 if ((status % 2) == 1) {
167 drv->recording_count--;
168 drv->input_size+=drv->input_buffer_size;
172 drv->recording_count++;
173 drv->input_front = (drv->input_front + 1) % drv->num_input_buffers;
176 dprintk(("f%d r%d c%d u%d\n",
177 drv->input_front, drv->input_rear,
178 drv->input_count, drv->recording_count));
180 /* If the input queue is full, shutdown the driver. */
181 if ((drv->input_count + drv->recording_count) == drv->num_input_buffers) {
182 kill_procs(drv->sd_siglist,SIGPOLL,S_MSG);
184 /* Stop the lowlevel driver from inputing. */
185 drv->ops->stop_input(drv);
186 drv->input_active = 0;
188 /* Otherwise, give the driver the next buffer. */
189 drv->ops->start_input(drv, drv->input_buffers[drv->input_front],
190 drv->input_buffer_size);
193 /* Wake up any tasks that are waiting. */
194 wake_up_interruptible(&drv->input_read_wait);
198 * VFS layer interface
201 static unsigned int sparcaudio_poll(struct file *file, poll_table * wait)
203 unsigned int mask = 0;
204 struct inode *inode = file->f_dentry->d_inode;
205 struct sparcaudio_driver *drv = drivers[(MINOR(inode->i_rdev) >>
206 SPARCAUDIO_DEVICE_SHIFT)];
208 poll_wait(file, &drv->input_read_wait, wait);
209 poll_wait(file, &drv->output_write_wait, wait);
210 if (((!file->f_flags & O_NONBLOCK) && drv->input_count) ||
211 (drv->input_size > drv->buffer_size)) {
212 mask |= POLLIN | POLLRDNORM;
214 if ((drv->output_count + drv->playing_count) < (drv->num_output_buffers)) {
215 mask |= POLLOUT | POLLWRNORM;
220 static ssize_t sparcaudio_read(struct file * file, char *buf,
221 size_t count, loff_t *ppos)
223 struct inode *inode = file->f_dentry->d_inode;
224 struct sparcaudio_driver *drv = drivers[(MINOR(inode->i_rdev) >>
225 SPARCAUDIO_DEVICE_SHIFT)];
226 int bytes_to_copy, bytes_read = 0, err;
228 if (! (file->f_mode & FMODE_READ))
231 if ((file->f_flags & O_NONBLOCK) && (drv->input_size < count))
235 if (drv->input_count == 0) {
236 /* This *should* never happen. */
237 if (file->f_flags & O_NONBLOCK) {
238 printk("Warning: audio input leak!\n");
241 interruptible_sleep_on(&drv->input_read_wait);
242 if (signal_pending(current))
246 bytes_to_copy = drv->input_buffer_size - drv->input_offset;
247 if (bytes_to_copy > count)
248 bytes_to_copy = count;
250 err = verify_area(VERIFY_WRITE, buf, bytes_to_copy);
254 copy_to_user(buf, drv->input_buffers[drv->input_rear]+drv->input_offset,
257 drv->input_offset += bytes_to_copy;
258 drv->input_size -= bytes_to_copy;
259 buf += bytes_to_copy;
260 count -= bytes_to_copy;
261 bytes_read += bytes_to_copy;
263 if (drv->input_offset >= drv->input_buffer_size) {
264 drv->input_rear = (drv->input_rear + 1) %
265 drv->num_input_buffers;
267 drv->input_offset = 0;
270 /* If we're in "loop audio" mode, try waking up the other side
271 * in case they're waiting for us to eat a block.
273 if (drv->duplex == 2)
274 wake_up_interruptible(&drv->output_write_wait);
280 static void sparcaudio_sync_output(struct sparcaudio_driver * drv)
284 /* If the low-level driver is not active, activate it. */
286 if ((!drv->output_active) && (drv->output_count > 0)) {
287 drv->ops->start_output(drv,
288 drv->output_buffers[drv->output_front],
289 drv->output_sizes[drv->output_front]);
290 drv->output_active = 1;
292 restore_flags(flags);
295 static ssize_t sparcaudio_write(struct file * file, const char *buf,
296 size_t count, loff_t *ppos)
298 struct inode *inode = file->f_dentry->d_inode;
299 struct sparcaudio_driver *drv = drivers[(MINOR(inode->i_rdev) >>
300 SPARCAUDIO_DEVICE_SHIFT)];
301 int bytes_written = 0, bytes_to_copy, err;
303 if (! (file->f_mode & FMODE_WRITE))
306 /* A signal they want notification when this is processed. Too bad
307 * sys_write doesn't tell us unless you patch it, in 2.0 kernels.
312 kill_procs(drv->sd_siglist,SIGPOLL,S_MSG);
314 /* Nice code, but the world isn't ready yet... */
315 drv->output_notify[drv->output_rear] = 1;
319 /* Loop until all output is written to device. */
321 /* Check to make sure that an output buffer is available. */
322 if (drv->num_output_buffers == (drv->output_count+drv->playing_count)) {
323 /* We need buffers, so... */
324 sparcaudio_sync_output(drv);
325 if (file->f_flags & O_NONBLOCK)
328 interruptible_sleep_on(&drv->output_write_wait);
329 if (signal_pending(current))
330 return bytes_written > 0 ? bytes_written : -EINTR;
333 /* No buffers were freed. Go back to sleep */
334 if (drv->num_output_buffers == (drv->output_count+drv->playing_count))
337 /* Deal with the weird case of a reader in the write area by trying to
338 * let them keep ahead of us... Go to sleep until they start servicing.
340 if ((drv->duplex == 2) && (drv->flags & SDF_OPEN_READ) &&
341 (drv->output_rear == drv->input_rear) && (drv->input_count > 0)) {
342 if (file->f_flags & O_NONBLOCK)
345 interruptible_sleep_on(&drv->output_write_wait);
346 if (signal_pending(current))
347 return bytes_written > 0 ? bytes_written : -EINTR;
350 /* Determine how much we can copy in this iteration. */
351 bytes_to_copy = count;
352 if (bytes_to_copy > drv->output_buffer_size - drv->output_offset)
353 bytes_to_copy = drv->output_buffer_size - drv->output_offset;
355 err = verify_area(VERIFY_READ, buf, bytes_to_copy);
359 copy_from_user(drv->output_buffers[drv->output_rear]+drv->output_offset,
362 /* Update the queue pointers. */
363 buf += bytes_to_copy;
364 count -= bytes_to_copy;
365 bytes_written += bytes_to_copy;
367 /* A block can get orphaned in a flush and not cleaned up. */
368 if (drv->output_offset)
369 drv->output_sizes[drv->output_rear] += bytes_to_copy;
371 drv->output_sizes[drv->output_rear] = bytes_to_copy;
373 drv->output_notify[drv->output_rear] = 0;
375 if (drv->output_sizes[drv->output_rear] == drv->output_buffer_size) {
376 drv->output_rear = (drv->output_rear + 1)
377 % drv->num_output_buffers;
379 drv->output_offset = 0;
381 drv->output_offset += bytes_to_copy;
384 drv->output_size += bytes_to_copy;
387 sparcaudio_sync_output(drv);
389 /* Return the number of bytes written to the caller. */
390 return bytes_written;
393 /* Add these in as new devices are supported. Belongs in audioio.h, actually */
394 #define MONO_DEVICES (SOUND_MASK_SPEAKER | SOUND_MASK_MIC)
396 static int sparcaudio_mixer_ioctl(struct inode * inode, struct file * file,
397 unsigned int cmd, unsigned int *arg)
399 struct sparcaudio_driver *drv = drivers[(MINOR(inode->i_rdev) >>
400 SPARCAUDIO_DEVICE_SHIFT)];
401 unsigned long i = 0, j = 0, l = 0, m = 0;
404 if (_SIOC_DIR(cmd) & _SIOC_WRITE)
405 drv->mixer_modify_counter++;
407 if(cmd == SOUND_MIXER_INFO) {
410 int retval = -EINVAL;
412 if(drv->ops->sunaudio_getdev) {
413 drv->ops->sunaudio_getdev(drv, &tmp);
414 memset(&info, 0, sizeof(info));
415 strncpy(info.id, tmp.name, sizeof(info.id));
416 strncpy(info.name, "Sparc Audio", sizeof(info.name));
417 info.modify_counter = drv->mixer_modify_counter;
419 if(copy_to_user((char *)arg, &info, sizeof(info)))
428 case SOUND_MIXER_WRITE_RECLEV:
429 if (get_user(k, (int *)arg))
432 oprintk(("setting input volume (0x%x)", k));
433 if (drv->ops->get_input_channels)
434 j = drv->ops->get_input_channels(drv);
435 if (drv->ops->get_input_volume)
436 l = drv->ops->get_input_volume(drv);
437 if (drv->ops->get_input_balance)
438 m = drv->ops->get_input_balance(drv);
441 oprintk((" for stereo to do %d (bal %d):", i, j));
442 if (drv->ops->set_input_volume)
443 drv->ops->set_input_volume(drv, i);
444 if (drv->ops->set_input_balance)
445 drv->ops->set_input_balance(drv, j);
446 case SOUND_MIXER_READ_RECLEV:
447 if (drv->ops->get_input_volume)
448 i = drv->ops->get_input_volume(drv);
449 if (drv->ops->get_input_balance)
450 j = drv->ops->get_input_balance(drv);
451 oprintk((" got (0x%x)\n", BAL_TO_OSS(i,j)));
453 /* Try to be reasonable about volume changes */
454 if ((cmd == SOUND_MIXER_WRITE_RECLEV) && (i != k) &&
455 (i == BAL_TO_OSS(l,m))) {
456 k += (OSS_LEFT(k) > OSS_LEFT(i)) ? 256 : -256;
457 k += (OSS_RIGHT(k) > OSS_RIGHT(i)) ? 1 : -1;
458 oprintk((" try 0x%x\n", k));
461 return put_user(i, (int *)arg);
462 case SOUND_MIXER_WRITE_VOLUME:
463 if (get_user(k, (int *)arg))
465 if (drv->ops->get_output_muted && drv->ops->set_output_muted) {
466 i = drv->ops->get_output_muted(drv);
467 if ((k == 0) || ((i == 0) && (OSS_LEFT(k) < 100)))
468 drv->ops->set_output_muted(drv, 1);
470 drv->ops->set_output_muted(drv, 0);
472 case SOUND_MIXER_READ_VOLUME:
473 if (drv->ops->get_output_muted)
474 i = drv->ops->get_output_muted(drv);
475 k = 0x6464 * (1 - i);
476 return put_user(k, (int *)arg);
477 case SOUND_MIXER_WRITE_PCM:
478 if (get_user(k, (int *)arg))
481 oprintk(("setting output volume (0x%x)\n", k));
482 if (drv->ops->get_output_channels)
483 j = drv->ops->get_output_channels(drv);
484 if (drv->ops->get_output_volume)
485 l = drv->ops->get_output_volume(drv);
486 if (drv->ops->get_output_balance)
487 m = drv->ops->get_output_balance(drv);
488 oprintk((" started as (0x%x)\n", BAL_TO_OSS(l,m)));
491 oprintk((" for stereo to %d (bal %d)\n", i, j));
492 if (drv->ops->set_output_volume)
493 drv->ops->set_output_volume(drv, i);
494 if (drv->ops->set_output_balance)
495 drv->ops->set_output_balance(drv, j);
496 case SOUND_MIXER_READ_PCM:
497 if (drv->ops->get_output_volume)
498 i = drv->ops->get_output_volume(drv);
499 if (drv->ops->get_output_balance)
500 j = drv->ops->get_output_balance(drv);
501 oprintk((" got 0x%x\n", BAL_TO_OSS(i,j)));
504 /* Try to be reasonable about volume changes */
505 if ((cmd == SOUND_MIXER_WRITE_PCM) && (i != k) &&
506 (i == BAL_TO_OSS(l,m))) {
507 k += (OSS_LEFT(k) > OSS_LEFT(i)) ? 256 : -256;
508 k += (OSS_RIGHT(k) > OSS_RIGHT(i)) ? 1 : -1;
509 oprintk((" try 0x%x\n", k));
512 return put_user(i, (int *)arg);
513 case SOUND_MIXER_READ_SPEAKER:
514 k = OSS_PORT_AUDIO(drv, AUDIO_SPEAKER);
515 return put_user(k, (int *)arg);
516 case SOUND_MIXER_READ_MIC:
517 k = OSS_IPORT_AUDIO(drv, AUDIO_MICROPHONE);
518 return put_user(k, (int *)arg);
519 case SOUND_MIXER_READ_CD:
520 k = OSS_IPORT_AUDIO(drv, AUDIO_CD);
521 return put_user(k, (int *)arg);
522 case SOUND_MIXER_READ_LINE:
523 k = OSS_IPORT_AUDIO(drv, AUDIO_LINE_IN);
524 return put_user(k, (int *)arg);
525 case SOUND_MIXER_READ_LINE1:
526 k = OSS_PORT_AUDIO(drv, AUDIO_HEADPHONE);
527 return put_user(k, (int *)arg);
528 case SOUND_MIXER_READ_LINE2:
529 k = OSS_PORT_AUDIO(drv, AUDIO_LINE_OUT);
530 return put_user(k, (int *)arg);
532 case SOUND_MIXER_WRITE_MIC:
533 case SOUND_MIXER_WRITE_CD:
534 case SOUND_MIXER_WRITE_LINE:
535 case SOUND_MIXER_WRITE_LINE1:
536 case SOUND_MIXER_WRITE_LINE2:
537 case SOUND_MIXER_WRITE_SPEAKER:
538 if (get_user(k, (int *)arg))
540 OSS_TWIDDLE_IPORT(drv, cmd, SOUND_MIXER_WRITE_LINE, AUDIO_LINE_IN, k);
541 OSS_TWIDDLE_IPORT(drv, cmd, SOUND_MIXER_WRITE_MIC, AUDIO_MICROPHONE, k);
542 OSS_TWIDDLE_IPORT(drv, cmd, SOUND_MIXER_WRITE_CD, AUDIO_CD, k);
544 OSS_TWIDDLE_PORT(drv, cmd, SOUND_MIXER_WRITE_SPEAKER, AUDIO_SPEAKER, k);
545 OSS_TWIDDLE_PORT(drv, cmd, SOUND_MIXER_WRITE_LINE1, AUDIO_HEADPHONE, k);
546 OSS_TWIDDLE_PORT(drv, cmd, SOUND_MIXER_WRITE_LINE2, AUDIO_LINE_OUT, k);
547 return put_user(k, (int *)arg);
548 case SOUND_MIXER_READ_RECSRC:
549 if (drv->ops->get_input_port)
550 i = drv->ops->get_input_port(drv);
552 /* only one should ever be selected */
553 if (i & AUDIO_CD) j = SOUND_MASK_CD;
554 if (i & AUDIO_LINE_IN) j = SOUND_MASK_LINE;
555 if (i & AUDIO_MICROPHONE) j = SOUND_MASK_MIC;
557 return put_user(j, (int *)arg);
558 case SOUND_MIXER_WRITE_RECSRC:
559 if (!drv->ops->set_input_port)
561 if (get_user(k, (int *)arg))
564 /* only one should ever be selected */
565 if (k & SOUND_MASK_CD) j = AUDIO_CD;
566 if (k & SOUND_MASK_LINE) j = AUDIO_LINE_IN;
567 if (k & SOUND_MASK_MIC) j = AUDIO_MICROPHONE;
568 oprintk(("setting inport to %d\n", j));
569 i = drv->ops->set_input_port(drv, j);
571 return put_user(i, (int *)arg);
572 case SOUND_MIXER_READ_RECMASK:
573 if (drv->ops->get_input_ports)
574 i = drv->ops->get_input_ports(drv);
575 /* what do we support? */
576 if (i & AUDIO_MICROPHONE) j |= SOUND_MASK_MIC;
577 if (i & AUDIO_LINE_IN) j |= SOUND_MASK_LINE;
578 if (i & AUDIO_CD) j |= SOUND_MASK_CD;
580 return put_user(j, (int *)arg);
581 case SOUND_MIXER_READ_CAPS: /* mixer capabilities */
582 i = SOUND_CAP_EXCL_INPUT;
583 return put_user(i, (int *)arg);
585 case SOUND_MIXER_READ_DEVMASK: /* all supported devices */
586 if (drv->ops->get_input_ports)
587 i = drv->ops->get_input_ports(drv);
588 /* what do we support? */
589 if (i & AUDIO_MICROPHONE) j |= SOUND_MASK_MIC;
590 if (i & AUDIO_LINE_IN) j |= SOUND_MASK_LINE;
591 if (i & AUDIO_CD) j |= SOUND_MASK_CD;
593 if (drv->ops->get_output_ports)
594 i = drv->ops->get_output_ports(drv);
595 if (i & AUDIO_SPEAKER) j |= SOUND_MASK_SPEAKER;
596 if (i & AUDIO_HEADPHONE) j |= SOUND_MASK_LINE1;
597 if (i & AUDIO_LINE_OUT) j |= SOUND_MASK_LINE2;
599 j |= SOUND_MASK_VOLUME;
601 case SOUND_MIXER_READ_STEREODEVS: /* what supports stereo */
602 j |= SOUND_MASK_PCM|SOUND_MASK_RECLEV;
604 if (cmd == SOUND_MIXER_READ_STEREODEVS)
605 j &= ~(MONO_DEVICES);
606 return put_user(j, (int *)arg);
612 /* AUDIO_SETINFO uses these to set values if possible. */
613 static __inline__ int
614 __sparcaudio_if_set_do(struct sparcaudio_driver *drv,
615 int (*set_function)(struct sparcaudio_driver *, int),
616 int (*get_function)(struct sparcaudio_driver *),
619 if (set_function && Modify(value))
620 return (int) set_function(drv, value);
621 else if (get_function)
622 return (int) get_function(drv);
627 static __inline__ int
628 __sparcaudio_if_setc_do(struct sparcaudio_driver *drv,
629 int (*set_function)(struct sparcaudio_driver *, int),
630 int (*get_function)(struct sparcaudio_driver *),
633 if (set_function && Modifyc(value))
634 return (char) set_function(drv, (int)value);
635 else if (get_function)
636 return (char) get_function(drv);
641 /* I_FLUSH, I_{G,S}ETSIG, I_NREAD provided for SunOS compatibility
643 * I must admit I'm quite ashamed of the state of the ioctl handling,
644 * but I do have several optimizations which I'm planning. -- DJB
646 static int sparcaudio_ioctl(struct inode * inode, struct file * file,
647 unsigned int cmd, unsigned long arg)
649 int retval = 0, i, j, k;
650 int minor = MINOR(inode->i_rdev);
651 struct audio_info ainfo;
652 audio_buf_info binfo;
654 struct sparcaudio_driver *drv =
655 drivers[(minor >> SPARCAUDIO_DEVICE_SHIFT)];
657 switch (minor & 0xf) {
658 case SPARCAUDIO_MIXER_MINOR:
659 return sparcaudio_mixer_ioctl(inode, file, cmd, (unsigned int *)arg);
660 case SPARCAUDIO_DSP16_MINOR:
661 case SPARCAUDIO_DSP_MINOR:
662 case SPARCAUDIO_AUDIO_MINOR:
663 case SPARCAUDIO_AUDIOCTL_MINOR:
664 /* According to the OSS prog int, you can mixer ioctl /dev/dsp */
665 if (_IOC_TYPE(cmd) == 'M')
666 return sparcaudio_mixer_ioctl(inode,
667 file, cmd, (unsigned int *)arg);
670 case I_GETSIG_SOLARIS:
671 j = (int) lis_get_elist_ent(drv->sd_siglist,current->pid);
672 put_user(j, (int *)arg);
673 retval = drv->input_count;
677 case I_SETSIG_SOLARIS:
678 if ((minor & 0xf) == SPARCAUDIO_AUDIOCTL_MINOR) {
680 if (lis_del_from_elist(&(drv->sd_siglist),
681 current->pid,S_ALL)) {
683 } else if (!drv->sd_siglist) {
686 } else if (lis_add_to_elist(&(drv->sd_siglist),
691 ((drv->sd_sigflags) |= (arg));
696 case I_NREAD_SOLARIS:
697 /* According to the Solaris man page, this copies out
698 * the size of the first streams buffer and returns
699 * the number of streams messages on the read queue as
700 * as its retval. (streamio(7I)) This should work.
702 j = (drv->input_count > 0) ? drv->input_buffer_size : 0;
703 put_user(j, (int *)arg);
704 retval = drv->input_count;
707 /* A poor substitute until we do true resizable buffers. */
708 case SNDCTL_DSP_GETISPACE:
709 binfo.fragstotal = drv->num_input_buffers;
710 binfo.fragments = drv->num_input_buffers -
711 (drv->input_count + drv->recording_count);
712 binfo.fragsize = drv->input_buffer_size;
713 binfo.bytes = binfo.fragments*binfo.fragsize;
715 retval = verify_area(VERIFY_WRITE, (int *)arg, sizeof(binfo));
718 copy_to_user(&((char *)arg)[0], (char *)&binfo, sizeof(binfo));
720 case SNDCTL_DSP_GETOSPACE:
721 binfo.fragstotal = drv->num_output_buffers;
722 binfo.fragments = drv->num_output_buffers -
723 (drv->output_count + drv->playing_count +
724 (drv->output_offset ? 1 : 0));
725 binfo.fragsize = drv->output_buffer_size;
726 binfo.bytes = binfo.fragments*binfo.fragsize +
727 (drv->output_buffer_size - drv->output_offset);
729 retval = verify_area(VERIFY_WRITE, (int *)arg, sizeof(binfo));
732 copy_to_user(&((char *)arg)[0], (char *)&binfo, sizeof(binfo));
734 case SNDCTL_DSP_GETIPTR:
735 case SNDCTL_DSP_GETOPTR:
736 /* int bytes (number of bytes read/written since last)
737 * int blocks (number of frags read/wrote since last call)
738 * int ptr (current position of dma in buffer)
744 cinfo.bytes += cinfo.ptr;
746 retval = verify_area(VERIFY_WRITE, (int *)arg, sizeof(cinfo));
749 copy_to_user(&((char *)arg)[0], (char *)&cinfo, sizeof(cinfo));
751 case SNDCTL_DSP_SETFRAGMENT:
752 /* XXX Small hack to get ESD/Enlightenment to work. --DaveM */
756 case SNDCTL_DSP_SUBDIVIDE:
757 /* I don't understand what I need to do yet. */
760 case SNDCTL_DSP_SETTRIGGER:
761 /* This may not be 100% correct */
762 if ((arg & PCM_ENABLE_INPUT) && drv->ops->get_input_pause &&
763 drv->ops->set_input_pause) {
764 if (drv->ops->get_input_pause(drv))
765 drv->ops->set_input_pause(drv, 0);
767 if (!drv->ops->get_input_pause(drv))
768 drv->ops->set_input_pause(drv, 1);
770 if ((arg & PCM_ENABLE_OUTPUT) && drv->ops->get_output_pause &&
771 drv->ops->set_output_pause) {
772 if (drv->ops->get_output_pause(drv))
773 drv->ops->set_output_pause(drv, 0);
775 if (!drv->ops->get_output_pause(drv))
776 drv->ops->set_output_pause(drv, 1);
779 case SNDCTL_DSP_GETTRIGGER:
781 if (drv->ops->get_input_pause) {
782 if (drv->ops->get_input_pause(drv))
783 j = PCM_ENABLE_INPUT;
785 if (drv->ops->get_output_pause) {
786 if (drv->ops->get_output_pause(drv))
787 j |= PCM_ENABLE_OUTPUT;
789 put_user(j, (int *)arg);
791 case SNDCTL_DSP_GETBLKSIZE:
792 j = drv->input_buffer_size;
793 put_user(j, (int *)arg);
795 case SNDCTL_DSP_SPEED:
796 if ((!drv->ops->set_output_rate) &&
797 (!drv->ops->set_input_rate)) {
801 get_user(i, (int *)arg)
802 tprintk(("setting speed to %d\n", i));
803 drv->ops->set_input_rate(drv, i);
804 drv->ops->set_output_rate(drv, i);
805 j = drv->ops->get_output_rate(drv);
806 put_user(j, (int *)arg);
808 case SNDCTL_DSP_GETCAPS:
809 /* All Sparc audio hardware is full duplex.
810 * 4231 supports DMA pointer reading, 7930 is byte at a time.
811 * Pause functionality emulates trigger
813 j = DSP_CAP_DUPLEX | DSP_CAP_TRIGGER | DSP_CAP_REALTIME;
814 put_user(j, (int *)arg);
816 case SNDCTL_DSP_GETFMTS:
817 if (drv->ops->get_formats) {
818 j = drv->ops->get_formats(drv);
819 put_user(j, (int *)arg);
824 case SNDCTL_DSP_SETFMT:
825 /* need to decode into encoding, precision */
826 get_user(i, (int *)arg);
828 /* handle special case here */
829 if (i == AFMT_QUERY) {
830 j = drv->ops->get_output_encoding(drv);
831 k = drv->ops->get_output_precision(drv);
832 if (j == AUDIO_ENCODING_DVI) {
836 case AUDIO_ENCODING_ULAW:
839 case AUDIO_ENCODING_ALAW:
842 case AUDIO_ENCODING_LINEAR8:
846 } else if (k == 16) {
848 case AUDIO_ENCODING_LINEAR:
851 case AUDIO_ENCODING_LINEARLE:
856 put_user(i, (int *)arg);
860 /* Without these there's no point in trying */
861 if (!drv->ops->set_input_precision ||
862 !drv->ops->set_input_encoding ||
863 !drv->ops->set_output_precision ||
864 !drv->ops->set_output_encoding) {
865 eprintk(("missing set routines: failed\n"));
870 if (drv->ops->get_formats) {
871 if (!(drv->ops->get_formats(drv) & i)) {
872 dprintk(("format not supported\n"));
878 ainfo.record.precision = ainfo.play.precision = 16;
879 ainfo.record.encoding = ainfo.play.encoding =
880 AUDIO_ENCODING_LINEARLE;
883 ainfo.record.precision = ainfo.play.precision = 16;
884 ainfo.record.encoding = ainfo.play.encoding =
885 AUDIO_ENCODING_LINEAR;
888 ainfo.record.precision = ainfo.play.precision = 8;
889 ainfo.record.encoding = ainfo.play.encoding =
893 ainfo.record.precision = ainfo.play.precision = 8;
894 ainfo.record.encoding = ainfo.play.encoding =
898 ainfo.record.precision = ainfo.play.precision = 8;
899 ainfo.record.encoding = ainfo.play.encoding =
900 AUDIO_ENCODING_LINEAR8;
903 tprintk(("setting fmt to enc %d pr %d\n",
905 ainfo.play.precision));
906 if ((drv->ops->set_input_precision(drv,
907 ainfo.record.precision)
909 (drv->ops->set_output_precision(drv,
910 ainfo.play.precision)
912 (drv->ops->set_input_encoding(drv,
913 ainfo.record.encoding)
915 (drv->ops->set_output_encoding(drv,
918 dprintk(("setting format: failed\n"));
921 put_user(i, (int *)arg);
923 case SNDCTL_DSP_CHANNELS:
924 if ((!drv->ops->set_output_channels) &&
925 (!drv->ops->set_input_channels)) {
929 get_user(i, (int *)arg);
930 drv->ops->set_input_channels(drv, i);
931 drv->ops->set_output_channels(drv, i);
932 i = drv->ops->get_output_channels(drv);
933 put_user(i, (int *)arg);
935 case SNDCTL_DSP_STEREO:
936 if ((!drv->ops->set_output_channels) &&
937 (!drv->ops->set_input_channels)) {
941 get_user(i, (int *)arg);
942 drv->ops->set_input_channels(drv, (i + 1));
943 drv->ops->set_output_channels(drv, (i + 1));
944 i = ((drv->ops->get_output_channels(drv)) - 1);
945 put_user(i, (int *)arg);
947 case SNDCTL_DSP_POST:
948 case SNDCTL_DSP_SYNC:
950 /* Deal with weirdness so we can fill buffers */
951 if (drv->output_offset) {
952 drv->output_offset = 0;
953 drv->output_rear = (drv->output_rear + 1)
954 % drv->num_output_buffers;
957 if (drv->output_count > 0) {
958 sparcaudio_sync_output(drv);
959 /* Only pause for DRAIN/SYNC, not POST */
960 if (cmd != SNDCTL_DSP_POST) {
961 interruptible_sleep_on(&drv->output_drain_wait);
962 retval = (signal_pending(current)) ? -EINTR : 0;
967 case I_FLUSH_SOLARIS:
968 if (((unsigned int)arg == FLUSHW) ||
969 ((unsigned int)arg == FLUSHRW)) {
970 if (file->f_mode & FMODE_WRITE) {
971 sparcaudio_sync_output(drv);
972 if (drv->output_active) {
973 wake_up_interruptible(&drv->output_write_wait);
974 drv->ops->stop_output(drv);
976 drv->output_offset = 0;
977 drv->output_active = 0;
978 drv->output_front = 0;
979 drv->output_rear = 0;
980 drv->output_count = 0;
981 drv->output_size = 0;
982 drv->playing_count = 0;
986 if (((unsigned int)arg == FLUSHR) ||
987 ((unsigned int)arg == FLUSHRW)) {
988 if (drv->input_active && (file->f_mode & FMODE_READ)) {
989 wake_up_interruptible(&drv->input_read_wait);
990 drv->ops->stop_input(drv);
991 drv->input_active = 0;
992 drv->input_front = 0;
994 drv->input_count = 0;
996 drv->input_offset = 0;
997 drv->recording_count = 0;
999 if ((file->f_mode & FMODE_READ) &&
1000 (drv->flags & SDF_OPEN_READ)) {
1001 if (drv->duplex == 2)
1002 drv->input_count = drv->output_count;
1003 drv->ops->start_input(drv,
1004 drv->input_buffers[drv->input_front],
1005 drv->input_buffer_size);
1006 drv->input_active = 1;
1009 if (((unsigned int)arg == FLUSHW) ||
1010 ((unsigned int)arg == FLUSHRW)) {
1011 if ((file->f_mode & FMODE_WRITE) &&
1012 !(drv->flags & SDF_OPEN_WRITE)) {
1013 kill_procs(drv->sd_siglist,SIGPOLL,S_MSG);
1014 sparcaudio_sync_output(drv);
1018 case SNDCTL_DSP_RESET:
1020 if (drv->output_active && (file->f_mode & FMODE_WRITE)) {
1021 wake_up_interruptible(&drv->output_write_wait);
1022 drv->ops->stop_output(drv);
1023 drv->output_active = 0;
1024 drv->output_front = 0;
1025 drv->output_rear = 0;
1026 drv->output_count = 0;
1027 drv->output_size = 0;
1028 drv->playing_count = 0;
1029 drv->output_offset = 0;
1030 drv->output_eof = 0;
1032 if (drv->input_active && (file->f_mode & FMODE_READ)) {
1033 wake_up_interruptible(&drv->input_read_wait);
1034 drv->ops->stop_input(drv);
1035 drv->input_active = 0;
1036 drv->input_front = 0;
1037 drv->input_rear = 0;
1038 drv->input_count = 0;
1039 drv->input_size = 0;
1040 drv->input_offset = 0;
1041 drv->recording_count = 0;
1043 if ((file->f_mode & FMODE_READ) &&
1044 !(drv->flags & SDF_OPEN_READ)) {
1045 drv->ops->start_input(drv,
1046 drv->input_buffers[drv->input_front],
1047 drv->input_buffer_size);
1048 drv->input_active = 1;
1050 if ((file->f_mode & FMODE_WRITE) &&
1051 !(drv->flags & SDF_OPEN_WRITE)) {
1052 sparcaudio_sync_output(drv);
1056 if (drv->ops->sunaudio_getdev) {
1059 retval = verify_area(VERIFY_WRITE, (void *)arg,
1060 sizeof(audio_device_t));
1062 drv->ops->sunaudio_getdev(drv, &tmp);
1063 copy_to_user((audio_device_t *)arg, &tmp, sizeof(tmp));
1068 case AUDIO_GETDEV_SUNOS:
1069 if (drv->ops->sunaudio_getdev_sunos) {
1070 int tmp = drv->ops->sunaudio_getdev_sunos(drv);
1072 retval = verify_area(VERIFY_WRITE, (void *)arg, sizeof(int));
1074 copy_to_user((int *)arg, &tmp, sizeof(tmp));
1080 AUDIO_INITINFO(&ainfo);
1082 if (drv->ops->get_input_rate)
1083 ainfo.record.sample_rate =
1084 drv->ops->get_input_rate(drv);
1086 ainfo.record.sample_rate = (8000);
1087 if (drv->ops->get_input_channels)
1088 ainfo.record.channels =
1089 drv->ops->get_input_channels(drv);
1091 ainfo.record.channels = (1);
1092 if (drv->ops->get_input_precision)
1093 ainfo.record.precision =
1094 drv->ops->get_input_precision(drv);
1096 ainfo.record.precision = (8);
1097 if (drv->ops->get_input_encoding)
1098 ainfo.record.encoding =
1099 drv->ops->get_input_encoding(drv);
1101 ainfo.record.encoding = (AUDIO_ENCODING_ULAW);
1102 if (drv->ops->get_input_volume)
1104 drv->ops->get_input_volume(drv);
1106 ainfo.record.gain = (0);
1107 if (drv->ops->get_input_port)
1109 drv->ops->get_input_port(drv);
1111 ainfo.record.port = (0);
1112 if (drv->ops->get_input_ports)
1113 ainfo.record.avail_ports =
1114 drv->ops->get_input_ports(drv);
1116 ainfo.record.avail_ports = (0);
1118 /* To make e.g. vat happy, we let them think they control this */
1119 ainfo.record.buffer_size = drv->buffer_size;
1120 if (drv->ops->get_input_samples)
1121 ainfo.record.samples = drv->ops->get_input_samples(drv);
1123 ainfo.record.samples = 0;
1125 /* This is undefined in the record context in Solaris */
1126 ainfo.record.eof = 0;
1127 if (drv->ops->get_input_pause)
1128 ainfo.record.pause =
1129 drv->ops->get_input_pause(drv);
1131 ainfo.record.pause = 0;
1132 if (drv->ops->get_input_error)
1133 ainfo.record.error =
1134 (unsigned char) drv->ops->get_input_error(drv);
1136 ainfo.record.error = 0;
1137 ainfo.record.waiting = 0;
1138 if (drv->ops->get_input_balance)
1139 ainfo.record.balance =
1140 (unsigned char) drv->ops->get_input_balance(drv);
1142 ainfo.record.balance = (unsigned char)(AUDIO_MID_BALANCE);
1143 ainfo.record.minordev = 4 + (minor << SPARCAUDIO_DEVICE_SHIFT);
1144 ainfo.record.open = (drv->flags & SDF_OPEN_READ);
1145 ainfo.record.active = 0;
1147 if (drv->ops->get_output_rate)
1148 ainfo.play.sample_rate =
1149 drv->ops->get_output_rate(drv);
1151 ainfo.play.sample_rate = (8000);
1152 if (drv->ops->get_output_channels)
1153 ainfo.play.channels =
1154 drv->ops->get_output_channels(drv);
1156 ainfo.play.channels = (1);
1157 if (drv->ops->get_output_precision)
1158 ainfo.play.precision =
1159 drv->ops->get_output_precision(drv);
1161 ainfo.play.precision = (8);
1162 if (drv->ops->get_output_encoding)
1163 ainfo.play.encoding =
1164 drv->ops->get_output_encoding(drv);
1166 ainfo.play.encoding = (AUDIO_ENCODING_ULAW);
1167 if (drv->ops->get_output_volume)
1169 drv->ops->get_output_volume(drv);
1171 ainfo.play.gain = (0);
1172 if (drv->ops->get_output_port)
1174 drv->ops->get_output_port(drv);
1176 ainfo.play.port = (0);
1177 if (drv->ops->get_output_ports)
1178 ainfo.play.avail_ports =
1179 drv->ops->get_output_ports(drv);
1181 ainfo.play.avail_ports = (0);
1183 /* This is not defined in the play context in Solaris */
1184 ainfo.play.buffer_size = 0;
1185 if (drv->ops->get_output_samples)
1186 ainfo.play.samples = drv->ops->get_output_samples(drv);
1188 ainfo.play.samples = 0;
1189 ainfo.play.eof = drv->output_eof;
1190 if (drv->ops->get_output_pause)
1192 drv->ops->get_output_pause(drv);
1194 ainfo.play.pause = 0;
1195 if (drv->ops->get_output_error)
1197 (unsigned char)drv->ops->get_output_error(drv);
1199 ainfo.play.error = 0;
1200 ainfo.play.waiting = waitqueue_active(&drv->open_wait);
1201 if (drv->ops->get_output_balance)
1202 ainfo.play.balance =
1203 (unsigned char)drv->ops->get_output_balance(drv);
1205 ainfo.play.balance = (unsigned char)(AUDIO_MID_BALANCE);
1206 ainfo.play.minordev = 4 + (minor << SPARCAUDIO_DEVICE_SHIFT);
1207 ainfo.play.open = (drv->flags & SDF_OPEN_WRITE);
1208 ainfo.play.active = drv->output_active;
1210 if (drv->ops->get_monitor_volume)
1211 ainfo.monitor_gain =
1212 drv->ops->get_monitor_volume(drv);
1214 ainfo.monitor_gain = (0);
1216 if (drv->ops->get_output_muted)
1217 ainfo.output_muted =
1218 (unsigned char)drv->ops->get_output_muted(drv);
1220 ainfo.output_muted = (unsigned char)(0);
1222 retval = verify_area(VERIFY_WRITE, (void *)arg,
1223 sizeof(struct audio_info));
1227 copy_to_user((struct audio_info *)arg, &ainfo, sizeof(ainfo));
1231 audio_info_t curinfo, newinfo;
1233 if (verify_area(VERIFY_READ, (audio_info_t *)arg,
1234 sizeof(audio_info_t))) {
1235 dprintk(("verify_area failed\n"));
1238 copy_from_user(&ainfo, (audio_info_t *)arg, sizeof(audio_info_t));
1240 /* Without these there's no point in trying */
1241 if (!drv->ops->get_input_precision ||
1242 !drv->ops->get_input_channels ||
1243 !drv->ops->get_input_rate ||
1244 !drv->ops->get_input_encoding ||
1245 !drv->ops->get_output_precision ||
1246 !drv->ops->get_output_channels ||
1247 !drv->ops->get_output_rate ||
1248 !drv->ops->get_output_encoding) {
1249 eprintk(("missing get routines: failed\n"));
1254 /* Do bounds checking for things which always apply.
1255 * Follow with enforcement of basic tenets of certain
1256 * encodings. Everything over and above generic is
1257 * enforced by the driver, which can assume that
1258 * Martian cases are taken care of here.
1260 if (Modify(ainfo.play.gain) &&
1261 ((ainfo.play.gain > AUDIO_MAX_GAIN) ||
1262 (ainfo.play.gain < AUDIO_MIN_GAIN))) {
1263 /* Need to differentiate this from e.g. the above error */
1264 eprintk(("play gain bounds: failed %d\n", ainfo.play.gain));
1268 if (Modify(ainfo.record.gain) &&
1269 ((ainfo.record.gain > AUDIO_MAX_GAIN) ||
1270 (ainfo.record.gain < AUDIO_MIN_GAIN))) {
1271 eprintk(("rec gain bounds: failed %d\n", ainfo.record.gain));
1275 if (Modify(ainfo.monitor_gain) &&
1276 ((ainfo.monitor_gain > AUDIO_MAX_GAIN) ||
1277 (ainfo.monitor_gain < AUDIO_MIN_GAIN))) {
1278 eprintk(("monitor gain bounds: failed\n"));
1283 /* Don't need to check less than zero on these */
1284 if (Modifyc(ainfo.play.balance) &&
1285 (ainfo.play.balance > AUDIO_RIGHT_BALANCE)) {
1286 eprintk(("play balance bounds: %d failed\n",
1287 (int)ainfo.play.balance));
1291 if (Modifyc(ainfo.record.balance) &&
1292 (ainfo.record.balance > AUDIO_RIGHT_BALANCE)) {
1293 eprintk(("rec balance bounds: failed\n"));
1298 /* If any of these changed, record them all, then make
1299 * changes atomically. If something fails, back it all out.
1301 if (Modify(ainfo.record.precision) ||
1302 Modify(ainfo.record.sample_rate) ||
1303 Modify(ainfo.record.channels) ||
1304 Modify(ainfo.record.encoding) ||
1305 Modify(ainfo.play.precision) ||
1306 Modify(ainfo.play.sample_rate) ||
1307 Modify(ainfo.play.channels) ||
1308 Modify(ainfo.play.encoding)) {
1309 /* If they're trying to change something we
1310 * have no routine for, they lose.
1312 if ((!drv->ops->set_input_encoding &&
1313 Modify(ainfo.record.encoding)) ||
1314 (!drv->ops->set_input_rate &&
1315 Modify(ainfo.record.sample_rate)) ||
1316 (!drv->ops->set_input_precision &&
1317 Modify(ainfo.record.precision)) ||
1318 (!drv->ops->set_input_channels &&
1319 Modify(ainfo.record.channels))) {
1320 eprintk(("rec set no routines: failed\n"));
1325 curinfo.record.encoding =
1326 drv->ops->get_input_encoding(drv);
1327 curinfo.record.sample_rate =
1328 drv->ops->get_input_rate(drv);
1329 curinfo.record.precision =
1330 drv->ops->get_input_precision(drv);
1331 curinfo.record.channels =
1332 drv->ops->get_input_channels(drv);
1333 newinfo.record.encoding =
1334 Modify(ainfo.record.encoding) ?
1335 ainfo.record.encoding :
1336 curinfo.record.encoding;
1337 newinfo.record.sample_rate =
1338 Modify(ainfo.record.sample_rate) ?
1339 ainfo.record.sample_rate :
1340 curinfo.record.sample_rate;
1341 newinfo.record.precision =
1342 Modify(ainfo.record.precision) ?
1343 ainfo.record.precision :
1344 curinfo.record.precision;
1345 newinfo.record.channels =
1346 Modify(ainfo.record.channels) ?
1347 ainfo.record.channels :
1348 curinfo.record.channels;
1350 switch (newinfo.record.encoding) {
1351 case AUDIO_ENCODING_ALAW:
1352 case AUDIO_ENCODING_ULAW:
1353 if (newinfo.record.precision != 8) {
1354 eprintk(("rec law precision bounds: "
1359 if (newinfo.record.channels != 1) {
1360 eprintk(("rec law channel bounds: "
1366 case AUDIO_ENCODING_LINEAR:
1367 case AUDIO_ENCODING_LINEARLE:
1368 if (newinfo.record.precision != 16) {
1369 eprintk(("rec lin precision bounds: "
1374 if (newinfo.record.channels != 1 &&
1375 newinfo.record.channels != 2) {
1376 eprintk(("rec lin channel bounds: "
1382 case AUDIO_ENCODING_LINEAR8:
1383 if (newinfo.record.precision != 8) {
1384 eprintk(("rec lin8 precision bounds: "
1389 if (newinfo.record.channels != 1 &&
1390 newinfo.record.channels != 2) {
1391 eprintk(("rec lin8 channel bounds: "
1401 /* If they're trying to change something we
1402 * have no routine for, they lose.
1404 if ((!drv->ops->set_output_encoding &&
1405 Modify(ainfo.play.encoding)) ||
1406 (!drv->ops->set_output_rate &&
1407 Modify(ainfo.play.sample_rate)) ||
1408 (!drv->ops->set_output_precision &&
1409 Modify(ainfo.play.precision)) ||
1410 (!drv->ops->set_output_channels &&
1411 Modify(ainfo.play.channels))) {
1412 eprintk(("play set no routine: failed\n"));
1417 curinfo.play.encoding =
1418 drv->ops->get_output_encoding(drv);
1419 curinfo.play.sample_rate =
1420 drv->ops->get_output_rate(drv);
1421 curinfo.play.precision =
1422 drv->ops->get_output_precision(drv);
1423 curinfo.play.channels =
1424 drv->ops->get_output_channels(drv);
1425 newinfo.play.encoding =
1426 Modify(ainfo.play.encoding) ?
1427 ainfo.play.encoding :
1428 curinfo.play.encoding;
1429 newinfo.play.sample_rate =
1430 Modify(ainfo.play.sample_rate) ?
1431 ainfo.play.sample_rate :
1432 curinfo.play.sample_rate;
1433 newinfo.play.precision =
1434 Modify(ainfo.play.precision) ?
1435 ainfo.play.precision :
1436 curinfo.play.precision;
1437 newinfo.play.channels =
1438 Modify(ainfo.play.channels) ?
1439 ainfo.play.channels :
1440 curinfo.play.channels;
1442 switch (newinfo.play.encoding) {
1443 case AUDIO_ENCODING_ALAW:
1444 case AUDIO_ENCODING_ULAW:
1445 if (newinfo.play.precision != 8) {
1446 eprintk(("play law precision bounds: "
1451 if (newinfo.play.channels != 1) {
1452 eprintk(("play law channel bounds: "
1458 case AUDIO_ENCODING_LINEAR:
1459 case AUDIO_ENCODING_LINEARLE:
1460 if (newinfo.play.precision != 16) {
1461 eprintk(("play lin precision bounds: "
1466 if (newinfo.play.channels != 1 &&
1467 newinfo.play.channels != 2) {
1468 eprintk(("play lin channel bounds: "
1474 case AUDIO_ENCODING_LINEAR8:
1475 if (newinfo.play.precision != 8) {
1476 eprintk(("play lin8 precision bounds: "
1481 if (newinfo.play.channels != 1 &&
1482 newinfo.play.channels != 2) {
1483 eprintk(("play lin8 channel bounds: "
1493 /* If we got this far, we're at least sane with
1494 * respect to generics. Try the changes.
1496 if ((drv->ops->set_input_channels &&
1497 (drv->ops->set_input_channels(drv,
1498 newinfo.record.channels)
1500 (drv->ops->set_output_channels &&
1501 (drv->ops->set_output_channels(drv,
1502 newinfo.play.channels)
1504 (drv->ops->set_input_rate &&
1505 (drv->ops->set_input_rate(drv,
1506 newinfo.record.sample_rate)
1508 (drv->ops->set_output_rate &&
1509 (drv->ops->set_output_rate(drv,
1510 newinfo.play.sample_rate)
1512 (drv->ops->set_input_precision &&
1513 (drv->ops->set_input_precision(drv,
1514 newinfo.record.precision)
1516 (drv->ops->set_output_precision &&
1517 (drv->ops->set_output_precision(drv,
1518 newinfo.play.precision)
1520 (drv->ops->set_input_encoding &&
1521 (drv->ops->set_input_encoding(drv,
1522 newinfo.record.encoding)
1524 (drv->ops->set_output_encoding &&
1525 (drv->ops->set_output_encoding(drv,
1526 newinfo.play.encoding)
1529 dprintk(("setting format: failed\n"));
1530 /* Pray we can set it all back. If not, uh... */
1531 if (drv->ops->set_input_channels)
1532 drv->ops->set_input_channels(drv,
1533 curinfo.record.channels);
1534 if (drv->ops->set_output_channels)
1535 drv->ops->set_output_channels(drv,
1536 curinfo.play.channels);
1537 if (drv->ops->set_input_rate)
1538 drv->ops->set_input_rate(drv,
1539 curinfo.record.sample_rate);
1540 if (drv->ops->set_output_rate)
1541 drv->ops->set_output_rate(drv,
1542 curinfo.play.sample_rate);
1543 if (drv->ops->set_input_precision)
1544 drv->ops->set_input_precision(drv,
1545 curinfo.record.precision);
1546 if (drv->ops->set_output_precision)
1547 drv->ops->set_output_precision(drv,
1548 curinfo.play.precision);
1549 if (drv->ops->set_input_encoding)
1550 drv->ops->set_input_encoding(drv,
1551 curinfo.record.encoding);
1552 if (drv->ops->set_output_encoding)
1553 drv->ops->set_output_encoding(drv,
1554 curinfo.play.encoding);
1563 newinfo.record.balance =
1564 __sparcaudio_if_setc_do(drv,
1565 drv->ops->set_input_balance,
1566 drv->ops->get_input_balance,
1567 ainfo.record.balance);
1568 newinfo.play.balance =
1569 __sparcaudio_if_setc_do(drv,
1570 drv->ops->set_output_balance,
1571 drv->ops->get_output_balance,
1572 ainfo.play.balance);
1573 newinfo.record.error =
1574 __sparcaudio_if_setc_do(drv,
1575 drv->ops->set_input_error,
1576 drv->ops->get_input_error,
1577 ainfo.record.error);
1578 newinfo.play.error =
1579 __sparcaudio_if_setc_do(drv,
1580 drv->ops->set_output_error,
1581 drv->ops->get_output_error,
1583 newinfo.output_muted =
1584 __sparcaudio_if_setc_do(drv,
1585 drv->ops->set_output_muted,
1586 drv->ops->get_output_muted,
1587 ainfo.output_muted);
1588 newinfo.record.gain =
1589 __sparcaudio_if_set_do(drv,
1590 drv->ops->set_input_volume,
1591 drv->ops->get_input_volume,
1594 __sparcaudio_if_set_do(drv,
1595 drv->ops->set_output_volume,
1596 drv->ops->get_output_volume,
1598 newinfo.record.port =
1599 __sparcaudio_if_set_do(drv,
1600 drv->ops->set_input_port,
1601 drv->ops->get_input_port,
1604 __sparcaudio_if_set_do(drv,
1605 drv->ops->set_output_port,
1606 drv->ops->get_output_port,
1608 newinfo.record.samples =
1609 __sparcaudio_if_set_do(drv,
1610 drv->ops->set_input_samples,
1611 drv->ops->get_input_samples,
1612 ainfo.record.samples);
1613 newinfo.play.samples =
1614 __sparcaudio_if_set_do(drv,
1615 drv->ops->set_output_samples,
1616 drv->ops->get_output_samples,
1617 ainfo.play.samples);
1618 newinfo.monitor_gain =
1619 __sparcaudio_if_set_do(drv,
1620 drv->ops->set_monitor_volume,
1621 drv->ops->get_monitor_volume,
1622 ainfo.monitor_gain);
1624 if (Modify(ainfo.record.buffer_size)) {
1625 /* Should sanity check this */
1626 newinfo.record.buffer_size = ainfo.record.buffer_size;
1627 drv->buffer_size = ainfo.record.buffer_size;
1629 newinfo.record.buffer_size = drv->buffer_size;
1632 if (Modify(ainfo.play.eof)) {
1633 ainfo.play.eof = newinfo.play.eof;
1634 newinfo.play.eof = drv->output_eof;
1635 drv->output_eof = ainfo.play.eof;
1637 newinfo.play.eof = drv->output_eof;
1640 if (drv->flags & SDF_OPEN_READ) {
1641 newinfo.record.pause =
1642 __sparcaudio_if_setc_do(drv,
1643 drv->ops->set_input_pause,
1644 drv->ops->get_input_pause,
1645 ainfo.record.pause);
1646 } else if (drv->ops->get_input_pause) {
1647 newinfo.record.pause = drv->ops->get_input_pause(drv);
1649 newinfo.record.pause = 0;
1652 if (drv->flags & SDF_OPEN_WRITE) {
1653 newinfo.play.pause =
1654 __sparcaudio_if_setc_do(drv,
1655 drv->ops->set_output_pause,
1656 drv->ops->get_output_pause,
1658 } else if (drv->ops->get_output_pause) {
1659 newinfo.play.pause = drv->ops->get_output_pause(drv);
1661 newinfo.play.pause = 0;
1664 retval = verify_area(VERIFY_WRITE, (void *)arg,
1665 sizeof(struct audio_info));
1667 /* Even if we fail, if we made changes let's try notification */
1669 copy_to_user((struct audio_info *)arg, &newinfo,
1672 #ifdef REAL_AUDIO_SIGNALS
1673 kill_procs(drv->sd_siglist,SIGPOLL,S_MSG);
1679 if (drv->ops->ioctl)
1680 retval = drv->ops->ioctl(inode,file,cmd,arg,drv);
1685 case SPARCAUDIO_STATUS_MINOR:
1686 eprintk(("status minor not yet implemented\n"));
1689 eprintk(("unknown minor device number\n"));
1696 static struct file_operations sparcaudioctl_fops = {
1698 poll: sparcaudio_poll,
1699 ioctl: sparcaudio_ioctl,
1702 static int sparcaudio_open(struct inode * inode, struct file * file)
1704 int minor = MINOR(inode->i_rdev);
1705 struct sparcaudio_driver *drv =
1706 drivers[(minor >> SPARCAUDIO_DEVICE_SHIFT)];
1709 /* A low-level audio driver must exist. */
1714 /* This is how 2.0 ended up dealing with 0 len writes */
1715 inode->i_flags |= S_ZERO_WR;
1718 switch (minor & 0xf) {
1719 case SPARCAUDIO_AUDIOCTL_MINOR:
1720 file->f_op = &sparcaudioctl_fops;
1722 case SPARCAUDIO_DSP16_MINOR:
1723 case SPARCAUDIO_DSP_MINOR:
1724 case SPARCAUDIO_AUDIO_MINOR:
1725 /* If the driver is busy, then wait to get through. */
1727 if (file->f_mode & FMODE_READ && drv->flags & SDF_OPEN_READ) {
1728 if (file->f_flags & O_NONBLOCK)
1731 /* If something is now waiting, signal control device */
1732 kill_procs(drv->sd_siglist,SIGPOLL,S_MSG);
1734 interruptible_sleep_on(&drv->open_wait);
1735 if (signal_pending(current))
1739 if (file->f_mode & FMODE_WRITE && drv->flags & SDF_OPEN_WRITE) {
1740 if (file->f_flags & O_NONBLOCK)
1743 /* If something is now waiting, signal control device */
1744 kill_procs(drv->sd_siglist,SIGPOLL,S_MSG);
1746 interruptible_sleep_on(&drv->open_wait);
1747 if (signal_pending(current))
1752 /* Allow the low-level driver to initialize itself. */
1753 if (drv->ops->open) {
1754 err = drv->ops->open(inode,file,drv);
1759 /* Mark the driver as locked for read and/or write. */
1760 if (file->f_mode & FMODE_READ) {
1761 drv->input_offset = 0;
1762 drv->input_front = 0;
1763 drv->input_rear = 0;
1764 drv->input_count = 0;
1765 drv->input_size = 0;
1766 drv->recording_count = 0;
1769 if (drv->ops->set_input_pause)
1770 drv->ops->set_input_pause(drv, 0);
1771 drv->ops->start_input(drv, drv->input_buffers[drv->input_front],
1772 drv->input_buffer_size);
1773 drv->input_active = 1;
1774 drv->flags |= SDF_OPEN_READ;
1777 if (file->f_mode & FMODE_WRITE) {
1778 drv->output_offset = 0;
1779 drv->output_eof = 0;
1780 drv->playing_count = 0;
1781 drv->output_size = 0;
1782 drv->output_front = 0;
1783 drv->output_rear = 0;
1784 drv->output_count = 0;
1785 drv->output_active = 0;
1788 if (drv->ops->set_output_pause)
1789 drv->ops->set_output_pause(drv, 0);
1790 drv->flags |= SDF_OPEN_WRITE;
1794 case SPARCAUDIO_MIXER_MINOR:
1795 file->f_op = &sparcaudioctl_fops;
1802 /* From the dbri driver:
1803 * SunOS 5.5.1 audio(7I) man page says:
1804 * "Upon the initial open() of the audio device, the driver
1805 * will reset the data format of the device to the default
1806 * state of 8-bit, 8KHz, mono u-law data."
1808 * Of course, we only do this for /dev/audio, and assume
1809 * OSS semantics on /dev/dsp
1812 if ((minor & 0xf) == SPARCAUDIO_AUDIO_MINOR) {
1813 if (file->f_mode & FMODE_WRITE) {
1814 if (drv->ops->set_output_channels)
1815 drv->ops->set_output_channels(drv, 1);
1816 if (drv->ops->set_output_encoding)
1817 drv->ops->set_output_encoding(drv, AUDIO_ENCODING_ULAW);
1818 if (drv->ops->set_output_rate)
1819 drv->ops->set_output_rate(drv, 8000);
1822 if (file->f_mode & FMODE_READ) {
1823 if (drv->ops->set_input_channels)
1824 drv->ops->set_input_channels(drv, 1);
1825 if (drv->ops->set_input_encoding)
1826 drv->ops->set_input_encoding(drv, AUDIO_ENCODING_ULAW);
1827 if (drv->ops->set_input_rate)
1828 drv->ops->set_input_rate(drv, 8000);
1836 static int sparcaudio_release(struct inode * inode, struct file * file)
1838 struct sparcaudio_driver *drv = drivers[(MINOR(inode->i_rdev) >>
1839 SPARCAUDIO_DEVICE_SHIFT)];
1842 if (file->f_mode & FMODE_READ) {
1844 drv->ops->stop_input(drv);
1845 drv->input_active = 0;
1848 if (file->f_mode & FMODE_WRITE) {
1849 /* Anything in the queue? */
1850 if (drv->output_offset) {
1851 drv->output_offset = 0;
1852 drv->output_rear = (drv->output_rear + 1)
1853 % drv->num_output_buffers;
1854 drv->output_count++;
1856 sparcaudio_sync_output(drv);
1858 /* Wait for any output still in the queue to be played. */
1859 if ((drv->output_count > 0) || (drv->playing_count > 0))
1860 interruptible_sleep_on(&drv->output_drain_wait);
1862 /* Force any output to be stopped. */
1863 drv->ops->stop_output(drv);
1864 drv->output_active = 0;
1865 drv->playing_count = 0;
1866 drv->output_eof = 0;
1869 /* Let the low-level driver do any release processing. */
1870 if (drv->ops->release)
1871 drv->ops->release(inode,file,drv);
1873 if (file->f_mode & FMODE_READ)
1874 drv->flags &= ~(SDF_OPEN_READ);
1876 if (file->f_mode & FMODE_WRITE)
1877 drv->flags &= ~(SDF_OPEN_WRITE);
1879 /* Status changed. Signal control device */
1880 kill_procs(drv->sd_siglist,SIGPOLL,S_MSG);
1882 wake_up_interruptible(&drv->open_wait);
1888 static struct file_operations sparcaudio_fops = {
1891 read: sparcaudio_read,
1892 write: sparcaudio_write,
1893 poll: sparcaudio_poll,
1894 ioctl: sparcaudio_ioctl,
1895 open: sparcaudio_open,
1896 release: sparcaudio_release,
1900 unsigned short minor;
1904 { SPARCAUDIO_MIXER_MINOR, "mixer", S_IWUSR | S_IRUGO },
1905 { SPARCAUDIO_DSP_MINOR, "dsp", S_IWUGO | S_IRUSR | S_IRGRP },
1906 { SPARCAUDIO_AUDIO_MINOR, "audio", S_IWUGO | S_IRUSR | S_IRGRP },
1907 { SPARCAUDIO_DSP16_MINOR, "dspW", S_IWUGO | S_IRUSR | S_IRGRP },
1908 { SPARCAUDIO_STATUS_MINOR, "status", S_IRUGO },
1909 { SPARCAUDIO_AUDIOCTL_MINOR, "audioctl", S_IRUGO }
1912 static void sparcaudio_mkname (char *buf, char *name, int dev)
1915 sprintf (buf, "%s%d", name, dev);
1917 sprintf (buf, "%s", name);
1920 int register_sparcaudio_driver(struct sparcaudio_driver *drv, int duplex)
1923 unsigned short minor;
1926 /* If we've used up SPARCAUDIO_MAX_DEVICES, fail */
1927 for (dev = 0; dev < SPARCAUDIO_MAX_DEVICES; dev++) {
1928 if (drivers[dev] == NULL)
1935 /* Ensure that the driver has a proper operations structure. */
1936 if (!drv->ops || !drv->ops->start_output || !drv->ops->stop_output ||
1937 !drv->ops->start_input || !drv->ops->stop_input)
1940 /* Register ourselves with devfs */
1941 for (i=0; i < sizeof (dev_list) / sizeof (*dev_list); i++) {
1942 sparcaudio_mkname (name_buf, dev_list[i].name, dev);
1943 minor = (dev << SPARCAUDIO_DEVICE_SHIFT) | dev_list[i].minor;
1944 devfs_register (devfs_handle, name_buf, DEVFS_FL_NONE,
1945 SOUND_MAJOR, minor, S_IFCHR | dev_list[i].mode,
1946 &sparcaudio_fops, NULL);
1949 /* Setup the circular queues of output and input buffers
1951 * Each buffer is a single page, but output buffers might
1952 * be partially filled (by a write with count < output_buffer_size),
1953 * so each output buffer also has a paired output size.
1955 * Input buffers, on the other hand, always fill completely,
1956 * so we don't need input counts - each contains input_buffer_size
1957 * bytes of audio data.
1959 * TODO: Make number of input/output buffers tunable parameters
1962 init_waitqueue_head(&drv->open_wait);
1963 init_waitqueue_head(&drv->output_write_wait);
1964 init_waitqueue_head(&drv->output_drain_wait);
1965 init_waitqueue_head(&drv->input_read_wait);
1967 drv->num_output_buffers = 8;
1968 drv->output_buffer_size = (4096 * 2);
1969 drv->playing_count = 0;
1970 drv->output_offset = 0;
1971 drv->output_eof = 0;
1972 drv->output_front = 0;
1973 drv->output_rear = 0;
1974 drv->output_count = 0;
1975 drv->output_active = 0;
1976 drv->output_buffers = kmalloc(drv->num_output_buffers *
1977 sizeof(__u8 *), GFP_KERNEL);
1978 drv->output_sizes = kmalloc(drv->num_output_buffers *
1979 sizeof(size_t), GFP_KERNEL);
1980 drv->output_notify = kmalloc(drv->num_output_buffers *
1981 sizeof(char), GFP_KERNEL);
1982 if (!drv->output_buffers || !drv->output_sizes || !drv->output_notify)
1983 goto kmalloc_failed1;
1985 drv->output_buffer = kmalloc((drv->output_buffer_size *
1986 drv->num_output_buffers),
1988 if (!drv->output_buffer)
1989 goto kmalloc_failed2;
1991 /* Allocate the pages for each output buffer. */
1992 for (i = 0; i < drv->num_output_buffers; i++) {
1993 drv->output_buffers[i] = (void *)(drv->output_buffer +
1994 (i * drv->output_buffer_size));
1995 drv->output_sizes[i] = 0;
1996 drv->output_notify[i] = 0;
1999 /* Setup the circular queue of input buffers. */
2000 drv->num_input_buffers = 8;
2001 drv->input_buffer_size = (4096 * 2);
2002 drv->recording_count = 0;
2003 drv->input_front = 0;
2004 drv->input_rear = 0;
2005 drv->input_count = 0;
2006 drv->input_offset = 0;
2007 drv->input_size = 0;
2008 drv->input_active = 0;
2009 drv->input_buffers = kmalloc(drv->num_input_buffers * sizeof(__u8 *),
2011 drv->input_sizes = kmalloc(drv->num_input_buffers *
2012 sizeof(size_t), GFP_KERNEL);
2013 if (!drv->input_buffers || !drv->input_sizes)
2014 goto kmalloc_failed3;
2016 /* Allocate the pages for each input buffer. */
2018 drv->input_buffer = kmalloc((drv->input_buffer_size *
2019 drv->num_input_buffers),
2021 if (!drv->input_buffer)
2022 goto kmalloc_failed4;
2024 for (i = 0; i < drv->num_input_buffers; i++)
2025 drv->input_buffers[i] = (void *)(drv->input_buffer +
2026 (i * drv->input_buffer_size));
2029 drv->input_buffer = drv->output_buffer;
2030 drv->input_buffer_size = drv->output_buffer_size;
2031 drv->num_input_buffers = drv->num_output_buffers;
2032 for (i = 0; i < drv->num_input_buffers; i++)
2033 drv->input_buffers[i] = drv->output_buffers[i];
2035 for (i = 0; i < drv->num_input_buffers; i++)
2036 drv->input_buffers[i] = NULL;
2040 /* Take note of our duplexity */
2041 drv->duplex = duplex;
2043 /* Ensure that the driver is marked as not being open. */
2048 /* Take driver slot, note which we took */
2055 kfree(drv->input_buffer);
2058 if (drv->input_sizes)
2059 kfree(drv->input_sizes);
2060 if (drv->input_buffers)
2061 kfree(drv->input_buffers);
2062 i = drv->num_output_buffers;
2065 kfree(drv->output_buffer);
2068 if (drv->output_buffers)
2069 kfree(drv->output_buffers);
2070 if (drv->output_sizes)
2071 kfree(drv->output_sizes);
2072 if (drv->output_notify)
2073 kfree(drv->output_notify);
2078 int unregister_sparcaudio_driver(struct sparcaudio_driver *drv, int duplex)
2084 /* Figure out which driver is unregistering */
2085 if (drivers[drv->index] != drv)
2088 /* Deallocate the queue of output buffers. */
2089 kfree(drv->output_buffer);
2090 kfree(drv->output_buffers);
2091 kfree(drv->output_sizes);
2092 kfree(drv->output_notify);
2094 /* Deallocate the queue of input buffers. */
2096 kfree(drv->input_buffer);
2097 kfree(drv->input_sizes);
2099 kfree(drv->input_buffers);
2101 if (&(drv->sd_siglist) != NULL)
2102 lis_free_elist( &(drv->sd_siglist) );
2104 /* Unregister ourselves with devfs */
2105 for (i=0; i < sizeof (dev_list) / sizeof (*dev_list); i++) {
2106 sparcaudio_mkname (name_buf, dev_list[i].name, drv->index);
2107 de = devfs_find_handle (devfs_handle, name_buf, 0, 0,
2108 DEVFS_SPECIAL_CHR, 0);
2109 devfs_unregister (de);
2114 /* Null the appropriate driver */
2115 drivers[drv->index] = NULL;
2120 EXPORT_SYMBOL(register_sparcaudio_driver);
2121 EXPORT_SYMBOL(unregister_sparcaudio_driver);
2122 EXPORT_SYMBOL(sparcaudio_output_done);
2123 EXPORT_SYMBOL(sparcaudio_input_done);
2125 static int __init sparcaudio_init(void)
2127 /* Register our character device driver with the VFS. */
2128 if (devfs_register_chrdev(SOUND_MAJOR, "sparcaudio", &sparcaudio_fops))
2131 devfs_handle = devfs_mk_dir (NULL, "sound", NULL);
2135 static void __exit sparcaudio_exit(void)
2137 devfs_unregister_chrdev(SOUND_MAJOR, "sparcaudio");
2138 devfs_unregister (devfs_handle);
2141 module_init(sparcaudio_init);
2142 module_exit(sparcaudio_exit);
2143 MODULE_LICENSE("GPL");
2146 * Code from Linux Streams, Copyright 1995 by
2147 * Graham Wheeler, Francisco J. Ballesteros, Denis Froschauer
2148 * and available under GPL
2152 lis_add_to_elist( strevent_t **list, pid_t pid, short events )
2154 strevent_t *ev = NULL;
2156 if (*list != NULL) {
2157 for (ev = (*list)->se_next;
2158 ev != *list && ev->se_pid < pid;
2163 if (ev == NULL || ev == *list) { /* no slot for pid in list */
2164 ev = (strevent_t *) kmalloc(sizeof(strevent_t), GFP_KERNEL);
2168 if (!*list) { /* create dummy head node */
2171 hd = (strevent_t *) kmalloc(sizeof(strevent_t), GFP_KERNEL);
2176 (*list = hd)->se_pid = 0;
2177 hd->se_next = hd->se_prev = hd; /* empty list */
2180 /* link node last in the list */
2181 ev->se_prev = (*list)->se_prev;
2182 (*list)->se_prev->se_next = ev;
2183 ((*list)->se_prev = ev)->se_next = *list;
2187 } else if (ev->se_pid != pid) { /* link node in the middle of the list */
2190 new = (strevent_t *) kmalloc(sizeof(strevent_t), GFP_KERNEL);
2194 new->se_prev = ev->se_prev;
2196 ev->se_prev->se_next = new;
2198 ev = new; /* use new element */
2203 ev->se_evs |= events;
2208 lis_del_from_elist( strevent_t **list, pid_t pid, short events )
2210 strevent_t *ev = NULL;
2212 if (*list != NULL) {
2213 for (ev = (*list)->se_next;
2214 ev != *list && ev->se_pid < pid;
2219 if (ev == NULL || ev == *list || ev->se_pid != pid)
2222 if ((ev->se_evs &= ~events) == 0) { /* unlink */
2223 if (ev->se_next) /* should always be true */
2224 ev->se_next->se_prev = ev->se_prev;
2225 if (ev->se_prev) /* should always be true */
2226 ev->se_prev->se_next = ev->se_next;
2233 lis_free_elist( strevent_t **list )
2238 for (ev = *list; ev != NULL; ) {
2243 break; /* all done */
2250 lis_get_elist_ent( strevent_t *list, pid_t pid )
2252 strevent_t *ev = NULL;
2257 for(ev = list->se_next ; ev != list && ev->se_pid < pid; ev = ev->se_next)
2259 if (ev != list && ev->se_pid == pid)
2266 kill_procs( struct strevent *elist, int sig, short e)
2272 for(ev = elist->se_next ; ev != elist; ev = ev->se_next)
2273 if ((ev->se_evs & e) != 0) {
2274 res = kill_proc(ev->se_pid, SIGPOLL, 1);
2278 lis_del_from_elist(&elist,
2283 dprintk(("kill_proc: errno %d\n",res));
2290 * Overrides for Emacs so that we follow Linus's tabbing style.
2291 * Emacs will notice this stuff at the end of the file and automatically
2292 * adjust the settings for this buffer only. This must remain at the end
2294 * ---------------------------------------------------------------------------
2297 * c-brace-imaginary-offset: 0
2298 * c-brace-offset: -4
2299 * c-argdecl-indent: 4
2300 * c-label-offset: -4
2301 * c-continued-statement-offset: 4
2302 * c-continued-brace-offset: 0
2303 * indent-tabs-mode: nil