root/dev/isa/ad1848var.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ad1848_devmap_t
  2. ad1848_to_vol
  3. ad1848_from_vol

    1 /*      $OpenBSD: ad1848var.h,v 1.12 2002/03/14 03:16:05 millert Exp $  */
    2 /*      $NetBSD: ad1848var.h,v 1.22 1998/01/19 22:18:26 augustss Exp $  */
    3 
    4 /*
    5  * Copyright (c) 1994 John Brezak
    6  * Copyright (c) 1991-1993 Regents of the University of California.
    7  * All rights reserved.
    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 Computer Systems
   20  *      Engineering Group at Lawrence Berkeley Laboratory.
   21  * 4. Neither the name of the University nor of the Laboratory may be used
   22  *    to endorse or promote products derived from this software without
   23  *    specific prior written permission.
   24  *
   25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   35  * SUCH DAMAGE.
   36  *
   37  */
   38 
   39 #define AD1848_NPORT    4
   40 
   41 struct ad1848_volume {
   42         u_char  left;
   43         u_char  right;
   44 };
   45 
   46 struct ad1848_softc {
   47         struct  device sc_dev;          /* base device */
   48         struct  isadev sc_id;           /* ISA device */
   49         void    *sc_ih;                 /* interrupt vectoring */
   50         bus_space_tag_t sc_iot;         /* tag */
   51         bus_space_handle_t sc_ioh;      /* handle */
   52         int     sc_iooffs;              /* offset from handle */
   53 
   54         void    *parent;
   55         struct  device *sc_isa;         /* ISA bus's device */
   56 
   57         u_short sc_locked;              /* true when doing HS DMA  */
   58         u_int   sc_lastcc;              /* size of last DMA xfer */
   59         int     sc_mode;                /* half-duplex record/play */
   60         
   61         int     sc_dma_flags;
   62         void    *sc_dma_bp;
   63         u_int   sc_dma_cnt;
   64 
   65         char    sc_playrun;             /* running in continuous mode */
   66         char    sc_recrun;              /* running in continuous mode */
   67 #define NOTRUNNING 0
   68 #define DMARUNNING 1
   69 #define PCMRUNNING 2
   70 
   71         int     sc_irq;                 /* interrupt */
   72         int     sc_drq;                 /* DMA */
   73         int     sc_recdrq;              /* record/capture DMA */
   74         
   75         /* We keep track of these */
   76         struct ad1848_volume gains[6];
   77 
   78         struct ad1848_volume rec_gain;
   79 
   80         int     rec_port;               /* recording port */
   81 
   82         /* ad1848 */
   83         u_char  MCE_bit;
   84         char    mic_gain_on;            /* CS4231 only */
   85         char    mute[6];
   86 
   87         char    *chip_name;
   88         int     mode;
   89         
   90         u_int   precision;              /* 8/16 bits */
   91         int     channels;
   92         
   93         u_char  speed_bits;
   94         u_char  format_bits;
   95         u_char  need_commit;
   96 
   97         u_long  sc_interrupts;          /* number of interrupts taken */
   98         void    (*sc_intr)(void *);     /* dma completion intr handler */
   99         void    *sc_arg;                /* arg for sc_intr() */
  100 
  101         /* Only used by pss XXX */
  102         int     sc_iobase;
  103 };
  104 
  105 #define MUTE_LEFT       1
  106 #define MUTE_RIGHT      2
  107 #define MUTE_ALL        (MUTE_LEFT | MUTE_RIGHT)
  108 #define MUTE_MONO       MUTE_ALL
  109 
  110 /* Don't change this ordering without seriously looking around.
  111    These are indexes into mute[] array and into a register information
  112    array */
  113 #define AD1848_AUX2_CHANNEL        0
  114 #define AD1848_AUX1_CHANNEL        1
  115 #define AD1848_DAC_CHANNEL         2
  116 #define AD1848_LINE_CHANNEL        3
  117 #define AD1848_MONO_CHANNEL        4
  118 #define AD1848_MONITOR_CHANNEL     5    /* Doesn't seem to be on all later chips */
  119 
  120 /*
  121  * Ad1848 ports
  122  */
  123 #define MIC_IN_PORT     0
  124 #define LINE_IN_PORT    1
  125 #define AUX1_IN_PORT    2
  126 #define DAC_IN_PORT     3
  127 
  128 #ifdef _KERNEL
  129 
  130 #define AD1848_KIND_LVL   0
  131 #define AD1848_KIND_MUTE  1
  132 #define AD1848_KIND_RECORDGAIN 2
  133 #define AD1848_KIND_MICGAIN 3
  134 #define AD1848_KIND_RECORDSOURCE 4
  135 
  136 typedef struct ad1848_devmap {
  137   int  id;
  138   int  kind;
  139   int  dev;
  140 } ad1848_devmap_t;
  141 
  142 static __inline int ad1848_to_vol(mixer_ctrl_t *, struct ad1848_volume *);
  143 static __inline int ad1848_from_vol(mixer_ctrl_t *, struct ad1848_volume *);
  144 
  145 static __inline int
  146 ad1848_to_vol(cp, vol)
  147         mixer_ctrl_t *cp;
  148         struct ad1848_volume *vol;
  149 {
  150         if (cp->un.value.num_channels == 1) {
  151                 vol->left = vol->right = cp->un.value.level[AUDIO_MIXER_LEVEL_MONO];
  152                 return(1);
  153         }
  154         else if (cp->un.value.num_channels == 2) {
  155                 vol->left  = cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT];
  156                 vol->right = cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT];
  157                 return(1);
  158         }
  159         return(0);
  160 }
  161 
  162 static __inline int
  163 ad1848_from_vol(cp, vol)
  164         mixer_ctrl_t *cp;
  165         struct ad1848_volume *vol;
  166 {
  167         if (cp->un.value.num_channels == 1) {
  168                 cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = vol->left;
  169                 return(1);
  170         }
  171         else if (cp->un.value.num_channels == 2) {
  172                 cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = vol->left;
  173                 cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = vol->right;
  174                 return(1);
  175         }
  176         return(0);
  177 }
  178 
  179 
  180 int     ad1848_mixer_get_port(struct ad1848_softc *, ad1848_devmap_t *, int cnt, mixer_ctrl_t *);
  181 int     ad1848_mixer_set_port(struct ad1848_softc *, ad1848_devmap_t *, int, mixer_ctrl_t *);
  182 int     ad1848_mapprobe(struct ad1848_softc *, int);
  183 int     ad1848_probe(struct ad1848_softc *);
  184 void    ad1848_unmap(struct ad1848_softc *);
  185 void    ad1848_attach(struct ad1848_softc *);
  186 
  187 int     ad1848_open(void *, int);
  188 void    ad1848_close(void *);
  189     
  190 void    ad1848_forceintr(struct ad1848_softc *);
  191 
  192 int     ad1848_query_encoding(void *, struct audio_encoding *);
  193 int     ad1848_set_params(void *, int, int, struct audio_params *, struct audio_params *);
  194 
  195 int     ad1848_round_blocksize(void *, int);
  196 
  197 int     ad1848_dma_init_output(void *, void *, int);
  198 int     ad1848_dma_init_input(void *, void *, int);
  199 int     ad1848_dma_output(void *, void *, int, void (*)(void *), void *);
  200 int     ad1848_dma_input(void *, void *, int, void (*)(void *), void *);
  201 
  202 int     ad1848_commit_settings(void *);
  203 
  204 int     ad1848_halt_in_dma(void *);
  205 int     ad1848_halt_out_dma(void *);
  206 
  207 int     ad1848_intr(void *);
  208 
  209 int     ad1848_set_rec_port(struct ad1848_softc *, int);
  210 int     ad1848_get_rec_port(struct ad1848_softc *);
  211 
  212 int     ad1848_set_channel_gain(struct ad1848_softc *, int, struct ad1848_volume *);
  213 int     ad1848_get_device_gain(struct ad1848_softc *, int, struct ad1848_volume *);
  214 int     ad1848_set_rec_gain(struct ad1848_softc *, struct ad1848_volume *);
  215 int     ad1848_get_rec_gain(struct ad1848_softc *, struct ad1848_volume *);
  216 /* Note: The mic pre-MUX gain is not a variable gain, it's 20dB or 0dB */
  217 int     ad1848_set_mic_gain(struct ad1848_softc *, struct ad1848_volume *);
  218 int     ad1848_get_mic_gain(struct ad1848_softc *, struct ad1848_volume *);
  219 void     ad1848_mute_channel(struct ad1848_softc *, int device, int mute);
  220 
  221 void   *ad1848_malloc(void *, int, size_t, int, int);
  222 void    ad1848_free(void *, void *, int);
  223 size_t  ad1848_round(void *, int, size_t);
  224 paddr_t ad1848_mappage(void *, void *, off_t, int);
  225 
  226 int     ad1848_get_props(void *);
  227 
  228 #endif

/* [<][>][^][v][top][bottom][index][help] */