diff --git a/sys/dev/sound/unit.c b/sys/dev/sound/unit.c --- a/sys/dev/sound/unit.c +++ b/sys/dev/sound/unit.c @@ -3,6 +3,10 @@ * * Copyright (c) 2007 Ariff Abdullah * All rights reserved. + * Copyright (c) 2024 The FreeBSD Foundation + * + * Portions of this software were developed by Christos Margiolis + * under sponsorship from the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -56,98 +60,65 @@ static int snd_c_shift = 10; /* 0 - 0x3ff : 1024 distinct channels (256 limit "by design") */ -static int snd_unit_initialized = 0; - -#ifdef SND_DIAGNOSTIC -#define SND_UNIT_ASSERT() do { \ - if (snd_unit_initialized == 0) \ - panic("%s(): Uninitialized sound unit!", __func__); \ -} while (0) -#else -#define SND_UNIT_ASSERT() KASSERT(snd_unit_initialized != 0, \ - ("%s(): Uninitialized sound unit!", \ - __func__)) -#endif - #define MKMASK(x) ((1 << snd_##x##_shift) - 1) int snd_max_u(void) { - SND_UNIT_ASSERT(); - return (MKMASK(u)); } int snd_max_d(void) { - SND_UNIT_ASSERT(); - return (MKMASK(d)); } int snd_max_c(void) { - SND_UNIT_ASSERT(); - return (MKMASK(c)); } int snd_unit2u(int unit) { - SND_UNIT_ASSERT(); - return ((unit >> (snd_c_shift + snd_d_shift)) & MKMASK(u)); } int snd_unit2d(int unit) { - SND_UNIT_ASSERT(); - return ((unit >> snd_c_shift) & MKMASK(d)); } int snd_unit2c(int unit) { - SND_UNIT_ASSERT(); - return (unit & MKMASK(c)); } int snd_u2unit(int u) { - SND_UNIT_ASSERT(); - return ((u & MKMASK(u)) << (snd_c_shift + snd_d_shift)); } int snd_d2unit(int d) { - SND_UNIT_ASSERT(); - return ((d & MKMASK(d)) << snd_c_shift); } int snd_c2unit(int c) { - SND_UNIT_ASSERT(); - return (c & MKMASK(c)); } int snd_mkunit(int u, int d, int c) { - SND_UNIT_ASSERT(); - return ((c & MKMASK(c)) | ((d & MKMASK(d)) << snd_c_shift) | ((u & MKMASK(u)) << (snd_c_shift + snd_d_shift))); } @@ -160,11 +131,6 @@ { int i; - if (snd_unit_initialized != 0) - return; - - snd_unit_initialized = 1; - if (getenv_int("hw.snd.maxunit", &i) != 0) { if (i < SND_UNIT_UMIN) i = SND_UNIT_UMIN;