FreeBSD kernel sound device code
dummy_codec.c
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2020 Oleksandr Tymoshenko <gonzo@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
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.
14 *
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
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD$
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD$");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/bus.h>
36#include <sys/kernel.h>
37#include <sys/lock.h>
38#include <sys/module.h>
39#include <sys/mutex.h>
40#include <sys/rman.h>
41#include <sys/resource.h>
42#include <machine/bus.h>
43
44#include <dev/ofw/ofw_bus.h>
45#include <dev/ofw/ofw_bus_subr.h>
46
47#include "opt_snd.h"
48#include <dev/sound/pcm/sound.h>
50#include "audio_dai_if.h"
51
52static struct ofw_compat_data compat_data[] = {
53 { "dummy-codec", 1},
54 { NULL, 0 }
55};
56
58 device_t dev;
59};
60
61static int dummy_codec_probe(device_t dev);
62static int dummy_codec_attach(device_t dev);
63static int dummy_codec_detach(device_t dev);
64
65static int
67{
68 if (!ofw_bus_status_okay(dev))
69 return (ENXIO);
70
71 if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data)
72 return (ENXIO);
73
74 device_set_desc(dev, "Dummy Codec");
75 return (BUS_PROBE_DEFAULT);
76}
77
78static int
80{
81 struct dummy_codec_softc *sc;
82 phandle_t node;
83
84 sc = device_get_softc(dev);
85 sc->dev = dev;
86
87 node = ofw_bus_get_node(dev);
88 OF_device_register_xref(OF_xref_from_node(node), dev);
89
90 return (0);
91}
92
93static int
95{
96
97 return (0);
98}
99
100static int
101dummy_codec_dai_init(device_t dev, uint32_t format)
102{
103
104 return (0);
105}
106
107static 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),
112
113 DEVMETHOD(audio_dai_init, dummy_codec_dai_init),
114
115 DEVMETHOD_END
116};
117
118static driver_t dummy_codec_driver = {
119 "dummycodec",
121 sizeof(struct dummy_codec_softc),
122};
123
124static devclass_t dummy_codec_devclass;
125
uint32_t format
Definition: audio_dai_if.m:39
DRIVER_MODULE(dummy_codec, simplebus, dummy_codec_driver, dummy_codec_devclass, 0, 0)
static int dummy_codec_attach(device_t dev)
Definition: dummy_codec.c:79
static device_method_t dummy_codec_methods[]
Definition: dummy_codec.c:107
static int dummy_codec_dai_init(device_t dev, uint32_t format)
Definition: dummy_codec.c:101
static int dummy_codec_probe(device_t dev)
Definition: dummy_codec.c:66
__FBSDID("$FreeBSD$")
static int dummy_codec_detach(device_t dev)
Definition: dummy_codec.c:94
static driver_t dummy_codec_driver
Definition: dummy_codec.c:118
static struct ofw_compat_data compat_data[]
Definition: dummy_codec.c:52
SIMPLEBUS_PNP_INFO(compat_data)
static devclass_t dummy_codec_devclass
Definition: dummy_codec.c:124
unsigned dev
Definition: mixer_if.m:59