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

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 *
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

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 * $FreeBSD: head/sys/dev/sound/pcm/mixer.c 70291 2000-12-23 03:16:13Z cg $
26 * $FreeBSD: head/sys/dev/sound/pcm/mixer.c 70618 2001-01-03 01:29:47Z jhb $
27 */
28
29#include <dev/sound/pcm/sound.h>
30
31#include "mixer_if.h"
32
33MALLOC_DEFINE(M_MIXER, "mixer", "mixer");
34

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

249 v = mixer_get(m, j);
250 }
251 *arg_i = v;
252 return (v != -1)? 0 : ENXIO;
253 }
254 return ENXIO;
255}
256
27 */
28
29#include <dev/sound/pcm/sound.h>
30
31#include "mixer_if.h"
32
33MALLOC_DEFINE(M_MIXER, "mixer", "mixer");
34

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

249 v = mixer_get(m, j);
250 }
251 *arg_i = v;
252 return (v != -1)? 0 : ENXIO;
253 }
254 return ENXIO;
255}
256
257static int hwvol_step = 5;
258SYSCTL_INT(_hw_snd, OID_AUTO, hwvol_step, CTLFLAG_RW, &hwvol_step, 0, "");
259
260static int hwvol_mixer = SOUND_MIXER_VOLUME;
261SYSCTL_INT(_hw_snd, OID_AUTO, hwvol_mixer, CTLFLAG_RW, &hwvol_mixer, 0, "");
262
263void
264mixer_hwmute(device_t dev)
265{
266 snddev_info *d;
267
268 d = device_get_softc(dev);
269 mixer_set(d->mixer, hwvol_mixer, 0);
270}
271
272void
273mixer_hwstep(device_t dev, int left_step, int right_step)
274{
275 snddev_info *d;
276 int level, left, right;
277
278 d = device_get_softc(dev);
279 level = mixer_get(d->mixer, hwvol_mixer);
280 if (level != -1) {
281 left = level & 0xff;
282 right = level >> 8;
283 left += left_step * hwvol_step;
284 if (left < 0)
285 left = 0;
286 right += right_step * hwvol_step;
287 if (right < 0)
288 right = 0;
289 mixer_set(d->mixer, hwvol_mixer, left | right << 8);
290 }
291}
292
257/*
258 * The various mixers use a variety of bitmasks etc. The Voxware
259 * driver had a very nice technique to describe a mixer and interface
260 * to it. A table defines, for each channel, which register, bits,
261 * offset, polarity to use. This procedure creates the new value
262 * using the table and the old value.
263 */
264

--- 23 unchanged lines hidden ---
293/*
294 * The various mixers use a variety of bitmasks etc. The Voxware
295 * driver had a very nice technique to describe a mixer and interface
296 * to it. A table defines, for each channel, which register, bits,
297 * offset, polarity to use. This procedure creates the new value
298 * using the table and the old value.
299 */
300

--- 23 unchanged lines hidden ---