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/isa/ics2101.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: ics2101.c,v 1.9 2001/11/13 08:01:15 lukem Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 1996 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Ken Hornstein and John Kohl.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *        This product includes software developed by the NetBSD 
   21  *        Foundation, Inc. and its contributors.
   22  * 4. Neither the name of The NetBSD Foundation nor the names of its 
   23  *    contributors may be used to endorse or promote products derived 
   24  *    from this software without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36  * POSSIBILITY OF SUCH DAMAGE.
   37  */
   38 
   39 #include <sys/cdefs.h>
   40 __KERNEL_RCSID(0, "$NetBSD: ics2101.c,v 1.9 2001/11/13 08:01:15 lukem Exp $");
   41 
   42 #include <sys/param.h>
   43 #include <sys/systm.h>
   44 #include <sys/errno.h>
   45 #include <sys/ioctl.h>
   46 #include <sys/syslog.h>
   47 #include <sys/device.h>
   48 #include <sys/proc.h>
   49 #include <sys/buf.h>
   50 
   51 #include <machine/cpu.h>
   52 
   53 #include <sys/audioio.h>
   54 #include <dev/audio_if.h>
   55 
   56 #include <dev/isa/isavar.h>
   57 #include <dev/isa/isadmavar.h>
   58 
   59 #include <dev/ic/ics2101reg.h>
   60 #include <dev/isa/ics2101var.h>
   61 
   62 
   63 #define ICS_VALUE       0x01
   64 #define ICS_MUTE        0x02
   65 #define ICS_MUTE_MUTED  0x04
   66 
   67 /* convert from [AUDIO_MIN_GAIN,AUDIO_MAX_GAIN] (0,255) to
   68    [ICSMIX_MAX_ATTN,ICSMIX_MIN_ATTN] (0,127) */
   69 
   70 #define cvt_value(val) ((val) >> 1)
   71 
   72 static void ics2101_mix_doit __P((struct ics2101_softc *, u_int, u_int, u_int,
   73     u_int));
   74 /*
   75  * Program one channel of the ICS mixer
   76  */
   77 
   78 
   79 static void
   80 ics2101_mix_doit(sc, chan, side, value, flags)
   81         struct ics2101_softc *sc;
   82         u_int chan, side, value, flags;
   83 {
   84         bus_space_tag_t iot = sc->sc_iot;
   85         unsigned char flip_left[6] = {0x01, 0x01, 0x01, 0x02, 0x01, 0x02};
   86         unsigned char flip_right[6] = {0x02, 0x02, 0x02, 0x01, 0x02, 0x01};
   87         unsigned char ctrl_addr;
   88         unsigned char attn_addr;
   89         unsigned char normal;
   90         int s;
   91 
   92         if (chan < ICSMIX_CHAN_0 || chan > ICSMIX_CHAN_5)
   93                 return;
   94         if (side != ICSMIX_LEFT && side != ICSMIX_RIGHT)
   95                 return;
   96 
   97         if (flags & ICS_MUTE) {
   98                 value = cvt_value(sc->sc_setting[chan][side]);
   99                 sc->sc_mute[chan][side] = flags & ICS_MUTE_MUTED;
  100         } else if (flags & ICS_VALUE) {
  101                 sc->sc_setting[chan][side] = value;
  102                 value = cvt_value(value);
  103                 if (value > ICSMIX_MIN_ATTN)
  104                         value = ICSMIX_MIN_ATTN;
  105         } else
  106                 return;
  107 
  108         ctrl_addr = chan << 3;
  109         attn_addr = chan << 3;
  110 
  111         if (side == ICSMIX_LEFT) {
  112                 ctrl_addr |= ICSMIX_CTRL_LEFT;
  113                 attn_addr |= ICSMIX_ATTN_LEFT;
  114                 if (sc->sc_mute[chan][side])
  115                         normal = 0x0;
  116                 else if (sc->sc_flags & ICS_FLIP)
  117                         normal = flip_left[chan];
  118                 else
  119                         normal = 0x01;
  120         } else {
  121                 ctrl_addr |= ICSMIX_CTRL_RIGHT;
  122                 attn_addr |= ICSMIX_ATTN_RIGHT;
  123                 if (sc->sc_mute[chan][side])
  124                         normal = 0x0;
  125                 else if (sc->sc_flags & ICS_FLIP)
  126                         normal = flip_right[chan];
  127                 else
  128                         normal = 0x02;
  129         }
  130 
  131         s = splaudio();
  132 
  133         bus_space_write_1(iot, sc->sc_selio_ioh, sc->sc_selio, ctrl_addr);
  134         bus_space_write_1(iot, sc->sc_dataio_ioh, sc->sc_dataio, normal);
  135 
  136         bus_space_write_1(iot, sc->sc_selio_ioh, sc->sc_selio, attn_addr);
  137         bus_space_write_1(iot, sc->sc_dataio_ioh, sc->sc_dataio, (unsigned char) value);
  138 
  139         splx(s);
  140 }
  141 
  142 void
  143 ics2101_mix_mute(sc, chan, side, domute)
  144         struct ics2101_softc *sc;
  145         unsigned int chan, side, domute;
  146 {
  147     ics2101_mix_doit(sc, chan, side, 0,
  148                      domute ? ICS_MUTE|ICS_MUTE_MUTED : ICS_MUTE);
  149 }
  150 
  151 void
  152 ics2101_mix_attenuate(sc, chan, side, value)
  153         struct ics2101_softc *sc;
  154         unsigned int chan, side, value;
  155 {
  156     ics2101_mix_doit(sc, chan, side, value, ICS_VALUE);
  157 }

Cache object: 9c07f30e610c5ce3f35f0e849502abb3


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