1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2005-2009 Ariff Abdullah <ariff@FreeBSD.org> 5 * Copyright (c) 2001 Cameron Grant <cg@FreeBSD.org> 6 * All rights reserved. 7 * Copyright (c) 2024-2025 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 _SND_VCHAN_H_ 35 #define _SND_VCHAN_H_ 36 37 extern bool snd_vchans_enable; 38 39 int vchan_create(struct pcm_channel *, struct pcm_channel **); 40 int vchan_destroy(struct pcm_channel *); 41 42 #ifdef SND_DEBUG 43 int vchan_passthrough(struct pcm_channel *, const char *); 44 #define vchan_sync(c) vchan_passthrough(c, __func__) 45 #else 46 int vchan_sync(struct pcm_channel *); 47 #endif 48 49 #define VCHAN_SYNC_REQUIRED(c) \ 50 (((c)->flags & CHN_F_VIRTUAL) && (((c)->flags & CHN_F_DIRTY) || \ 51 sndbuf_getfmt((c)->bufhard) != (c)->parentchannel->format || \ 52 sndbuf_getspd((c)->bufhard) != (c)->parentchannel->speed)) 53 54 void vchan_initsys(device_t); 55 56 /* 57 * Default format / rate 58 */ 59 #define VCHAN_DEFAULT_FORMAT SND_FORMAT(AFMT_S16_LE, 2, 0) 60 #define VCHAN_DEFAULT_RATE 48000 61 62 #define VCHAN_PLAY 0 63 #define VCHAN_REC 1 64 65 /* 66 * Offset by +/- 1 so we can distinguish bogus pointer. 67 */ 68 #define VCHAN_SYSCTL_DATA(x, y) \ 69 ((void *)((intptr_t)(((((x) + 1) & 0xfff) << 2) | \ 70 (((VCHAN_##y) + 1) & 0x3)))) 71 72 #define VCHAN_SYSCTL_DATA_SIZE sizeof(void *) 73 #define VCHAN_SYSCTL_UNIT(x) ((int)(((intptr_t)(x) >> 2) & 0xfff) - 1) 74 #define VCHAN_SYSCTL_DIR(x) ((int)((intptr_t)(x) & 0x3) - 1) 75 76 #endif /* _SND_VCHAN_H_ */ 77