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_REGISTERED(x) ((x) != NULL && (x)->cdev != NULL) 38 39 #define MIXER_NAMELEN 16 40 struct snd_mixer { 41 KOBJ_FIELDS; 42 void *devinfo; 43 int hwvol_mixer; 44 int hwvol_step; 45 int type; 46 device_t dev; 47 uint32_t devs; 48 uint32_t mutedevs; 49 uint32_t recdevs; 50 uint32_t recsrc; 51 uint16_t level[32]; 52 uint16_t level_muted[32]; 53 uint8_t parent[32]; 54 uint32_t child[32]; 55 uint8_t realdev[32]; 56 char name[MIXER_NAMELEN]; 57 struct mtx *lock; 58 struct mtx priv_lock; 59 int modify_counter; 60 struct cdev *cdev; 61 }; 62 63 struct snd_mixer *mixer_create(device_t dev, kobj_class_t cls, void *devinfo, 64 const char *desc); 65 int mixer_delete(struct snd_mixer *m); 66 int mixer_init(device_t dev, kobj_class_t cls, void *devinfo); 67 int mixer_uninit(device_t dev); 68 int mixer_reinit(device_t dev); 69 int mixer_make_dev(device_t dev); 70 int mixer_ioctl_cmd(struct cdev *i_dev, unsigned long cmd, caddr_t arg, 71 int mode, struct thread *td); 72 int mixer_oss_mixerinfo(struct cdev *i_dev, oss_mixerinfo *mi); 73 74 int mixer_hwvol_init(device_t dev); 75 void mixer_hwvol_mute(device_t dev); 76 void mixer_hwvol_step(device_t dev, int left_step, int right_step); 77 78 int mix_set(struct snd_mixer *m, unsigned int dev, unsigned int left, unsigned int right); 79 int mix_get(struct snd_mixer *m, unsigned int dev); 80 int mix_setrecsrc(struct snd_mixer *m, uint32_t src); 81 uint32_t mix_getrecsrc(struct snd_mixer *m); 82 device_t mix_get_dev(struct snd_mixer *m); 83 84 void mix_setdevs(struct snd_mixer *m, uint32_t v); 85 void mix_setrecdevs(struct snd_mixer *m, uint32_t v); 86 void mix_setmutedevs(struct snd_mixer *m, uint32_t v); 87 uint32_t mix_getdevs(struct snd_mixer *m); 88 uint32_t mix_getrecdevs(struct snd_mixer *m); 89 uint32_t mix_getmutedevs(struct snd_mixer *m); 90 void mix_setparentchild(struct snd_mixer *m, uint32_t parent, uint32_t childs); 91 void mix_setrealdev(struct snd_mixer *m, uint32_t dev, uint32_t realdev); 92 uint32_t mix_getparent(struct snd_mixer *m, uint32_t dev); 93 void *mix_getdevinfo(struct snd_mixer *m); 94 95 #define MIXER_TYPE_PRIMARY 0 /* mixer_init() */ 96 #define MIXER_TYPE_SECONDARY 1 /* mixer_create() */ 97 98 #define MIXER_DECLARE(name) static DEFINE_CLASS(name, name ## _methods, \ 99 sizeof(struct snd_mixer)) 100 101 #endif /* _PCM_MIXER_H_ */ 102