1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2005-2009 Ariff Abdullah <ariff@FreeBSD.org> 5 * Copyright (c) 1999 Cameron Grant <cg@FreeBSD.org> 6 * All rights reserved. 7 * Copyright (c) 2026 The FreeBSD Foundation 8 * 9 * Portions of this software were developed by Christos Margiolis 10 * <christos@FreeBSD.org> under sponsorship from the FreeBSD Foundation. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34 #ifndef _PCM_MIXER_H_ 35 #define _PCM_MIXER_H_ 36 37 #define MIXER_NAMELEN 16 38 struct snd_mixer { 39 KOBJ_FIELDS; 40 void *devinfo; 41 int hwvol_mixer; 42 int hwvol_step; 43 int type; 44 device_t dev; 45 u_int32_t devs; 46 u_int32_t mutedevs; 47 u_int32_t recdevs; 48 u_int32_t recsrc; 49 u_int16_t level[32]; 50 u_int16_t level_muted[32]; 51 u_int8_t parent[32]; 52 u_int32_t child[32]; 53 u_int8_t realdev[32]; 54 char name[MIXER_NAMELEN]; 55 struct mtx lock; 56 int modify_counter; 57 }; 58 59 struct snd_mixer *mixer_create(device_t dev, kobj_class_t cls, void *devinfo, 60 const char *desc); 61 int mixer_delete(struct snd_mixer *m); 62 int mixer_init(device_t dev, kobj_class_t cls, void *devinfo); 63 int mixer_uninit(device_t dev); 64 int mixer_reinit(device_t dev); 65 int mixer_ioctl_cmd(struct cdev *i_dev, u_long cmd, caddr_t arg, int mode, struct thread *td); 66 int mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi); 67 68 int mixer_hwvol_init(device_t dev); 69 void mixer_hwvol_mute_locked(struct snd_mixer *m); 70 void mixer_hwvol_mute(device_t dev); 71 void mixer_hwvol_step_locked(struct snd_mixer *m, int l_step, int r_step); 72 void mixer_hwvol_step(device_t dev, int left_step, int right_step); 73 74 int mix_set(struct snd_mixer *m, u_int dev, u_int left, u_int right); 75 int mix_get(struct snd_mixer *m, u_int dev); 76 int mix_setrecsrc(struct snd_mixer *m, u_int32_t src); 77 u_int32_t mix_getrecsrc(struct snd_mixer *m); 78 device_t mix_get_dev(struct snd_mixer *m); 79 80 void mix_setdevs(struct snd_mixer *m, u_int32_t v); 81 void mix_setrecdevs(struct snd_mixer *m, u_int32_t v); 82 void mix_setmutedevs(struct snd_mixer *m, u_int32_t v); 83 u_int32_t mix_getdevs(struct snd_mixer *m); 84 u_int32_t mix_getrecdevs(struct snd_mixer *m); 85 u_int32_t mix_getmutedevs(struct snd_mixer *m); 86 void mix_setparentchild(struct snd_mixer *m, u_int32_t parent, u_int32_t childs); 87 void mix_setrealdev(struct snd_mixer *m, u_int32_t dev, u_int32_t realdev); 88 u_int32_t mix_getparent(struct snd_mixer *m, u_int32_t dev); 89 void *mix_getdevinfo(struct snd_mixer *m); 90 91 #define MIXER_TYPE_PRIMARY 0 /* mixer_init() */ 92 #define MIXER_TYPE_SECONDARY 1 /* mixer_create() */ 93 94 #define MIXER_DECLARE(name) static DEFINE_CLASS(name, name ## _methods, \ 95 sizeof(struct snd_mixer)) 96 97 #endif /* _PCM_MIXER_H_ */ 98