1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #ifndef _LX_AUDIO_H
  27 #define _LX_AUDIO_H
  28 
  29 #pragma ident   "%Z%%M% %I%     %E% SMI"
  30 
  31 #include <sys/zone.h>
  32 
  33 #ifdef  __cplusplus
  34 extern "C" {
  35 #endif
  36 
  37 /*
  38  * name for this driver
  39  */
  40 #define LX_AUDIO_DRV                    "lx_audio"
  41 
  42 /*
  43  * names for the minor nodes this driver exports
  44  */
  45 #define LXA_MINORNAME_DEVCTL            "lx_devctl"
  46 #define LXA_MINORNAME_DSP               "lx_dsp"
  47 #define LXA_MINORNAME_MIXER             "lx_mixer"
  48 
  49 /*
  50  * minor numbers for the minor nodes this driver exporrts
  51  */
  52 #define LXA_MINORNUM_DEVCTL             0
  53 #define LXA_MINORNUM_DSP                1
  54 #define LXA_MINORNUM_MIXER              2
  55 #define LXA_MINORNUM_COUNT              3
  56 
  57 /*
  58  * driver ioctls
  59  *
  60  * note that we're layering on top of solaris audio devices so we want
  61  * to make sure that our ioctls namespace doesn't conflict with theirs.
  62  * looking in sys/audioio.h and sys/mixer.h we see that they seem to
  63  * use an _IO key of 'A' and 'M', so we'll choose an _IO key of 'a.'
  64  */
  65 
  66 /*
  67  * administrative ioctls.
  68  * these ioctls are only supported on the DEVCTL minor node
  69  */
  70 #define LXA_IOC_ZONE_REG                (_IOR('a', 0, lxa_zone_reg_t))
  71 #define LXA_IOC_ZONE_UNREG              (_IOR('a', 1, lxa_zone_reg_t))
  72 
  73 
  74 /*
  75  * audio and mixer device ioctls
  76  * these ioctls are supported on DSP and MIXER minor nodes.
  77  */
  78 #define LXA_IOC_GETMINORNUM             (_IOR('a', 20, int))
  79 
  80 /*
  81  * audio device ioctls.
  82  * these ioctls are supports on DSP minor nodes.
  83  */
  84 #define LXA_IOC_MMAP_OUTPUT             (_IOR('a', 41, int))
  85 #define LXA_IOC_MMAP_PTR                (_IOR('a', 42, int))
  86 #define LXA_IOC_GET_FRAG_INFO           (_IOR('a', 43, lxa_frag_info_t))
  87 #define LXA_IOC_SET_FRAG_INFO           (_IOR('a', 44, lxa_frag_info_t))
  88 
  89 /*
  90  * mixer device ioctls.
  91  * these ioctls are supports on MIXER minor nodes.
  92  */
  93 #define LXA_IOC_MIXER_GET_VOL           (_IOR('a', 60, lxa_mixer_levels_t))
  94 #define LXA_IOC_MIXER_SET_VOL           (_IOR('a', 61, lxa_mixer_levels_t))
  95 #define LXA_IOC_MIXER_GET_MIC           (_IOR('a', 62, lxa_mixer_levels_t))
  96 #define LXA_IOC_MIXER_SET_MIC           (_IOR('a', 63, lxa_mixer_levels_t))
  97 #define LXA_IOC_MIXER_GET_PCM           (_IOR('a', 64, lxa_mixer_levels_t))
  98 #define LXA_IOC_MIXER_SET_PCM           (_IOR('a', 65, lxa_mixer_levels_t))
  99 
 100 /* command structure for LXA_IOC_ZONE_REG */
 101 #define LXA_INTSTRLEN 32
 102 typedef struct lxa_zone_reg {
 103         char    lxa_zr_zone_name[ZONENAME_MAX];
 104         char    lxa_zr_inputdev[LXA_INTSTRLEN];
 105         char    lxa_zr_outputdev[LXA_INTSTRLEN];
 106 } lxa_zone_reg_t;
 107 
 108 /* command structure for LXA_IOC_GET_FRAG_INFO and LXA_IOC_SET_FRAG_INFO */
 109 typedef struct lxa_frag_info {
 110         int     lxa_fi_size;
 111         int     lxa_fi_cnt;
 112 } lxa_frag_info_t;
 113 
 114 /* command structure for LXA_IOC_MIXER_GET_* and LXA_IOC_MIXER_SET_* */
 115 typedef struct lxa_mixer_levels {
 116         int     lxa_ml_gain;
 117         int     lxa_ml_balance;
 118 } lxa_mixer_levels_t;
 119 
 120 /* verify that a solaris mixer level structure has valid values */
 121 #define LXA_MIXER_LEVELS_OK(x) (((x)->lxa_ml_gain >= AUDIO_MIN_GAIN) && \
 122                                 ((x)->lxa_ml_gain <= AUDIO_MAX_GAIN) && \
 123                                 ((x)->lxa_ml_balance >= AUDIO_LEFT_BALANCE) && \
 124                                 ((x)->lxa_ml_balance <= AUDIO_RIGHT_BALANCE))
 125 
 126 #ifdef  __cplusplus
 127 }
 128 #endif
 129 
 130 #endif  /* _LX_AUDIO_H */