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/isapnp/gus_isapnp.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 /*      $NetBSD: gus_isapnp.c,v 1.22 2003/05/03 18:11:30 wiz Exp $      */
    2 
    3 /*
    4  * Copyright (c) 1997, 1999 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * Author: Kari Mettinen
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 1. Redistributions of source code must retain the above copyright
   13  *    notice, this list of conditions and the following disclaimer.
   14  * 2. Redistributions in binary form must reproduce the above copyright
   15  *    notice, this list of conditions and the following disclaimer in the
   16  *    documentation and/or other materials provided with the distribution.
   17  * 3. All advertising materials mentioning features or use of this software
   18  *    must display the following acknowledgement:
   19  *        This product includes software developed by the NetBSD
   20  *        Foundation, Inc. and its contributors.
   21  * 4. Neither the name of The NetBSD Foundation nor the names of its
   22  *    contributors may be used to endorse or promote products derived
   23  *    from this software without specific prior written permission.
   24  *
   25  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   26  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   35  * POSSIBILITY OF SUCH DAMAGE.
   36  */
   37 
   38 #include <sys/cdefs.h>
   39 __KERNEL_RCSID(0, "$NetBSD: gus_isapnp.c,v 1.22 2003/05/03 18:11:30 wiz Exp $");
   40 
   41 #include "guspnp.h"
   42 #if NGUSPNP > 0
   43 
   44 #include <sys/param.h>
   45 #include <sys/fcntl.h>
   46 #include <sys/vnode.h>
   47 #include <sys/poll.h>
   48 #include <sys/malloc.h>
   49 #include <sys/select.h>
   50 #include <sys/systm.h>
   51 #include <sys/errno.h>
   52 #include <sys/ioctl.h>
   53 #include <sys/syslog.h>
   54 #include <sys/device.h>
   55 #include <sys/proc.h>
   56 
   57 #include <machine/bus.h>
   58 
   59 #include <sys/audioio.h>
   60 #include <dev/audio_if.h>
   61 #include <dev/audiovar.h>
   62 #include <dev/mulaw.h>
   63 
   64 #include <dev/isa/isavar.h>
   65 #include <dev/isa/isadmavar.h>
   66 
   67 #include <dev/isapnp/isapnpreg.h>
   68 #include <dev/isapnp/isapnpvar.h>
   69 #include <dev/isapnp/isapnpdevs.h>
   70 
   71 
   72 #include <dev/ic/interwavevar.h>
   73 #include <dev/ic/interwavereg.h>
   74 
   75 
   76 int     gus_isapnp_match __P((struct device *, struct cfdata *, void *));
   77 void    gus_isapnp_attach __P((struct device *, struct device *, void *));
   78 static int     gus_isapnp_open __P((void *, int));
   79 
   80 static struct audio_hw_if guspnp_hw_if = {
   81         gus_isapnp_open,
   82         iwclose,
   83         NULL,
   84         
   85         iw_query_encoding,
   86         iw_set_params,
   87         
   88         iw_round_blocksize,
   89         
   90         iw_commit_settings,
   91         
   92         iw_init_output,
   93         iw_init_input,
   94         iw_start_output,
   95         iw_start_input,
   96         iw_halt_output,
   97         iw_halt_input,
   98         
   99         iw_speaker_ctl,
  100         
  101         iw_getdev,
  102         iw_setfd,
  103         iw_set_port,
  104         iw_get_port,
  105         iw_query_devinfo,
  106         iw_malloc,
  107         iw_free,
  108         iw_round_buffersize,
  109         iw_mappage,
  110         iw_get_props,
  111         NULL,
  112         NULL,
  113         NULL,
  114 };
  115 
  116 
  117 
  118 CFATTACH_DECL(guspnp, sizeof(struct iw_softc),
  119     gus_isapnp_match, gus_isapnp_attach, NULL, NULL);
  120 
  121 extern struct cfdriver guspnp_cd;
  122 
  123 /*
  124  * Probe / attach routines.
  125  */
  126 
  127 /*
  128  * Probe for the guspnp hardware.
  129  *
  130  * The thing has 5 separate devices on the card
  131  */
  132 
  133 static int gus_0 = 1;           /* XXX what's this */
  134 
  135 int
  136 gus_isapnp_match(parent, match, aux)
  137         struct device *parent;
  138         struct cfdata *match;
  139         void *aux;
  140 {
  141         int pri, variant;
  142 
  143         pri = isapnp_devmatch(aux, &isapnp_gus_devinfo, &variant);
  144         if (pri && variant > 0)
  145                 pri = 0;
  146         return (pri);
  147 }
  148 
  149 
  150 
  151 /*
  152  * Attach hardware to driver, attach hardware driver to audio
  153  * pseudo-device driver.
  154  */
  155 
  156 void
  157 gus_isapnp_attach(parent, self, aux)
  158         struct device *parent, *self;
  159         void *aux;
  160 {
  161         struct iw_softc *sc = (struct iw_softc *)self;
  162         struct isapnp_attach_args *ipa = aux;
  163 
  164         printf("\n");
  165 
  166         if (!gus_0)
  167                 return;
  168         gus_0 = 0;
  169 
  170         if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
  171                 printf("%s: error in region allocation\n", 
  172                        sc->sc_dev.dv_xname);
  173                 return;
  174         }
  175 
  176         sc->sc_iot = ipa->ipa_iot;
  177 
  178         /* handle is the region base */
  179 
  180         sc->dir_h = 0; /* XXXXX */
  181         sc->p2xr = 0;
  182         sc->p2xr_h = ipa->ipa_io[0].h;
  183         sc->sc_p2xr_ic = ipa->ipa_ic;
  184         sc->p3xr = 0;
  185         sc->p3xr_h = ipa->ipa_io[1].h;
  186         sc->sc_p3xr_ic = ipa->ipa_ic;
  187         sc->codec_index = 0;
  188         sc->codec_index_h = ipa->ipa_io[2].h;
  189         sc->sc_irq = ipa->ipa_irq[0].num;
  190         sc->sc_recdrq = ipa->ipa_drq[0].num;
  191         sc->sc_playdrq = ipa->ipa_drq[1].num;
  192 
  193         sc->sc_ic = ipa->ipa_ic;
  194 
  195         /*
  196          * Create our DMA maps.
  197          */
  198         if (sc->sc_playdrq != -1) {
  199                 sc->sc_play_maxsize = isa_dmamaxsize(sc->sc_ic,
  200                     sc->sc_playdrq);
  201                 if (isa_dmamap_create(sc->sc_ic, sc->sc_playdrq,
  202                     sc->sc_play_maxsize, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) {
  203                         printf("%s: can't create map for drq %d\n",
  204                             sc->sc_dev.dv_xname, sc->sc_playdrq);
  205                         return;
  206                       }
  207               }
  208         if (sc->sc_recdrq != -1) {
  209                 sc->sc_rec_maxsize = isa_dmamaxsize(sc->sc_ic,
  210                     sc->sc_recdrq);
  211                 if (isa_dmamap_create(sc->sc_ic, sc->sc_recdrq,
  212                     sc->sc_rec_maxsize, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) {
  213                         printf("%s: can't create map for drq %d\n",
  214                             sc->sc_dev.dv_xname, sc->sc_recdrq);
  215                         return;
  216                       }
  217               }
  218 
  219         /*
  220          * isapnp is a child if isa, and we need isa for the DMA
  221          * routines.
  222          */
  223         sc->iw_cd = &guspnp_cd;
  224         sc->iw_hw_if = &guspnp_hw_if;
  225 
  226         printf("%s: %s %s", sc->sc_dev.dv_xname, ipa->ipa_devident,
  227                ipa->ipa_devclass);
  228 
  229         iwattach(sc);
  230 }
  231 
  232 static
  233 int 
  234 gus_isapnp_open(addr, flags)
  235      void *addr;
  236      int flags;
  237 {
  238         /* open hardware */
  239         struct iw_softc *sc = (struct iw_softc *)addr;
  240 
  241         if (!sc)
  242                 return ENXIO;
  243 
  244         return iwopen(sc,flags);
  245 }
  246 
  247 #endif /* NGUSPNP */

Cache object: 57afe43c0415af59879df1d45167694e


[ 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.