Deleted Added
full compact
mixer.c (130640) mixer.c (130792)
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

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <dev/sound/pcm/sound.h>
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

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

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <dev/sound/pcm/sound.h>
28#include <sys/kernel.h>
28
29#include "mixer_if.h"
30
29
30#include "mixer_if.h"
31
31SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/mixer.c 130640 2004-06-17 17:16:53Z phk $");
32SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/mixer.c 130792 2004-06-20 15:38:11Z josef $");
32
33MALLOC_DEFINE(M_MIXER, "mixer", "mixer");
34
35#define MIXER_NAMELEN 16
36struct snd_mixer {
37 KOBJ_FIELDS;
38 const char *type;
39 void *devinfo;

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

184 return m->devinfo;
185}
186
187int
188mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
189{
190 struct snddev_info *snddev;
191 struct snd_mixer *m;
33
34MALLOC_DEFINE(M_MIXER, "mixer", "mixer");
35
36#define MIXER_NAMELEN 16
37struct snd_mixer {
38 KOBJ_FIELDS;
39 const char *type;
40 void *devinfo;

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

185 return m->devinfo;
186}
187
188int
189mixer_init(device_t dev, kobj_class_t cls, void *devinfo)
190{
191 struct snddev_info *snddev;
192 struct snd_mixer *m;
193 char devname[20];
192 u_int16_t v;
193 struct cdev *pdev;
194 u_int16_t v;
195 struct cdev *pdev;
194 int i, unit;
196 int i, unit, val;
195
196 m = (struct snd_mixer *)kobj_create(cls, M_MIXER, M_WAITOK | M_ZERO);
197 snprintf(m->name, MIXER_NAMELEN, "%s:mixer", device_get_nameunit(dev));
198 m->lock = snd_mtxcreate(m->name, "pcm mixer");
199 m->type = cls->name;
200 m->devinfo = devinfo;
201 m->busy = 0;
202
203 if (MIXER_INIT(m))
204 goto bad;
205
206 for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
197
198 m = (struct snd_mixer *)kobj_create(cls, M_MIXER, M_WAITOK | M_ZERO);
199 snprintf(m->name, MIXER_NAMELEN, "%s:mixer", device_get_nameunit(dev));
200 m->lock = snd_mtxcreate(m->name, "pcm mixer");
201 m->type = cls->name;
202 m->devinfo = devinfo;
203 m->busy = 0;
204
205 if (MIXER_INIT(m))
206 goto bad;
207
208 for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
207 v = snd_mixerdefaults[i];
209 snprintf(devname, sizeof(devname), "%s.%s", device_get_nameunit(dev), snd_mixernames[i]);
210 TUNABLE_INT_FETCH(devname, &val);
211
212 if (val >= 0 && val <= 100)
213 v = (u_int16_t) val;
214 else
215 v = snd_mixerdefaults[i];
216
208 mixer_set(m, i, v | (v << 8));
209 }
210
211 mixer_setrecsrc(m, SOUND_MASK_MIC);
212
213 unit = device_get_unit(dev);
214 pdev = make_dev(&mixer_cdevsw, PCMMKMINOR(unit, SND_DEV_CTL, 0),
215 UID_ROOT, GID_WHEEL, 0666, "mixer%d", unit);

--- 297 unchanged lines hidden ---
217 mixer_set(m, i, v | (v << 8));
218 }
219
220 mixer_setrecsrc(m, SOUND_MASK_MIC);
221
222 unit = device_get_unit(dev);
223 pdev = make_dev(&mixer_cdevsw, PCMMKMINOR(unit, SND_DEV_CTL, 0),
224 UID_ROOT, GID_WHEEL, 0666, "mixer%d", unit);

--- 297 unchanged lines hidden ---