1*e622eac4Sisaki /* $NetBSD: audio_component.c,v 1.5 2019/05/08 13:40:19 isaki Exp $ */
23bae9757Spooka
33bae9757Spooka /*
43bae9757Spooka * Copyright (c) 2010 Antti Kantee. All Rights Reserved.
53bae9757Spooka *
63bae9757Spooka * Redistribution and use in source and binary forms, with or without
73bae9757Spooka * modification, are permitted provided that the following conditions
83bae9757Spooka * are met:
93bae9757Spooka * 1. Redistributions of source code must retain the above copyright
103bae9757Spooka * notice, this list of conditions and the following disclaimer.
113bae9757Spooka * 2. Redistributions in binary form must reproduce the above copyright
123bae9757Spooka * notice, this list of conditions and the following disclaimer in the
133bae9757Spooka * documentation and/or other materials provided with the distribution.
143bae9757Spooka *
153bae9757Spooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
163bae9757Spooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
173bae9757Spooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
183bae9757Spooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
193bae9757Spooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
203bae9757Spooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
213bae9757Spooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
223bae9757Spooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
233bae9757Spooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
243bae9757Spooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
253bae9757Spooka * SUCH DAMAGE.
263bae9757Spooka */
273bae9757Spooka
283bae9757Spooka #include <sys/cdefs.h>
29*e622eac4Sisaki __KERNEL_RCSID(0, "$NetBSD: audio_component.c,v 1.5 2019/05/08 13:40:19 isaki Exp $");
303bae9757Spooka
313bae9757Spooka #include <sys/param.h>
323bae9757Spooka #include <sys/conf.h>
333bae9757Spooka #include <sys/device.h>
343bae9757Spooka #include <sys/mbuf.h>
353bae9757Spooka #include <sys/stat.h>
363bae9757Spooka
37*e622eac4Sisaki #include <dev/audio/audio_if.h>
383bae9757Spooka
396bb51422Spooka #include <rump-sys/kern.h>
406bb51422Spooka #include <rump-sys/vfs.h>
413bae9757Spooka
RUMP_COMPONENT(RUMP_COMPONENT_DEV)423bae9757Spooka RUMP_COMPONENT(RUMP_COMPONENT_DEV)
433bae9757Spooka {
443bae9757Spooka extern const struct cdevsw audio_cdevsw;
45ab66491cSpgoyette extern devmajor_t audio_bmajor, audio_cmajor;
463bae9757Spooka int error;
473bae9757Spooka
48ab66491cSpgoyette if ((error = devsw_attach("audio", NULL, &audio_bmajor,
49ab66491cSpgoyette &audio_cdevsw, &audio_cmajor)) != 0)
503bae9757Spooka panic("audio devsw attach failed: %d", error);
513bae9757Spooka if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/audio", '0',
52ab66491cSpgoyette audio_cmajor, AUDIO_DEVICE, 4)) !=0)
533bae9757Spooka panic("cannot create audio device nodes: %d", error);
544e4d7694Spooka if ((error = rump_vfs_makesymlink("audio0", "/dev/audio")) != 0)
554e4d7694Spooka panic("cannot create audio symlink: %d", error);
563bae9757Spooka if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/sound", '0',
57ab66491cSpgoyette audio_cmajor, SOUND_DEVICE, 4)) !=0)
583bae9757Spooka panic("cannot create sound device nodes: %d", error);
594e4d7694Spooka if ((error = rump_vfs_makesymlink("sound0", "/dev/sound")) != 0)
604e4d7694Spooka panic("cannot create sound symlink: %d", error);
613bae9757Spooka if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/audioctl", '0',
62ab66491cSpgoyette audio_cmajor, AUDIOCTL_DEVICE, 4)) !=0)
633bae9757Spooka panic("cannot create audioctl device nodes: %d", error);
644e4d7694Spooka if ((error = rump_vfs_makesymlink("audioctl0", "/dev/audioctl")) != 0)
654e4d7694Spooka panic("cannot create audioctl symlink: %d", error);
663bae9757Spooka if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/mixer", '0',
67ab66491cSpgoyette audio_cmajor, MIXER_DEVICE, 4)) !=0)
683bae9757Spooka panic("cannot create mixer device nodes: %d", error);
694e4d7694Spooka if ((error = rump_vfs_makesymlink("mixer0", "/dev/mixer")) != 0)
704e4d7694Spooka panic("cannot create mixer symlink: %d", error);
71ab66491cSpgoyette devsw_detach(NULL, &audio_cdevsw);
723bae9757Spooka }
73