2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2020 Oleksandr Tymoshenko <gonzo@FreeBSD.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include <sys/param.h>
34 #include <sys/systm.h>
36 #include <sys/kernel.h>
38 #include <sys/module.h>
39 #include <sys/mutex.h>
41 #include <sys/resource.h>
42 #include <machine/bus.h>
44 #include <dev/ofw/ofw_bus.h>
45 #include <dev/ofw/ofw_bus_subr.h>
48 #include <dev/sound/pcm/sound.h>
49 #include <dev/sound/fdt/audio_dai.h>
50 #include "audio_dai_if.h"
52 static struct ofw_compat_data compat_data[] = {
57 struct dummy_codec_softc {
61 static int dummy_codec_probe(device_t dev);
62 static int dummy_codec_attach(device_t dev);
63 static int dummy_codec_detach(device_t dev);
66 dummy_codec_probe(device_t dev)
68 if (!ofw_bus_status_okay(dev))
71 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
74 device_set_desc(dev, "Dummy Codec");
75 return (BUS_PROBE_DEFAULT);
79 dummy_codec_attach(device_t dev)
81 struct dummy_codec_softc *sc;
84 sc = device_get_softc(dev);
87 node = ofw_bus_get_node(dev);
88 OF_device_register_xref(OF_xref_from_node(node), dev);
94 dummy_codec_detach(device_t dev)
101 dummy_codec_dai_init(device_t dev, uint32_t format)
107 static device_method_t dummy_codec_methods[] = {
108 /* Device interface */
109 DEVMETHOD(device_probe, dummy_codec_probe),
110 DEVMETHOD(device_attach, dummy_codec_attach),
111 DEVMETHOD(device_detach, dummy_codec_detach),
113 DEVMETHOD(audio_dai_init, dummy_codec_dai_init),
118 static driver_t dummy_codec_driver = {
121 sizeof(struct dummy_codec_softc),
124 static devclass_t dummy_codec_devclass;
126 DRIVER_MODULE(dummy_codec, simplebus, dummy_codec_driver, dummy_codec_devclass, 0, 0);
127 SIMPLEBUS_PNP_INFO(compat_data);