The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/sound/fdt/dummy_codec.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    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>
   49 #include <dev/sound/fdt/audio_dai.h>
   50 #include "audio_dai_if.h"
   51 
   52 static struct ofw_compat_data compat_data[] = {
   53         { "dummy-codec",        1},
   54         { NULL,                 0 }
   55 };
   56 
   57 struct dummy_codec_softc {
   58         device_t        dev;
   59 };
   60 
   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);
   64 
   65 static int
   66 dummy_codec_probe(device_t dev)
   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 
   78 static int
   79 dummy_codec_attach(device_t dev)
   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 
   93 static int
   94 dummy_codec_detach(device_t dev)
   95 {
   96 
   97         return (0);
   98 }
   99 
  100 static int
  101 dummy_codec_dai_init(device_t dev, uint32_t format)
  102 {
  103 
  104         return (0);
  105 }
  106 
  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),
  112 
  113         DEVMETHOD(audio_dai_init,       dummy_codec_dai_init),
  114 
  115         DEVMETHOD_END
  116 };
  117 
  118 static driver_t dummy_codec_driver = {
  119         "dummycodec",
  120         dummy_codec_methods,
  121         sizeof(struct dummy_codec_softc),
  122 };
  123 
  124 DRIVER_MODULE(dummy_codec, simplebus, dummy_codec_driver, 0, 0);
  125 SIMPLEBUS_PNP_INFO(compat_data);

Cache object: be63c557e193c756ef6fc9aa061e7b19


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.