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/isa/es1888.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1999 Doug Rabson
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  */
   26 
   27 #include <dev/sound/pcm/sound.h>
   28 #include <dev/sound/isa/sb.h>
   29 
   30 #include <isa/isavar.h>
   31 
   32 SND_DECLARE_FILE("$FreeBSD: releng/6.4/sys/dev/sound/isa/es1888.c 139749 2005-01-06 01:43:34Z imp $");
   33 
   34 #ifdef __alpha__
   35 static int
   36 es1888_dspready(u_int32_t port)
   37 {
   38         return ((inb(port + SBDSP_STATUS) & 0x80) == 0);
   39 }
   40 
   41 static int
   42 es1888_dspwr(u_int32_t port, u_char val)
   43 {
   44         int  i;
   45 
   46         for (i = 0; i < 1000; i++) {
   47                 if (es1888_dspready(port)) {
   48                         outb(port + SBDSP_CMD, val);
   49                         return 0;
   50                 }
   51                 if (i > 10) DELAY((i > 100)? 1000 : 10);
   52         }
   53         return ENXIO;
   54 }
   55 
   56 static u_int
   57 es1888_get_byte(u_int32_t port)
   58 {
   59         int i;
   60 
   61         for (i = 1000; i > 0; i--) {
   62                 if (inb(port + DSP_DATA_AVAIL) & 0x80)
   63                         return inb(port + DSP_READ);
   64                 else
   65                         DELAY(20);
   66         }
   67         return 0xffff;
   68 }
   69 
   70 static int
   71 es1888_reset(u_int32_t port)
   72 {
   73         outb(port + SBDSP_RST, 3);
   74         DELAY(100);
   75         outb(port + SBDSP_RST, 0);
   76         if (es1888_get_byte(port) != 0xAA) {
   77                 return ENXIO;   /* Sorry */
   78         }
   79         return 0;
   80 }
   81 
   82 static void
   83 es1888_configuration_mode(void)
   84 {
   85         /*
   86          * Emit the Read-Sequence-Key to enter configuration
   87          * mode. Note this only works after a reset (or after bit 2 of
   88          * mixer register 0x40 is set).
   89          *
   90          * 3 reads from 0x229 in a row guarantees reset of key
   91          * sequence to beginning.
   92          */
   93         inb(0x229);
   94         inb(0x229);
   95         inb(0x229);
   96 
   97         inb(0x22b);             /* state 1 */
   98         inb(0x229);             /* state 2 */
   99         inb(0x22b);             /* state 3 */
  100         inb(0x229);             /* state 4 */
  101         inb(0x229);             /* state 5 */
  102         inb(0x22b);             /* state 6 */
  103         inb(0x229);             /* state 7 */
  104 }
  105 
  106 static void
  107 es1888_set_port(u_int32_t port)
  108 {
  109         es1888_configuration_mode();
  110         inb(port);
  111 }
  112 #endif
  113 
  114 static void
  115 es1888_identify(driver_t *driver, device_t parent)
  116 {
  117 /*
  118  * Only use this on alpha since PNPBIOS is a better solution on x86.
  119  */
  120 #ifdef __alpha__
  121         u_int32_t lo, hi;
  122         device_t dev;
  123 
  124         es1888_set_port(0x220);
  125         if (es1888_reset(0x220))
  126                 return;
  127 
  128         /*
  129          * Check identification bytes for es1888.
  130          */
  131         if (es1888_dspwr(0x220, 0xe7))
  132                 return;
  133         hi = es1888_get_byte(0x220);
  134         lo = es1888_get_byte(0x220);
  135         if (hi != 0x68 || (lo & 0xf0) != 0x80)
  136                 return;
  137 
  138         /*
  139          * Program irq and drq.
  140          */
  141         if (es1888_dspwr(0x220, 0xc6) /* enter extended mode */
  142             || es1888_dspwr(0x220, 0xb1) /* write register b1 */
  143             || es1888_dspwr(0x220, 0x14) /* enable irq 5 */
  144             || es1888_dspwr(0x220, 0xb2) /* write register b1 */
  145             || es1888_dspwr(0x220, 0x18)) /* enable drq 1 */
  146                 return;
  147 
  148         /*
  149          * Create the device and program its resources.
  150          */
  151         dev = BUS_ADD_CHILD(parent, ISA_ORDER_PNPBIOS, NULL, -1);
  152         bus_set_resource(dev, SYS_RES_IOPORT, 0, 0x220, 0x10);
  153         bus_set_resource(dev, SYS_RES_IRQ, 0, 5, 1);
  154         bus_set_resource(dev, SYS_RES_DRQ, 0, 1, 1);
  155         isa_set_vendorid(dev, PNP_EISAID("ESS1888"));
  156         isa_set_logicalid(dev, PNP_EISAID("ESS1888"));
  157 #endif
  158 }
  159 
  160 static device_method_t es1888_methods[] = {
  161         /* Device interface */
  162         DEVMETHOD(device_identify,      es1888_identify),
  163 
  164         { 0, 0 }
  165 };
  166 
  167 static driver_t es1888_driver = {
  168         "pcm",
  169         es1888_methods,
  170         1,                      /* no softc */
  171 };
  172 
  173 DRIVER_MODULE(snd_es1888, isa, es1888_driver, pcm_devclass, 0, 0);
  174 MODULE_DEPEND(snd_es1888, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
  175 MODULE_VERSION(snd_es1888, 1);
  176 
  177 

Cache object: 9713fbf087f11a1e1441aa3a582bb38d


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