Deleted Added
full compact
mixer.c (246421) mixer.c (246454)
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
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 $");
38SND_DECLARE_FILE("$FreeBSD: head/sys/dev/sound/pcm/mixer.c 246454 2013-02-07 08:20:03Z 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
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)
896mixer_hwvol_mute_locked(struct snd_mixer *m)
897{
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 }
898 if (m->hwvol_muted) {
899 m->hwvol_muted = 0;
900 mixer_set(m, m->hwvol_mixer, m->hwvol_mute_level);
901 } else {
902 m->hwvol_muted++;
903 m->hwvol_mute_level = mixer_get(m, m->hwvol_mixer);
904 mixer_set(m, m->hwvol_mixer, 0);
905 }
912 snd_mtxunlock(m->lock);
913}
914
915void
906}
907
908void
916mixer_hwvol_step(device_t dev, int left_step, int right_step)
909mixer_hwvol_mute(device_t dev)
917{
918 struct snd_mixer *m;
910{
911 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);
912 struct cdev *pdev;
913
914 pdev = mixer_get_devt(dev);
915 m = pdev->si_drv1;
916 snd_mtxlock(m->lock);
917 mixer_hwvol_mute_locked(m);
918 snd_mtxunlock(m->lock);
919}
920
921void
922mixer_hwvol_step_locked(struct snd_mixer *m, int left_step, int right_step)
923{
924 int level, left, right;
925
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;
926 if (m->hwvol_muted) {
927 m->hwvol_muted = 0;
928 level = m->hwvol_mute_level;
929 } else
930 level = mixer_get(m, m->hwvol_mixer);
931 if (level != -1) {
932 left = level & 0xff;
932 right = level >> 8;
933 right = (level >> 8) & 0xff;
933 left += left_step * m->hwvol_step;
934 if (left < 0)
935 left = 0;
934 left += left_step * m->hwvol_step;
935 if (left < 0)
936 left = 0;
937 else if (left > 100)
938 left = 100;
936 right += right_step * m->hwvol_step;
937 if (right < 0)
938 right = 0;
939 right += right_step * m->hwvol_step;
940 if (right < 0)
941 right = 0;
942 else if (right > 100)
943 right = 100;
939 mixer_set(m, m->hwvol_mixer, left | right << 8);
940 }
944 mixer_set(m, m->hwvol_mixer, left | right << 8);
945 }
946}
947
948void
949mixer_hwvol_step(device_t dev, int left_step, int right_step)
950{
951 struct snd_mixer *m;
952 struct cdev *pdev;
953
954 pdev = mixer_get_devt(dev);
955 m = pdev->si_drv1;
956 snd_mtxlock(m->lock);
957 mixer_hwvol_step_locked(m, left_step, right_step);
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 ---
958 snd_mtxunlock(m->lock);
959}
960
961int
962mixer_busy(struct snd_mixer *m)
963{
964 KASSERT(m != NULL, ("NULL snd_mixer"));
965

--- 573 unchanged lines hidden ---