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 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 |
896mixer_hwvol_mute_locked(struct snd_mixer *m) |
897{ |
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 } |
906} 907 908void |
909mixer_hwvol_mute(device_t dev) |
910{ 911 struct snd_mixer *m; |
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 |
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; |
933 right = (level >> 8) & 0xff; |
934 left += left_step * m->hwvol_step; 935 if (left < 0) 936 left = 0; |
937 else if (left > 100) 938 left = 100; |
939 right += right_step * m->hwvol_step; 940 if (right < 0) 941 right = 0; |
942 else if (right > 100) 943 right = 100; |
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); |
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 --- |