dsp.c (82185) | dsp.c (83089) |
---|---|
1/* 2 * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/param.h> 28#include <sys/queue.h> 29 30#include <dev/sound/pcm/sound.h> 31 | 1/* 2 * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 15 unchanged lines hidden (view full) --- 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/param.h> 28#include <sys/queue.h> 29 30#include <dev/sound/pcm/sound.h> 31 |
32SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/dsp.c 82185 2001-08-23 12:21:12Z cg $"); | 32SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/dsp.c 83089 2001-09-05 16:28:41Z cg $"); |
33 34#define OLDPCM_IOCTL 35 36static d_open_t dsp_open; 37static d_close_t dsp_close; 38static d_read_t dsp_read; 39static d_write_t dsp_write; 40static d_ioctl_t dsp_ioctl; --- 153 unchanged lines hidden (view full) --- 194 case SND_DEV_AUDIO: 195 fmt = AFMT_MU_LAW; 196 break; 197 198 case SND_DEV_NORESET: 199 fmt = 0; 200 break; 201 | 33 34#define OLDPCM_IOCTL 35 36static d_open_t dsp_open; 37static d_close_t dsp_close; 38static d_read_t dsp_read; 39static d_write_t dsp_write; 40static d_ioctl_t dsp_ioctl; --- 153 unchanged lines hidden (view full) --- 194 case SND_DEV_AUDIO: 195 fmt = AFMT_MU_LAW; 196 break; 197 198 case SND_DEV_NORESET: 199 fmt = 0; 200 break; 201 |
202 case SND_DEV_DSPREC: 203 fmt = AFMT_U8; 204 if (mode & FWRITE) { 205 splx(s); 206 return EINVAL; 207 } 208 break; 209 |
|
202 default: 203 panic("impossible devtype %d", devtype); 204 } 205 206 /* lock snddev so nobody else can monkey with it */ 207 pcm_lock(d); 208 if ((dsp_get_flags(i_dev) & SD_F_SIMPLEX) && (i_dev->si_drv1 || i_dev->si_drv2)) { 209 /* simplex device, already open, exit */ --- 5 unchanged lines hidden (view full) --- 215 /* if we get here, the open request is valid */ 216 rdch = i_dev->si_drv1; 217 wrch = i_dev->si_drv2; 218 219 if (flags & FREAD) { 220 /* open for read */ 221 if (rdch == NULL) { 222 /* not already open, try to get a channel */ | 210 default: 211 panic("impossible devtype %d", devtype); 212 } 213 214 /* lock snddev so nobody else can monkey with it */ 215 pcm_lock(d); 216 if ((dsp_get_flags(i_dev) & SD_F_SIMPLEX) && (i_dev->si_drv1 || i_dev->si_drv2)) { 217 /* simplex device, already open, exit */ --- 5 unchanged lines hidden (view full) --- 223 /* if we get here, the open request is valid */ 224 rdch = i_dev->si_drv1; 225 wrch = i_dev->si_drv2; 226 227 if (flags & FREAD) { 228 /* open for read */ 229 if (rdch == NULL) { 230 /* not already open, try to get a channel */ |
223 rdch = pcm_chnalloc(d, PCMDIR_REC, p->p_pid); | 231 if (devtype == SND_DEV_DSPREC) 232 rdch = pcm_chnalloc(d, PCMDIR_REC, p->p_pid, PCMCHAN(i_dev)); 233 else 234 rdch = pcm_chnalloc(d, PCMDIR_REC, p->p_pid, -1); |
224 if (!rdch) { 225 /* no channel available, exit */ 226 pcm_unlock(d); 227 splx(s); 228 return EBUSY; 229 } 230 /* got a channel, already locked for us */ 231 } else { 232 /* already open for read, exit */ 233 pcm_unlock(d); 234 splx(s); 235 return EBUSY; 236 } 237 } 238 239 if (flags & FWRITE) { 240 /* open for write */ 241 if (wrch == NULL) { 242 /* not already open, try to get a channel */ | 235 if (!rdch) { 236 /* no channel available, exit */ 237 pcm_unlock(d); 238 splx(s); 239 return EBUSY; 240 } 241 /* got a channel, already locked for us */ 242 } else { 243 /* already open for read, exit */ 244 pcm_unlock(d); 245 splx(s); 246 return EBUSY; 247 } 248 } 249 250 if (flags & FWRITE) { 251 /* open for write */ 252 if (wrch == NULL) { 253 /* not already open, try to get a channel */ |
243 wrch = pcm_chnalloc(d, PCMDIR_PLAY, p->p_pid); | 254 wrch = pcm_chnalloc(d, PCMDIR_PLAY, p->p_pid, -1); |
244 if (!wrch) { 245 /* no channel available */ 246 if (rdch && (flags & FREAD)) { 247 /* just opened a read channel, release it */ 248 pcm_chnrelease(rdch); 249 } 250 /* exit */ 251 pcm_unlock(d); --- 779 unchanged lines hidden (view full) --- 1031 UID_ROOT, GID_WHEEL, 0666, "dspW%d.%d", unit, channel); 1032 make_dev(&dsp_cdevsw, PCMMKMINOR(unit, SND_DEV_AUDIO, channel), 1033 UID_ROOT, GID_WHEEL, 0666, "audio%d.%d", unit, channel); 1034 1035 return 0; 1036} 1037 1038int | 255 if (!wrch) { 256 /* no channel available */ 257 if (rdch && (flags & FREAD)) { 258 /* just opened a read channel, release it */ 259 pcm_chnrelease(rdch); 260 } 261 /* exit */ 262 pcm_unlock(d); --- 779 unchanged lines hidden (view full) --- 1042 UID_ROOT, GID_WHEEL, 0666, "dspW%d.%d", unit, channel); 1043 make_dev(&dsp_cdevsw, PCMMKMINOR(unit, SND_DEV_AUDIO, channel), 1044 UID_ROOT, GID_WHEEL, 0666, "audio%d.%d", unit, channel); 1045 1046 return 0; 1047} 1048 1049int |
1050dsp_registerrec(int unit, int channel) 1051{ 1052 make_dev(&dsp_cdevsw, PCMMKMINOR(unit, SND_DEV_DSPREC, channel), 1053 UID_ROOT, GID_WHEEL, 0666, "dspr%d.%d", unit, channel); 1054 1055 return 0; 1056} 1057 1058int |
|
1039dsp_unregister(int unit, int channel) 1040{ 1041 dev_t pdev; 1042 1043 pdev = makedev(SND_CDEV_MAJOR, PCMMKMINOR(unit, SND_DEV_DSP, channel)); 1044 destroy_dev(pdev); 1045 pdev = makedev(SND_CDEV_MAJOR, PCMMKMINOR(unit, SND_DEV_DSP16, channel)); 1046 destroy_dev(pdev); 1047 pdev = makedev(SND_CDEV_MAJOR, PCMMKMINOR(unit, SND_DEV_AUDIO, channel)); 1048 destroy_dev(pdev); 1049 1050 return 0; 1051} 1052 | 1059dsp_unregister(int unit, int channel) 1060{ 1061 dev_t pdev; 1062 1063 pdev = makedev(SND_CDEV_MAJOR, PCMMKMINOR(unit, SND_DEV_DSP, channel)); 1064 destroy_dev(pdev); 1065 pdev = makedev(SND_CDEV_MAJOR, PCMMKMINOR(unit, SND_DEV_DSP16, channel)); 1066 destroy_dev(pdev); 1067 pdev = makedev(SND_CDEV_MAJOR, PCMMKMINOR(unit, SND_DEV_AUDIO, channel)); 1068 destroy_dev(pdev); 1069 1070 return 0; 1071} 1072 |
1073int 1074dsp_unregisterrec(int unit, int channel) 1075{ 1076 dev_t pdev; 1077 1078 pdev = makedev(SND_CDEV_MAJOR, PCMMKMINOR(unit, SND_DEV_DSPREC, channel)); 1079 destroy_dev(pdev); 1080 1081 return 0; 1082} 1083 |
|
1053#ifdef USING_DEVFS 1054static void 1055dsp_clone(void *arg, char *name, int namelen, dev_t *dev) 1056{ 1057 dev_t pdev; 1058 int i, cont, unit, devtype; 1059 int devtypes[3] = {SND_DEV_DSP, SND_DEV_DSP16, SND_DEV_AUDIO}; 1060 char *devnames[3] = {"dsp", "dspW", "audio"}; --- 52 unchanged lines hidden --- | 1084#ifdef USING_DEVFS 1085static void 1086dsp_clone(void *arg, char *name, int namelen, dev_t *dev) 1087{ 1088 dev_t pdev; 1089 int i, cont, unit, devtype; 1090 int devtypes[3] = {SND_DEV_DSP, SND_DEV_DSP16, SND_DEV_AUDIO}; 1091 char *devnames[3] = {"dsp", "dspW", "audio"}; --- 52 unchanged lines hidden --- |