Deleted Added
sdiff udiff text old ( 246421 ) new ( 246454 )
full compact
1/*-
2 * Copyright (c) 2005-2009 Ariff Abdullah <ariff@FreeBSD.org>
3 * Portions Copyright (c) Ryan Beasley <ryan.beasley@gmail.com> - GSoC 2006
4 * Copyright (c) 1999 Cameron Grant <cg@FreeBSD.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

30#include "opt_snd.h"
31#endif
32
33#include <dev/sound/pcm/sound.h>
34
35#include "feeder_if.h"
36#include "mixer_if.h"
37
38SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/mixer.c 246421 2013-02-06 17:43:05Z hselasky $");
39
40static MALLOC_DEFINE(M_MIXER, "mixer", "mixer");
41
42static int mixer_bypass = 1;
43TUNABLE_INT("hw.snd.vpc_mixer_bypass", &mixer_bypass);
44SYSCTL_INT(_hw_snd, OID_AUTO, vpc_mixer_bypass, CTLFLAG_RW,
45 &mixer_bypass, 0,
46 "control channel pcm/rec volume, bypassing real mixer device");

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

888 SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
889 SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
890 OID_AUTO, "hwvol_mixer", CTLTYPE_STRING | CTLFLAG_RW, m, 0,
891 sysctl_hw_snd_hwvol_mixer, "A", "");
892 return 0;
893}
894
895void
896mixer_hwvol_mute(device_t dev)
897{
898 struct snd_mixer *m;
899 struct cdev *pdev;
900
901 pdev = mixer_get_devt(dev);
902 m = pdev->si_drv1;
903 snd_mtxlock(m->lock);
904 if (m->hwvol_muted) {
905 m->hwvol_muted = 0;
906 mixer_set(m, m->hwvol_mixer, m->hwvol_mute_level);
907 } else {
908 m->hwvol_muted++;
909 m->hwvol_mute_level = mixer_get(m, m->hwvol_mixer);
910 mixer_set(m, m->hwvol_mixer, 0);
911 }
912 snd_mtxunlock(m->lock);
913}
914
915void
916mixer_hwvol_step(device_t dev, int left_step, int right_step)
917{
918 struct snd_mixer *m;
919 int level, left, right;
920 struct cdev *pdev;
921
922 pdev = mixer_get_devt(dev);
923 m = pdev->si_drv1;
924 snd_mtxlock(m->lock);
925 if (m->hwvol_muted) {
926 m->hwvol_muted = 0;
927 level = m->hwvol_mute_level;
928 } else
929 level = mixer_get(m, m->hwvol_mixer);
930 if (level != -1) {
931 left = level & 0xff;
932 right = level >> 8;
933 left += left_step * m->hwvol_step;
934 if (left < 0)
935 left = 0;
936 right += right_step * m->hwvol_step;
937 if (right < 0)
938 right = 0;
939 mixer_set(m, m->hwvol_mixer, left | right << 8);
940 }
941 snd_mtxunlock(m->lock);
942}
943
944int
945mixer_busy(struct snd_mixer *m)
946{
947 KASSERT(m != NULL, ("NULL snd_mixer"));
948

--- 573 unchanged lines hidden ---