dsp.c (45550658617bab1a5e2228cc0adb133e5e76aea0) dsp.c (5ee30e277a97679dd1cbd4a1746339a5f14546aa)
1/*
2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
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

--- 27 unchanged lines hidden (view full) ---

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;
41static d_poll_t dsp_poll;
42static d_mmap_t dsp_mmap;
43
1/*
2 * Copyright (c) 1999 Cameron Grant <cg@freebsd.org>
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

--- 27 unchanged lines hidden (view full) ---

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;
41static d_poll_t dsp_poll;
42static d_mmap_t dsp_mmap;
43
44static struct cdevsw dsp_cdevsw = {
44struct cdevsw dsp_cdevsw = {
45 .d_open = dsp_open,
46 .d_close = dsp_close,
47 .d_read = dsp_read,
48 .d_write = dsp_write,
49 .d_ioctl = dsp_ioctl,
50 .d_poll = dsp_poll,
51 .d_mmap = dsp_mmap,
52 .d_name = "dsp",

--- 986 unchanged lines hidden (view full) ---

1039
1040 *paddr = vtophys(sndbuf_getbufofs(c->bufsoft, offset));
1041 relchns(i_dev, rdch, wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
1042
1043 splx(s);
1044 return 0;
1045}
1046
45 .d_open = dsp_open,
46 .d_close = dsp_close,
47 .d_read = dsp_read,
48 .d_write = dsp_write,
49 .d_ioctl = dsp_ioctl,
50 .d_poll = dsp_poll,
51 .d_mmap = dsp_mmap,
52 .d_name = "dsp",

--- 986 unchanged lines hidden (view full) ---

1039
1040 *paddr = vtophys(sndbuf_getbufofs(c->bufsoft, offset));
1041 relchns(i_dev, rdch, wrch, SD_F_PRIO_RD | SD_F_PRIO_WR);
1042
1043 splx(s);
1044 return 0;
1045}
1046
1047int
1048dsp_register(int unit, int channel)
1049{
1050 dev_t dt;
1051 int r;
1052
1053 dt = make_dev(&dsp_cdevsw, PCMMKMINOR(unit, SND_DEV_DSP, channel),
1054 UID_ROOT, GID_WHEEL, 0666, "dsp%d.%d", unit, channel);
1055 r = pcm_regdevt(dt, unit, SND_DEV_DSP, channel);
1056 if (r)
1057 return r;
1058
1059 dt = make_dev(&dsp_cdevsw, PCMMKMINOR(unit, SND_DEV_DSP16, channel),
1060 UID_ROOT, GID_WHEEL, 0666, "dspW%d.%d", unit, channel);
1061 r = pcm_regdevt(dt, unit, SND_DEV_DSP16, channel);
1062 if (r)
1063 return r;
1064
1065 dt = make_dev(&dsp_cdevsw, PCMMKMINOR(unit, SND_DEV_AUDIO, channel),
1066 UID_ROOT, GID_WHEEL, 0666, "audio%d.%d", unit, channel);
1067 r = pcm_regdevt(dt, unit, SND_DEV_AUDIO, channel);
1068 if (r)
1069 return r;
1070
1071 return 0;
1072}
1073
1074int
1075dsp_registerrec(int unit, int channel)
1076{
1077 dev_t dt;
1078 int r;
1079
1080 dt = make_dev(&dsp_cdevsw, PCMMKMINOR(unit, SND_DEV_DSPREC, channel),
1081 UID_ROOT, GID_WHEEL, 0666, "dspr%d.%d", unit, channel);
1082
1083 r = pcm_regdevt(dt, unit, SND_DEV_DSPREC, channel);
1084
1085 return r;
1086}
1087
1088int
1089dsp_unregister(int unit, int channel)
1090{
1091 dev_t pdev;
1092 int r;
1093
1094 pdev = pcm_getdevt(unit, SND_DEV_DSP, channel);
1095 if (pdev == NULL)
1096 return ENOENT;
1097 destroy_dev(pdev);
1098 r = pcm_unregdevt(unit, SND_DEV_DSP, channel);
1099 if (r)
1100 return r;
1101
1102 pdev = pcm_getdevt(unit, SND_DEV_DSP16, channel);
1103 if (pdev == NULL)
1104 return ENOENT;
1105 destroy_dev(pdev);
1106 r = pcm_unregdevt(unit, SND_DEV_DSP16, channel);
1107 if (r)
1108 return r;
1109
1110 pdev = pcm_getdevt(unit, SND_DEV_AUDIO, channel);
1111 if (pdev == NULL)
1112 return ENOENT;
1113 destroy_dev(pdev);
1114 r = pcm_unregdevt(unit, SND_DEV_AUDIO, channel);
1115 if (r)
1116 return r;
1117
1118 return 0;
1119}
1120
1121int
1122dsp_unregisterrec(int unit, int channel)
1123{
1124 dev_t pdev;
1125 int r;
1126
1127 pdev = pcm_getdevt(unit, SND_DEV_DSPREC, channel);
1128 if (pdev == NULL)
1129 return ENOENT;
1130 destroy_dev(pdev);
1131 r = pcm_unregdevt(unit, SND_DEV_DSPREC, channel);
1132
1133 return r;
1134}
1135
1136#ifdef USING_DEVFS
1047#ifdef USING_DEVFS
1048
1049/*
1050 * Clone logic is this:
1051 * x E X = {dsp, dspW, audio}
1052 * x -> x${sysctl("hw.snd.unit")}
1053 * xN->
1054 * for i N = 1 to channels of device N
1055 * if xN.i isn't busy, return its dev_t
1056 */
1137static void
1138dsp_clone(void *arg, char *name, int namelen, dev_t *dev)
1139{
1140 dev_t pdev;
1057static void
1058dsp_clone(void *arg, char *name, int namelen, dev_t *dev)
1059{
1060 dev_t pdev;
1141 int i, cont, unit, devtype;
1061 struct snddev_info *pcm_dev;
1062 struct snddev_channel *pcm_chan;
1063 int i, unit, devtype;
1142 int devtypes[3] = {SND_DEV_DSP, SND_DEV_DSP16, SND_DEV_AUDIO};
1143 char *devnames[3] = {"dsp", "dspW", "audio"};
1144
1145 if (*dev != NODEV)
1146 return;
1147 if (pcm_devclass == NULL)
1148 return;
1149

--- 6 unchanged lines hidden (view full) ---

1156 } else {
1157 if (dev_stdclone(name, NULL, devnames[i], &unit) != 1)
1158 unit = -1;
1159 }
1160 }
1161 if (unit == -1 || unit >= devclass_get_maxunit(pcm_devclass))
1162 return;
1163
1064 int devtypes[3] = {SND_DEV_DSP, SND_DEV_DSP16, SND_DEV_AUDIO};
1065 char *devnames[3] = {"dsp", "dspW", "audio"};
1066
1067 if (*dev != NODEV)
1068 return;
1069 if (pcm_devclass == NULL)
1070 return;
1071

--- 6 unchanged lines hidden (view full) ---

1078 } else {
1079 if (dev_stdclone(name, NULL, devnames[i], &unit) != 1)
1080 unit = -1;
1081 }
1082 }
1083 if (unit == -1 || unit >= devclass_get_maxunit(pcm_devclass))
1084 return;
1085
1164 cont = 1;
1165 for (i = 0; cont; i++) {
1166 pdev = pcm_getdevt(unit, devtype, i);
1167 if (pdev->si_flags & SI_NAMED) {
1168 if ((pdev->si_drv1 == NULL) && (pdev->si_drv2 == NULL)) {
1169 *dev = pdev;
1170 return;
1171 }
1172 } else {
1173 cont = 0;
1086 pcm_dev = devclass_get_softc(pcm_devclass, unit);
1087
1088 SLIST_FOREACH(pcm_chan, &pcm_dev->channels, link) {
1089
1090 switch(devtype) {
1091 case SND_DEV_DSP:
1092 pdev = pcm_chan->dsp_devt;
1093 break;
1094 case SND_DEV_DSP16:
1095 pdev = pcm_chan->dspW_devt;
1096 break;
1097 case SND_DEV_AUDIO:
1098 pdev = pcm_chan->audio_devt;
1099 break;
1100 default:
1101 panic("Unknown devtype %d", devtype);
1174 }
1102 }
1103
1104 if ((pdev->si_drv1 == NULL) && (pdev->si_drv2 == NULL)) {
1105 *dev = pdev;
1106 return;
1107 }
1175 }
1176}
1177
1178static void
1179dsp_sysinit(void *p)
1180{
1181 dsp_ehtag = EVENTHANDLER_REGISTER(dev_clone, dsp_clone, 0, 1000);
1182}

--- 13 unchanged lines hidden ---
1108 }
1109}
1110
1111static void
1112dsp_sysinit(void *p)
1113{
1114 dsp_ehtag = EVENTHANDLER_REGISTER(dev_clone, dsp_clone, 0, 1000);
1115}

--- 13 unchanged lines hidden ---